qid int64 46k 74.7M | question stringlengths 54 37.8k | date stringlengths 10 10 | metadata listlengths 3 3 | response_j stringlengths 17 26k | response_k stringlengths 26 26k |
|---|---|---|---|---|---|
68,319,575 | I see that the example python code from Intel offers a way to change the resolution as below:
```
config.enable_stream(rs.stream.depth, 640, 480, rs.format.z16, 30)
# Start streaming
pipeline.start(config)
```
<https://github.com/IntelRealSense/librealsense/blob/master/wrappers/python/examples/opencv_viewer_example.... | 2021/07/09 | [
"https://Stackoverflow.com/questions/68319575",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1231714/"
] | You were close, but you need to set the revised object to a new variable. Also, you probably want to aggregate arrays since there are multiple 'completed'. This first creates the base object and then populates it using `reduce()` for both actions
```
let keys=todos.reduce((b,a) => ({...b, [a.status]:[]}),{}),
rev... | You can group by `status` by destructing the `todo` and recalling (spreading) the previous value or using a new array with the [nullish coalescing operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Nullish_coalescing_operator) (`??`). If your version of JS doesn't support that operato... |
68,319,575 | I see that the example python code from Intel offers a way to change the resolution as below:
```
config.enable_stream(rs.stream.depth, 640, 480, rs.format.z16, 30)
# Start streaming
pipeline.start(config)
```
<https://github.com/IntelRealSense/librealsense/blob/master/wrappers/python/examples/opencv_viewer_example.... | 2021/07/09 | [
"https://Stackoverflow.com/questions/68319575",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1231714/"
] | You were close, but you need to set the revised object to a new variable. Also, you probably want to aggregate arrays since there are multiple 'completed'. This first creates the base object and then populates it using `reduce()` for both actions
```
let keys=todos.reduce((b,a) => ({...b, [a.status]:[]}),{}),
rev... | You're only getting the most recent completed element from the original array because each object in your result is an object, not an array... It might be easier to start with a simple forEach instead of the reduce to see if that gets you what you need:
```js
const todos = [{
id: 'a',
name: 'Buy dog',... |
68,319,575 | I see that the example python code from Intel offers a way to change the resolution as below:
```
config.enable_stream(rs.stream.depth, 640, 480, rs.format.z16, 30)
# Start streaming
pipeline.start(config)
```
<https://github.com/IntelRealSense/librealsense/blob/master/wrappers/python/examples/opencv_viewer_example.... | 2021/07/09 | [
"https://Stackoverflow.com/questions/68319575",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1231714/"
] | ```js
const todos = [{id: 'a',name: 'Buy dog',action: 'a',status: 'deleted'},{id: 'b',name: 'Buy food',tooltip: null,status: 'completed'},{id: 'c',name: 'Heal dog',tooltip: null,status: 'completed'},{id: 'd',name: 'Todo this',action: 'd',status: 'completed'},{id: 'e',name: 'Todo that',action: 'e',status: 'todo'}];
co... | ```
function getByValue(arr, value) {
var result = arr.filter(function(o){return o.status == value;} );
return result? result[0] : null; // or undefined
}
todo_obj = getByValue(arr, 'todo')
deleted_obj = getByValue(arr, 'deleted')
completed_obj = getByValue(arr, 'completed')
``` |
68,319,575 | I see that the example python code from Intel offers a way to change the resolution as below:
```
config.enable_stream(rs.stream.depth, 640, 480, rs.format.z16, 30)
# Start streaming
pipeline.start(config)
```
<https://github.com/IntelRealSense/librealsense/blob/master/wrappers/python/examples/opencv_viewer_example.... | 2021/07/09 | [
"https://Stackoverflow.com/questions/68319575",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1231714/"
] | ```js
const todos = [{id: 'a',name: 'Buy dog',action: 'a',status: 'deleted'},{id: 'b',name: 'Buy food',tooltip: null,status: 'completed'},{id: 'c',name: 'Heal dog',tooltip: null,status: 'completed'},{id: 'd',name: 'Todo this',action: 'd',status: 'completed'},{id: 'e',name: 'Todo that',action: 'e',status: 'todo'}];
co... | Your code is fine, you just need to use the reduce function as an output - it doesn't mutate `todos` it returns a new value.
```js
const todos = [{id: 'a',name: 'Buy dog',action: 'a',status: 'deleted',},{id: 'b',name: 'Buy food',tooltip: null,status: 'completed',},{id: 'c',name: 'Heal dog',tooltip: null,status: 'compl... |
68,319,575 | I see that the example python code from Intel offers a way to change the resolution as below:
```
config.enable_stream(rs.stream.depth, 640, 480, rs.format.z16, 30)
# Start streaming
pipeline.start(config)
```
<https://github.com/IntelRealSense/librealsense/blob/master/wrappers/python/examples/opencv_viewer_example.... | 2021/07/09 | [
"https://Stackoverflow.com/questions/68319575",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1231714/"
] | ```js
const todos = [{id: 'a',name: 'Buy dog',action: 'a',status: 'deleted'},{id: 'b',name: 'Buy food',tooltip: null,status: 'completed'},{id: 'c',name: 'Heal dog',tooltip: null,status: 'completed'},{id: 'd',name: 'Todo this',action: 'd',status: 'completed'},{id: 'e',name: 'Todo that',action: 'e',status: 'todo'}];
co... | You haven't been very clear in your question, I assume you want an output that looks like `{todo: [], completed: [], deleted: []}`.
In that case here is a simple solution.
```js
var todos = [{
id: 'a',
name: 'Buy dog',
action: 'a',
status: 'deleted',
},
{
id: 'b',
name: 'Buy food',
too... |
68,319,575 | I see that the example python code from Intel offers a way to change the resolution as below:
```
config.enable_stream(rs.stream.depth, 640, 480, rs.format.z16, 30)
# Start streaming
pipeline.start(config)
```
<https://github.com/IntelRealSense/librealsense/blob/master/wrappers/python/examples/opencv_viewer_example.... | 2021/07/09 | [
"https://Stackoverflow.com/questions/68319575",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1231714/"
] | ```js
const todos = [{id: 'a',name: 'Buy dog',action: 'a',status: 'deleted'},{id: 'b',name: 'Buy food',tooltip: null,status: 'completed'},{id: 'c',name: 'Heal dog',tooltip: null,status: 'completed'},{id: 'd',name: 'Todo this',action: 'd',status: 'completed'},{id: 'e',name: 'Todo that',action: 'e',status: 'todo'}];
co... | You can group by `status` by destructing the `todo` and recalling (spreading) the previous value or using a new array with the [nullish coalescing operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Nullish_coalescing_operator) (`??`). If your version of JS doesn't support that operato... |
68,319,575 | I see that the example python code from Intel offers a way to change the resolution as below:
```
config.enable_stream(rs.stream.depth, 640, 480, rs.format.z16, 30)
# Start streaming
pipeline.start(config)
```
<https://github.com/IntelRealSense/librealsense/blob/master/wrappers/python/examples/opencv_viewer_example.... | 2021/07/09 | [
"https://Stackoverflow.com/questions/68319575",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1231714/"
] | ```js
const todos = [{id: 'a',name: 'Buy dog',action: 'a',status: 'deleted'},{id: 'b',name: 'Buy food',tooltip: null,status: 'completed'},{id: 'c',name: 'Heal dog',tooltip: null,status: 'completed'},{id: 'd',name: 'Todo this',action: 'd',status: 'completed'},{id: 'e',name: 'Todo that',action: 'e',status: 'todo'}];
co... | You're only getting the most recent completed element from the original array because each object in your result is an object, not an array... It might be easier to start with a simple forEach instead of the reduce to see if that gets you what you need:
```js
const todos = [{
id: 'a',
name: 'Buy dog',... |
34,708,302 | I've got a list of dictionaries in a JSON file that looks like this:
```
[{"url": "http://www.URL1.com", "date": "2001-01-01"},
{"url": "http://www.URL2.com", "date": "2001-01-02"}, ...]
```
but I'm struggling to import it into a pandas data frame — this should be pretty easy, but I'm blanking on it. Anyone able t... | 2016/01/10 | [
"https://Stackoverflow.com/questions/34708302",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4309943/"
] | You can use [`from_dict`](http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.from_dict.html):
```
import pandas as pd
lis = [{"url": "http://www.URL1.com", "date": "2001-01-01"},
{"url": "http://www.URL2.com", "date": "2001-01-02"}]
print pd.DataFrame.from_dict(lis)
date ... | While `from_dict` will work here, the prescribed way would be to use [`pd.read_json`](https://pandas.pydata.org/pandas-docs/stable/generated/pandas.read_json.html) with `orient='records'`. This parses an input that is
>
> list-like `[{column -> value}, ... , {column -> value}]`
>
>
>
Example: say this is the text... |
43,259,717 | I am trying to use a progress bar in a python script that I have since I have a for loop that takes quite a bit of time to process. I have looked at other explanations on here already but I am still confused. Here is what my for loop looks like in my script:
```
for member in members:
url = "http://api.wiki123.com... | 2017/04/06 | [
"https://Stackoverflow.com/questions/43259717",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7681184/"
] | To show the progress bar:
```
from tqdm import tqdm
for x in tqdm(my_list):
# do something with x
#### In case using with enumerate:
for i, x in enumerate( tqdm(my_list) ):
# do something with i and x
```
[](https://i.stack.imgur.com/H9sUC... | Or you can use this (can be used for any situation):
```
for i in tqdm (range (1), desc="Loading..."):
for member in members:
url = "http://api.wiki123.com/v1.11/member?id="+str(member)
header = {"Authorization": authorization_code}
api_response = requests.get(url, headers=header)
memb... |
43,259,717 | I am trying to use a progress bar in a python script that I have since I have a for loop that takes quite a bit of time to process. I have looked at other explanations on here already but I am still confused. Here is what my for loop looks like in my script:
```
for member in members:
url = "http://api.wiki123.com... | 2017/04/06 | [
"https://Stackoverflow.com/questions/43259717",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7681184/"
] | I think this could be most elegantly be solved in this manner:
```
import progressbar
bar = progressbar.ProgressBar(maxval=len(members)).start()
for idx, member in enumerate(members):
...
bar.update(idx)
``` | Or you can use this (can be used for any situation):
```
for i in tqdm (range (1), desc="Loading..."):
for member in members:
url = "http://api.wiki123.com/v1.11/member?id="+str(member)
header = {"Authorization": authorization_code}
api_response = requests.get(url, headers=header)
memb... |
43,259,717 | I am trying to use a progress bar in a python script that I have since I have a for loop that takes quite a bit of time to process. I have looked at other explanations on here already but I am still confused. Here is what my for loop looks like in my script:
```
for member in members:
url = "http://api.wiki123.com... | 2017/04/06 | [
"https://Stackoverflow.com/questions/43259717",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7681184/"
] | To show the progress bar:
```
from tqdm import tqdm
for x in tqdm(my_list):
# do something with x
#### In case using with enumerate:
for i, x in enumerate( tqdm(my_list) ):
# do something with i and x
```
[](https://i.stack.imgur.com/H9sUC... | The [rich module](https://pypi.org/project/rich/) has also a progress bar that can be included in your for loop:
```
import time # for demonstration only
from rich.progress import track
members = ['Liam', 'Olivia', 'Noah', 'Emma', 'Oliver', 'Charlotte'] # for demonstration only
for member in track(members):
# ... |
43,259,717 | I am trying to use a progress bar in a python script that I have since I have a for loop that takes quite a bit of time to process. I have looked at other explanations on here already but I am still confused. Here is what my for loop looks like in my script:
```
for member in members:
url = "http://api.wiki123.com... | 2017/04/06 | [
"https://Stackoverflow.com/questions/43259717",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7681184/"
] | The basic idea of a progress bar from a loop is to insert points within the loop to update the progress bar. An example would be something like this:
```
membersProcessed = 0
for member in members:
url = "http://api.wiki123.com/v1.11/member?id="+str(member)
header = {"Authorization": authorization_code}
a... | The [rich module](https://pypi.org/project/rich/) has also a progress bar that can be included in your for loop:
```
import time # for demonstration only
from rich.progress import track
members = ['Liam', 'Olivia', 'Noah', 'Emma', 'Oliver', 'Charlotte'] # for demonstration only
for member in track(members):
# ... |
43,259,717 | I am trying to use a progress bar in a python script that I have since I have a for loop that takes quite a bit of time to process. I have looked at other explanations on here already but I am still confused. Here is what my for loop looks like in my script:
```
for member in members:
url = "http://api.wiki123.com... | 2017/04/06 | [
"https://Stackoverflow.com/questions/43259717",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7681184/"
] | The [rich module](https://pypi.org/project/rich/) has also a progress bar that can be included in your for loop:
```
import time # for demonstration only
from rich.progress import track
members = ['Liam', 'Olivia', 'Noah', 'Emma', 'Oliver', 'Charlotte'] # for demonstration only
for member in track(members):
# ... | Or you can use this (can be used for any situation):
```
for i in tqdm (range (1), desc="Loading..."):
for member in members:
url = "http://api.wiki123.com/v1.11/member?id="+str(member)
header = {"Authorization": authorization_code}
api_response = requests.get(url, headers=header)
memb... |
43,259,717 | I am trying to use a progress bar in a python script that I have since I have a for loop that takes quite a bit of time to process. I have looked at other explanations on here already but I am still confused. Here is what my for loop looks like in my script:
```
for member in members:
url = "http://api.wiki123.com... | 2017/04/06 | [
"https://Stackoverflow.com/questions/43259717",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7681184/"
] | Using [tqdm](https://github.com/tqdm/):
```
from tqdm import tqdm
for member in tqdm(members):
# current contents of your for loop
```
`tqdm()` takes `members` and iterates over it, but each time it yields a new member (between each iteration of the loop), it also updates a progress bar on your command line. Th... | Or you can use this (can be used for any situation):
```
for i in tqdm (range (1), desc="Loading..."):
for member in members:
url = "http://api.wiki123.com/v1.11/member?id="+str(member)
header = {"Authorization": authorization_code}
api_response = requests.get(url, headers=header)
memb... |
43,259,717 | I am trying to use a progress bar in a python script that I have since I have a for loop that takes quite a bit of time to process. I have looked at other explanations on here already but I am still confused. Here is what my for loop looks like in my script:
```
for member in members:
url = "http://api.wiki123.com... | 2017/04/06 | [
"https://Stackoverflow.com/questions/43259717",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7681184/"
] | To show the progress bar:
```
from tqdm import tqdm
for x in tqdm(my_list):
# do something with x
#### In case using with enumerate:
for i, x in enumerate( tqdm(my_list) ):
# do something with i and x
```
[](https://i.stack.imgur.com/H9sUC... | The basic idea of a progress bar from a loop is to insert points within the loop to update the progress bar. An example would be something like this:
```
membersProcessed = 0
for member in members:
url = "http://api.wiki123.com/v1.11/member?id="+str(member)
header = {"Authorization": authorization_code}
a... |
43,259,717 | I am trying to use a progress bar in a python script that I have since I have a for loop that takes quite a bit of time to process. I have looked at other explanations on here already but I am still confused. Here is what my for loop looks like in my script:
```
for member in members:
url = "http://api.wiki123.com... | 2017/04/06 | [
"https://Stackoverflow.com/questions/43259717",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7681184/"
] | The basic idea of a progress bar from a loop is to insert points within the loop to update the progress bar. An example would be something like this:
```
membersProcessed = 0
for member in members:
url = "http://api.wiki123.com/v1.11/member?id="+str(member)
header = {"Authorization": authorization_code}
a... | Or you can use this (can be used for any situation):
```
for i in tqdm (range (1), desc="Loading..."):
for member in members:
url = "http://api.wiki123.com/v1.11/member?id="+str(member)
header = {"Authorization": authorization_code}
api_response = requests.get(url, headers=header)
memb... |
43,259,717 | I am trying to use a progress bar in a python script that I have since I have a for loop that takes quite a bit of time to process. I have looked at other explanations on here already but I am still confused. Here is what my for loop looks like in my script:
```
for member in members:
url = "http://api.wiki123.com... | 2017/04/06 | [
"https://Stackoverflow.com/questions/43259717",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7681184/"
] | I think this could be most elegantly be solved in this manner:
```
import progressbar
bar = progressbar.ProgressBar(maxval=len(members)).start()
for idx, member in enumerate(members):
...
bar.update(idx)
``` | The [rich module](https://pypi.org/project/rich/) has also a progress bar that can be included in your for loop:
```
import time # for demonstration only
from rich.progress import track
members = ['Liam', 'Olivia', 'Noah', 'Emma', 'Oliver', 'Charlotte'] # for demonstration only
for member in track(members):
# ... |
43,259,717 | I am trying to use a progress bar in a python script that I have since I have a for loop that takes quite a bit of time to process. I have looked at other explanations on here already but I am still confused. Here is what my for loop looks like in my script:
```
for member in members:
url = "http://api.wiki123.com... | 2017/04/06 | [
"https://Stackoverflow.com/questions/43259717",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7681184/"
] | To show the progress bar:
```
from tqdm import tqdm
for x in tqdm(my_list):
# do something with x
#### In case using with enumerate:
for i, x in enumerate( tqdm(my_list) ):
# do something with i and x
```
[](https://i.stack.imgur.com/H9sUC... | I think this could be most elegantly be solved in this manner:
```
import progressbar
bar = progressbar.ProgressBar(maxval=len(members)).start()
for idx, member in enumerate(members):
...
bar.update(idx)
``` |
72,216,546 | Used the standard python installation file (3.9.12) for windows.
The installation file have a built in option for pip installation:
[](https://i.stack.imgur.com/CEH51.png)
The resulting python is without pip.
Then I try to install pip directly by usin... | 2022/05/12 | [
"https://Stackoverflow.com/questions/72216546",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8812406/"
] | One should add `min-h-0` to `<main>`.. I swear I tried everything. | Add `overflow-y-scroll h-3/5` to the div containing the paragraphs.
Please find below the solution code and watch result in full screen.
```html
<script src="https://cdn.tailwindcss.com" ></script>
<div class="flex h-full flex-col">
<mark class="bg-red-900 p-2 font-semibold text-white"> Warning message </mark>
<m... |
55,436,896 | I have a table of IDs and dates of quarterly data and i would like to reindex this to daily (weekdays).
Example table:
[](https://i.stack.imgur.com/bLvFf.png)
I'm trying to figure out a pythonic or pandas way to reindex to a higher frequency date ra... | 2019/03/31 | [
"https://Stackoverflow.com/questions/55436896",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5615327/"
] | Yes you can do with `merge`
```
new_idx_frame=new_idx.to_frame()
new_idx_frame.columns=['date', 'id', 'type']
Yourdf=df.reset_index().merge(new_idx_frame,how='right',sort =True).groupby('id').ffill()# here I am using toy data
Out[408]:
id date type value
0 1 1 1 NaN
1 1 1 2 ... | Wen-Ben's answer is almost there - thank you for that. The only thing missing is grouping by ['id', 'type'] when doing the forward fill.
Further, when creating the new multindex in my use case should have unique values:
```
new_idx = pd.MultiIndex.from_product([dates, df.index.get_level_values(1).unique(), df.index.g... |
66,491,254 | I have created python desktop software. Now I want to market that as a product. But my problem is, anyone can decompile my exe file and they will get the actual code.
So is there any way to encrypt my code and convert it to exe before deployment. I have tried different ways.
But nothing is working. Is there any way to... | 2021/03/05 | [
"https://Stackoverflow.com/questions/66491254",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14155439/"
] | This [link](https://wiki.python.org/moin/Asking%20for%20Help/How%20do%20you%20protect%20Python%20source%20code%3F) has most of the info you need.
But since links are discouraged here:
There is py2exe, which compiles your code into an .exe file, but afaik it's not difficult to reverse-engineer the code from the exe fil... | You can install pyinstaller per `pip install pyinstaller` (make sure to also add it to your environment variables) and then open shell in the folder where your file is (shift+right-click somewhere where no file is and "open PowerShell here") and the do "pyinstaller --onefile YOUR\_FILE".
If there will be created a dis... |
4,331,348 | If I have a python module that has a bunch of functions, say like this:
```
#funcs.py
def foo() :
print "foo!"
def bar() :
print "bar!"
```
And I have another module that is designed to parse a list of functions from a string and run those functions:
```
#parser.py
from funcs import *
def execute(command)... | 2010/12/02 | [
"https://Stackoverflow.com/questions/4331348",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/67829/"
] | `import module_name` does something fundamentally different from what `from module_name import *` does.
The former creates a global named `module_name`, which is of type `module` and which contains the module's names, accessed as attributes. The latter creates a global for each of those names within `module_name`, but... | * Print the globals after you import parser to see what it did
* `parser` is it built-in module also. Usually the built-in parser should load not yours.
I would change the name so you do not have problems.
* Your importing funcs but parser imports \* from funcs?
I would think carefully about what order you are importi... |
4,331,348 | If I have a python module that has a bunch of functions, say like this:
```
#funcs.py
def foo() :
print "foo!"
def bar() :
print "bar!"
```
And I have another module that is designed to parse a list of functions from a string and run those functions:
```
#parser.py
from funcs import *
def execute(command)... | 2010/12/02 | [
"https://Stackoverflow.com/questions/4331348",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/67829/"
] | `import module_name` does something fundamentally different from what `from module_name import *` does.
The former creates a global named `module_name`, which is of type `module` and which contains the module's names, accessed as attributes. The latter creates a global for each of those names within `module_name`, but... | Your "parser" is a pretty bad idea.
Do this instead.
```
def execute(*functions):
for function in functions:
function()
```
Then you can open up python and do the following:
```
>>> import parser
>>> from funcs import foo, bar
>>> parser.execute(foo, bar, bar, foo)
```
Life will be simpler without u... |
73,066,303 | I have python 3.10, selenium 4.3.0 and i would like to click on the following element:
```
<a href="#" onclick="fireLoginOrRegisterModalRequest('sign_in');ga('send', 'event', 'main_navigation', 'login', '1st_level');"> Mein Konto </a>
```
Unfortunately,
`driver.find_element(By.CSS_SELECTOR,"a[onclick^='fireLoginOrRe... | 2022/07/21 | [
"https://Stackoverflow.com/questions/73066303",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19163184/"
] | It turns out that despite opening up to all IP-addresses, the networkpolicy does not allow egress to the DNS pod, which is in another namespace.
```
# Identifying DNS pod
kubectl get pods -A | grep dns
# Identifying DNS pod label
kubectl describe pods -n kube-system coredns-64cfd66f7-rzgwk
```
Next I add the dns la... | The reason is, `curl` attempts to form a 2-way TCP connection with the HTTP server at `www.google.com`. This means, *both* egress and ingress traffic need to be allowed on your policy. Currently, only out-bound traffic is allowed. Maybe, you'll be able to see this in more detail if you ran curl in verbose mode:
```
ku... |
61,243,561 | I wrote some classes which were a shopping cart, Customer, Order, and some functions for discounts for the orders. this is the final lines of my code.
```
anu = Customer('anu', 4500) # 1
user_cart = [Lineitem('apple', 7, 7), Lineitem('orange', 5, 6)] # 2
order1 = Order(anu, user_cart) # 2
print(type(joe)) # 4
prin... | 2020/04/16 | [
"https://Stackoverflow.com/questions/61243561",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12857878/"
] | You can do this by awaiting the listen even, wrapping it in a promise, and calling the promise resolve as the callback to the server listen
```js
const app = express();
let server;
await new Promise(resolve => server = app.listen(0, "127.0.0.1", resolve));
this.global.server = server;
```
You could also put ... | Extending [Robert Mennell](https://stackoverflow.com/users/5377773) answer:
>
> You could also put a custom callback that will just call the promise resolver as the third argument to the `app.listen()` and it should run that code then call resolve if you need some sort of diagnostics.
>
>
>
```js
let server;
cons... |
57,122,160 | I am setting up a django rest api and need to integrate social login feature.I followed the following link
[Simple Facebook social Login using Django Rest Framework.](https://medium.com/@katherinekimetto/simple-facebook-social-login-using-django-rest-framework-e2ac10266be1)
After setting up all , when a migrate (7 th ... | 2019/07/20 | [
"https://Stackoverflow.com/questions/57122160",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5113584/"
] | Firefox uses different flags. I am not sure exactly what your aim is but I am assuming you are trying to avoid some website detecting that you are using selenium.
There are different methods to avoid websites detecting the use of Selenium.
1) The value of navigator.webdriver is set to true by default when using Selen... | you may try:
```
from selenium.webdriver.firefox.firefox_profile import FirefoxProfile
from selenium.webdriver import DesiredCapabilities
from selenium.webdriver import Firefox
profile = FirefoxProfile()
profile.set_preference('devtools.jsonview.enabled', False)
profile.update_preferences()
desired = DesiredCapabilit... |
3,633,288 | I'll to explain this right:
I'm in an environment where I can't use python built-in functions (like 'sorted', 'set'), can't declare methods, can't make conditions (if), and can't make loops, except for:
* can call methods (but just one each time, and saving returns on another variable
foo python:item.sort(); #foo ... | 2010/09/03 | [
"https://Stackoverflow.com/questions/3633288",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/334872/"
] | It's hard to answer, not knowing exactly what's allowed and what's not. But how about this O(N^2) solution?
```
[x for x in correct_order if x in messed_order] + [x for x in messed_order if x not in correct_order]
``` | Does the exact order of the 55/66/44 items matter, or do they just need to be listed at the end? If the order doesn't matter you could do this:
```
[i for i in correct_order if i in messed_order] +
list(set(messed_order) - set(correct_order))
``` |
3,633,288 | I'll to explain this right:
I'm in an environment where I can't use python built-in functions (like 'sorted', 'set'), can't declare methods, can't make conditions (if), and can't make loops, except for:
* can call methods (but just one each time, and saving returns on another variable
foo python:item.sort(); #foo ... | 2010/09/03 | [
"https://Stackoverflow.com/questions/3633288",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/334872/"
] | It's hard to answer, not knowing exactly what's allowed and what's not. But how about this O(N^2) solution?
```
[x for x in correct_order if x in messed_order] + [x for x in messed_order if x not in correct_order]
``` | Here is one that **destroys `messed_order`**
```
[messed_order.remove(i) or i for i in correct_order if i in messed_order] + messed_order
```
This one sorts `messed_order` in place
```
messed_order.sort(key=(correct_order+messed_order).index)
``` |
3,633,288 | I'll to explain this right:
I'm in an environment where I can't use python built-in functions (like 'sorted', 'set'), can't declare methods, can't make conditions (if), and can't make loops, except for:
* can call methods (but just one each time, and saving returns on another variable
foo python:item.sort(); #foo ... | 2010/09/03 | [
"https://Stackoverflow.com/questions/3633288",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/334872/"
] | It's hard to answer, not knowing exactly what's allowed and what's not. But how about this O(N^2) solution?
```
[x for x in correct_order if x in messed_order] + [x for x in messed_order if x not in correct_order]
``` | Not to detract from the answers already given, but it's python - you *aren't* arbitrarily restricted from using loops:
```
for item in correct_order: messed_order[messed_order.index(item)], messed_order[correct_order.index(item)] = messed_order[correct_order.index(item)], messed_order[messed_order.index(item)]
```
i... |
3,633,288 | I'll to explain this right:
I'm in an environment where I can't use python built-in functions (like 'sorted', 'set'), can't declare methods, can't make conditions (if), and can't make loops, except for:
* can call methods (but just one each time, and saving returns on another variable
foo python:item.sort(); #foo ... | 2010/09/03 | [
"https://Stackoverflow.com/questions/3633288",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/334872/"
] | It's hard to answer, not knowing exactly what's allowed and what's not. But how about this O(N^2) solution?
```
[x for x in correct_order if x in messed_order] + [x for x in messed_order if x not in correct_order]
``` | Create a `Script (Python)` object in your skin and use that as a function. TALES expressions are limited for a reason: they are there only to help you create HTML or XML markup, not do full-scale business logic. Better still, create a proper browser view and avoid the severe restrictions laid on Through-The-Web editabl... |
3,633,288 | I'll to explain this right:
I'm in an environment where I can't use python built-in functions (like 'sorted', 'set'), can't declare methods, can't make conditions (if), and can't make loops, except for:
* can call methods (but just one each time, and saving returns on another variable
foo python:item.sort(); #foo ... | 2010/09/03 | [
"https://Stackoverflow.com/questions/3633288",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/334872/"
] | Create a `Script (Python)` object in your skin and use that as a function. TALES expressions are limited for a reason: they are there only to help you create HTML or XML markup, not do full-scale business logic. Better still, create a proper browser view and avoid the severe restrictions laid on Through-The-Web editabl... | Does the exact order of the 55/66/44 items matter, or do they just need to be listed at the end? If the order doesn't matter you could do this:
```
[i for i in correct_order if i in messed_order] +
list(set(messed_order) - set(correct_order))
``` |
3,633,288 | I'll to explain this right:
I'm in an environment where I can't use python built-in functions (like 'sorted', 'set'), can't declare methods, can't make conditions (if), and can't make loops, except for:
* can call methods (but just one each time, and saving returns on another variable
foo python:item.sort(); #foo ... | 2010/09/03 | [
"https://Stackoverflow.com/questions/3633288",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/334872/"
] | Create a `Script (Python)` object in your skin and use that as a function. TALES expressions are limited for a reason: they are there only to help you create HTML or XML markup, not do full-scale business logic. Better still, create a proper browser view and avoid the severe restrictions laid on Through-The-Web editabl... | Here is one that **destroys `messed_order`**
```
[messed_order.remove(i) or i for i in correct_order if i in messed_order] + messed_order
```
This one sorts `messed_order` in place
```
messed_order.sort(key=(correct_order+messed_order).index)
``` |
3,633,288 | I'll to explain this right:
I'm in an environment where I can't use python built-in functions (like 'sorted', 'set'), can't declare methods, can't make conditions (if), and can't make loops, except for:
* can call methods (but just one each time, and saving returns on another variable
foo python:item.sort(); #foo ... | 2010/09/03 | [
"https://Stackoverflow.com/questions/3633288",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/334872/"
] | Create a `Script (Python)` object in your skin and use that as a function. TALES expressions are limited for a reason: they are there only to help you create HTML or XML markup, not do full-scale business logic. Better still, create a proper browser view and avoid the severe restrictions laid on Through-The-Web editabl... | Not to detract from the answers already given, but it's python - you *aren't* arbitrarily restricted from using loops:
```
for item in correct_order: messed_order[messed_order.index(item)], messed_order[correct_order.index(item)] = messed_order[correct_order.index(item)], messed_order[messed_order.index(item)]
```
i... |
41,954,262 | I am running through a very large data set with a json object for each row. And after passing through almost 1 billion rows I am suddenly getting an error with my transaction.
I am using Python 3.x and psycopg2 to perform my transactions.
The json object I am trying to write is as follows:
```
{"message": "ConfigMan... | 2017/01/31 | [
"https://Stackoverflow.com/questions/41954262",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2302843/"
] | you're trying to write a `tuple` to your file.
While it would work for `print` since `print` knows how to print several arguments, `write` is more strict.
Just format your `var` properly.
```
var = "\n{}\n".format(test)
``` | I assume you want to concatinate the string, so use `+` instead of `,`
```
import pandas as pd
import os
#path = '/test'
#os.chdir(path)
def writeScores(test):
with open('output.txt', 'w') as f:
var = "\n" + test + "\n"
f.write(var)
writeScores("asd")
``` |
41,954,262 | I am running through a very large data set with a json object for each row. And after passing through almost 1 billion rows I am suddenly getting an error with my transaction.
I am using Python 3.x and psycopg2 to perform my transactions.
The json object I am trying to write is as follows:
```
{"message": "ConfigMan... | 2017/01/31 | [
"https://Stackoverflow.com/questions/41954262",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2302843/"
] | you're trying to write a `tuple` to your file.
While it would work for `print` since `print` knows how to print several arguments, `write` is more strict.
Just format your `var` properly.
```
var = "\n{}\n".format(test)
``` | Instead of string you have created a tuple here with comma separated values like
```
var = "\n" + test + "\n"
```
So you can't write that tuple directly on the file.so lets put values inside that tuple to a string as:
```
with open('output.txt', 'w') as fp:
var = "\n", test, "\n"
fp.write(''.join('%s' % x f... |
41,954,262 | I am running through a very large data set with a json object for each row. And after passing through almost 1 billion rows I am suddenly getting an error with my transaction.
I am using Python 3.x and psycopg2 to perform my transactions.
The json object I am trying to write is as follows:
```
{"message": "ConfigMan... | 2017/01/31 | [
"https://Stackoverflow.com/questions/41954262",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2302843/"
] | You have this error because your first argument is not string, you should pass it a string ,you can use this simple script and also you can change "rw" to "w+"
or use 'a+' for appending (not erasing existing content)
```
import os
writepath = 'some/path/to/file.txt'
mode = 'a' if os.path.exists(writepath) else 'w'
w... | I assume you want to concatinate the string, so use `+` instead of `,`
```
import pandas as pd
import os
#path = '/test'
#os.chdir(path)
def writeScores(test):
with open('output.txt', 'w') as f:
var = "\n" + test + "\n"
f.write(var)
writeScores("asd")
``` |
41,954,262 | I am running through a very large data set with a json object for each row. And after passing through almost 1 billion rows I am suddenly getting an error with my transaction.
I am using Python 3.x and psycopg2 to perform my transactions.
The json object I am trying to write is as follows:
```
{"message": "ConfigMan... | 2017/01/31 | [
"https://Stackoverflow.com/questions/41954262",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2302843/"
] | I assume you want to concatinate the string, so use `+` instead of `,`
```
import pandas as pd
import os
#path = '/test'
#os.chdir(path)
def writeScores(test):
with open('output.txt', 'w') as f:
var = "\n" + test + "\n"
f.write(var)
writeScores("asd")
``` | Instead of string you have created a tuple here with comma separated values like
```
var = "\n" + test + "\n"
```
So you can't write that tuple directly on the file.so lets put values inside that tuple to a string as:
```
with open('output.txt', 'w') as fp:
var = "\n", test, "\n"
fp.write(''.join('%s' % x f... |
41,954,262 | I am running through a very large data set with a json object for each row. And after passing through almost 1 billion rows I am suddenly getting an error with my transaction.
I am using Python 3.x and psycopg2 to perform my transactions.
The json object I am trying to write is as follows:
```
{"message": "ConfigMan... | 2017/01/31 | [
"https://Stackoverflow.com/questions/41954262",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2302843/"
] | You have this error because your first argument is not string, you should pass it a string ,you can use this simple script and also you can change "rw" to "w+"
or use 'a+' for appending (not erasing existing content)
```
import os
writepath = 'some/path/to/file.txt'
mode = 'a' if os.path.exists(writepath) else 'w'
w... | Instead of string you have created a tuple here with comma separated values like
```
var = "\n" + test + "\n"
```
So you can't write that tuple directly on the file.so lets put values inside that tuple to a string as:
```
with open('output.txt', 'w') as fp:
var = "\n", test, "\n"
fp.write(''.join('%s' % x f... |
38,589,830 | I have following:
1. ```
python manage.py crontab show # this command give following
Currently active jobs in crontab:
12151a7f59f3f0be816fa30b31e7cc4d -> ('*/1 * * * *', 'media_api_server.cron.cronSendEmail')
```
2. My app is in virtual environment (env) active
3. In my media\_api\_server/cron.py I have follo... | 2016/07/26 | [
"https://Stackoverflow.com/questions/38589830",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5287027/"
] | Your code actually works. You may be think that `print("Hello")` should appear in stdout? So it doesn't work that way, because cron doesn't use `stdour` and `stderr` for it's output. To see actual results you should point path to some log file in `CRONJOBS` list: just put `'>> /path/to/log/file.log'` as last argument, ... | Try to change the crontab with a first line like:
```
SHELL=/bin/bash
```
Create the new line at crontab with:
```
./manage.py crontab add
```
And change the line created by crontab library with the command:
>
> crontab -e
>
>
>
```
*/1 * * * * source /home/app/env/bin/activate && /home/app/manage.py cronta... |
38,589,830 | I have following:
1. ```
python manage.py crontab show # this command give following
Currently active jobs in crontab:
12151a7f59f3f0be816fa30b31e7cc4d -> ('*/1 * * * *', 'media_api_server.cron.cronSendEmail')
```
2. My app is in virtual environment (env) active
3. In my media\_api\_server/cron.py I have follo... | 2016/07/26 | [
"https://Stackoverflow.com/questions/38589830",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5287027/"
] | Your code actually works. You may be think that `print("Hello")` should appear in stdout? So it doesn't work that way, because cron doesn't use `stdour` and `stderr` for it's output. To see actual results you should point path to some log file in `CRONJOBS` list: just put `'>> /path/to/log/file.log'` as last argument, ... | `source` sometimes not working in shell scripts
use `.` (dot) instead
```
*/1 * * * * . /home/app/env/bin/activate e.t.c.
``` |
38,589,830 | I have following:
1. ```
python manage.py crontab show # this command give following
Currently active jobs in crontab:
12151a7f59f3f0be816fa30b31e7cc4d -> ('*/1 * * * *', 'media_api_server.cron.cronSendEmail')
```
2. My app is in virtual environment (env) active
3. In my media\_api\_server/cron.py I have follo... | 2016/07/26 | [
"https://Stackoverflow.com/questions/38589830",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5287027/"
] | Your code actually works. You may be think that `print("Hello")` should appear in stdout? So it doesn't work that way, because cron doesn't use `stdour` and `stderr` for it's output. To see actual results you should point path to some log file in `CRONJOBS` list: just put `'>> /path/to/log/file.log'` as last argument, ... | An alternative way, directly in the OS( in case you are running on a Unix system), so that you won't have to fiddle with python libraries. Provided your OS user has all permissions/owns the django project, you can do it on the command line and in the directory where your project folder is;
```
user@server:~$ crontab -... |
38,589,830 | I have following:
1. ```
python manage.py crontab show # this command give following
Currently active jobs in crontab:
12151a7f59f3f0be816fa30b31e7cc4d -> ('*/1 * * * *', 'media_api_server.cron.cronSendEmail')
```
2. My app is in virtual environment (env) active
3. In my media\_api\_server/cron.py I have follo... | 2016/07/26 | [
"https://Stackoverflow.com/questions/38589830",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5287027/"
] | `source` sometimes not working in shell scripts
use `.` (dot) instead
```
*/1 * * * * . /home/app/env/bin/activate e.t.c.
``` | Try to change the crontab with a first line like:
```
SHELL=/bin/bash
```
Create the new line at crontab with:
```
./manage.py crontab add
```
And change the line created by crontab library with the command:
>
> crontab -e
>
>
>
```
*/1 * * * * source /home/app/env/bin/activate && /home/app/manage.py cronta... |
38,589,830 | I have following:
1. ```
python manage.py crontab show # this command give following
Currently active jobs in crontab:
12151a7f59f3f0be816fa30b31e7cc4d -> ('*/1 * * * *', 'media_api_server.cron.cronSendEmail')
```
2. My app is in virtual environment (env) active
3. In my media\_api\_server/cron.py I have follo... | 2016/07/26 | [
"https://Stackoverflow.com/questions/38589830",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5287027/"
] | `source` sometimes not working in shell scripts
use `.` (dot) instead
```
*/1 * * * * . /home/app/env/bin/activate e.t.c.
``` | An alternative way, directly in the OS( in case you are running on a Unix system), so that you won't have to fiddle with python libraries. Provided your OS user has all permissions/owns the django project, you can do it on the command line and in the directory where your project folder is;
```
user@server:~$ crontab -... |
55,476,131 | I'm trying to implement fastai pretrain language model and it requires torch to work. After run the code, I got some problem about the import torch.\_C
I run it on my linux, python 3.7.1, via pip: torch 1.0.1.post2, cuda V7.5.17. I'm getting this error:
```
Traceback (most recent call last):
File "pretrain_lm.py",... | 2019/04/02 | [
"https://Stackoverflow.com/questions/55476131",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6332850/"
] | My problem is solved. I'm uninstalling my torch twice
```
pip uninstall torch
pip uninstall torch
```
and then re-installing it back:
```
pip install torch==1.0.1.post2
``` | Try to use `pytorch` 1.4.0. For which, upgrade the `pytorch` library using the following command,
```
pip install -U torch==1.5
```
If you are working on Colab then use the following command,
```
!pip install -U torch==1.5
```
Still facing challenges on the library then install `detectron2` library also.
```
!pi... |
55,476,131 | I'm trying to implement fastai pretrain language model and it requires torch to work. After run the code, I got some problem about the import torch.\_C
I run it on my linux, python 3.7.1, via pip: torch 1.0.1.post2, cuda V7.5.17. I'm getting this error:
```
Traceback (most recent call last):
File "pretrain_lm.py",... | 2019/04/02 | [
"https://Stackoverflow.com/questions/55476131",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6332850/"
] | My problem is solved. I'm uninstalling my torch twice
```
pip uninstall torch
pip uninstall torch
```
and then re-installing it back:
```
pip install torch==1.0.1.post2
``` | I run into this error when I accidentally overwrite `pytorch` with a different channel. My original `pytorch` installation is from `pytorch` channel and in a later update it was overwritten with the one from `conda-forge`. I got this error even if the version is the same. After reinstalling `pytorch` from `pytorch` cha... |
60,693,395 | I created a small app in Django and runserver and admin works fine.
I wrote some tests which can call with `python manage.py test` and the tests pass.
Now I would like to call one particular test via PyCharm.
This fails like this:
```
/home/guettli/x/venv/bin/python
/snap/pycharm-community/179/plugins/python-ce... | 2020/03/15 | [
"https://Stackoverflow.com/questions/60693395",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/633961/"
] | You can add DJANGO\_SETTINGS\_MODULE as an environmental variable:
In the menu: Run -> Edit Configurations -> Templates -> Python Tests -> Unittests
[](https://i.stack.imgur.com/XKKTG.png)
And delete old "Unittests for tests...." entries. | You can specify the settings in your test command
Assuming your in the xyz directory, and the structure is
```
/xyz
- manage.py
- xyz/
- settings.py
```
The following command should work
```
python manage.py test --settings=xyz.settings
``` |
60,693,395 | I created a small app in Django and runserver and admin works fine.
I wrote some tests which can call with `python manage.py test` and the tests pass.
Now I would like to call one particular test via PyCharm.
This fails like this:
```
/home/guettli/x/venv/bin/python
/snap/pycharm-community/179/plugins/python-ce... | 2020/03/15 | [
"https://Stackoverflow.com/questions/60693395",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/633961/"
] | You can add DJANGO\_SETTINGS\_MODULE as an environmental variable:
In the menu: Run -> Edit Configurations -> Templates -> Python Tests -> Unittests
[](https://i.stack.imgur.com/XKKTG.png)
And delete old "Unittests for tests...." entries. | Edited: For this method to work django support should me enabled in pycharm. I guess it should be possible to setup the equivalent template in the community edition version of pycharm.
**Method with django support enabled:**
I find that the most convenient way that also allow you to directly click on a particular te... |
60,693,395 | I created a small app in Django and runserver and admin works fine.
I wrote some tests which can call with `python manage.py test` and the tests pass.
Now I would like to call one particular test via PyCharm.
This fails like this:
```
/home/guettli/x/venv/bin/python
/snap/pycharm-community/179/plugins/python-ce... | 2020/03/15 | [
"https://Stackoverflow.com/questions/60693395",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/633961/"
] | You can add DJANGO\_SETTINGS\_MODULE as an environmental variable:
In the menu: Run -> Edit Configurations -> Templates -> Python Tests -> Unittests
[](https://i.stack.imgur.com/XKKTG.png)
And delete old "Unittests for tests...." entries. | If you use django and pytest, then I recommend the plugin [pytest-django](https://pytest-django.readthedocs.io/en/latest/)
It provides a simple way to set DJANGO\_SETTINGS\_MODULE via configuration.
See [configuring django](https://pytest-django.readthedocs.io/en/latest/configuring_django.html#pytest-ini-settings)
`... |
60,693,395 | I created a small app in Django and runserver and admin works fine.
I wrote some tests which can call with `python manage.py test` and the tests pass.
Now I would like to call one particular test via PyCharm.
This fails like this:
```
/home/guettli/x/venv/bin/python
/snap/pycharm-community/179/plugins/python-ce... | 2020/03/15 | [
"https://Stackoverflow.com/questions/60693395",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/633961/"
] | You can specify the settings in your test command
Assuming your in the xyz directory, and the structure is
```
/xyz
- manage.py
- xyz/
- settings.py
```
The following command should work
```
python manage.py test --settings=xyz.settings
``` | Edited: For this method to work django support should me enabled in pycharm. I guess it should be possible to setup the equivalent template in the community edition version of pycharm.
**Method with django support enabled:**
I find that the most convenient way that also allow you to directly click on a particular te... |
60,693,395 | I created a small app in Django and runserver and admin works fine.
I wrote some tests which can call with `python manage.py test` and the tests pass.
Now I would like to call one particular test via PyCharm.
This fails like this:
```
/home/guettli/x/venv/bin/python
/snap/pycharm-community/179/plugins/python-ce... | 2020/03/15 | [
"https://Stackoverflow.com/questions/60693395",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/633961/"
] | You can specify the settings in your test command
Assuming your in the xyz directory, and the structure is
```
/xyz
- manage.py
- xyz/
- settings.py
```
The following command should work
```
python manage.py test --settings=xyz.settings
``` | If you use django and pytest, then I recommend the plugin [pytest-django](https://pytest-django.readthedocs.io/en/latest/)
It provides a simple way to set DJANGO\_SETTINGS\_MODULE via configuration.
See [configuring django](https://pytest-django.readthedocs.io/en/latest/configuring_django.html#pytest-ini-settings)
`... |
60,693,395 | I created a small app in Django and runserver and admin works fine.
I wrote some tests which can call with `python manage.py test` and the tests pass.
Now I would like to call one particular test via PyCharm.
This fails like this:
```
/home/guettli/x/venv/bin/python
/snap/pycharm-community/179/plugins/python-ce... | 2020/03/15 | [
"https://Stackoverflow.com/questions/60693395",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/633961/"
] | Edited: For this method to work django support should me enabled in pycharm. I guess it should be possible to setup the equivalent template in the community edition version of pycharm.
**Method with django support enabled:**
I find that the most convenient way that also allow you to directly click on a particular te... | If you use django and pytest, then I recommend the plugin [pytest-django](https://pytest-django.readthedocs.io/en/latest/)
It provides a simple way to set DJANGO\_SETTINGS\_MODULE via configuration.
See [configuring django](https://pytest-django.readthedocs.io/en/latest/configuring_django.html#pytest-ini-settings)
`... |
34,116,682 | I am trying to save an image with python that is Base64 encoded. Here the string is to large to post but here is the image
[](https://i.stack.imgur.com/JYHLV.jpg)
And when received by python the last 2 characters are `==` although the string is not f... | 2015/12/06 | [
"https://Stackoverflow.com/questions/34116682",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3630528/"
] | There is no need to add `data:image/png;base64,` before, I tried using the code below, it works fine.
```
import base64
data = 'iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAADBQTFRFA6b1q Ci5/f2lt/9yu3 Y8v2cMpb1/DSJbz5i9R2NLwfLrWbw m T8I8////////SvMAbAAAABB0Uk5T//////... | If you append **data:image/png;base64,** to data, then you get error. If You have this, you must replace it.
```
new_data = initial_data.replace('data:image/png;base64,', '')
``` |
56,838,851 | I am getting an error when execute robot scripts through CMD (windows)
>
> 'robot' is not recognized as an internal or external command, operable
> program or batch file"
>
>
>
My team installed Python in C:\Python27 folder and I installed ROBOT framework and all required libraries with the following command
`... | 2019/07/01 | [
"https://Stackoverflow.com/questions/56838851",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9717530/"
] | I've installed robotframework using this command "sudo pip3 install robotframework" in jenkins server. and now my jenkins pipeline script can now run my robot scripts | I'm not very comfort with Windows environment, so let me give my two cents:
1) Try to set the PATH or PYTHONPATH to the location where your robot file is
2) Try to run robot from python script. I saw that you tried it above, but take a look at the RF User Guide and see if you are doing something wrong:
<https://robo... |
56,838,851 | I am getting an error when execute robot scripts through CMD (windows)
>
> 'robot' is not recognized as an internal or external command, operable
> program or batch file"
>
>
>
My team installed Python in C:\Python27 folder and I installed ROBOT framework and all required libraries with the following command
`... | 2019/07/01 | [
"https://Stackoverflow.com/questions/56838851",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9717530/"
] | Thanks a lot, it works for me. Just write the following in the terminal:
```sh
python -m robot "your file name"
```
In this case the file name is `TC1.robot`, so the command would be:
```sh
python -m robot TC1.robot
``` | I'm not very comfort with Windows environment, so let me give my two cents:
1) Try to set the PATH or PYTHONPATH to the location where your robot file is
2) Try to run robot from python script. I saw that you tried it above, but take a look at the RF User Guide and see if you are doing something wrong:
<https://robo... |
56,838,851 | I am getting an error when execute robot scripts through CMD (windows)
>
> 'robot' is not recognized as an internal or external command, operable
> program or batch file"
>
>
>
My team installed Python in C:\Python27 folder and I installed ROBOT framework and all required libraries with the following command
`... | 2019/07/01 | [
"https://Stackoverflow.com/questions/56838851",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9717530/"
] | I was getting an error when executing robot scripts through linux command of
```
sudo pip install robotframework
```
and the below command worked for me:
```
sudo pip3 install robotframework
``` | I'm not very comfort with Windows environment, so let me give my two cents:
1) Try to set the PATH or PYTHONPATH to the location where your robot file is
2) Try to run robot from python script. I saw that you tried it above, but take a look at the RF User Guide and see if you are doing something wrong:
<https://robo... |
56,838,851 | I am getting an error when execute robot scripts through CMD (windows)
>
> 'robot' is not recognized as an internal or external command, operable
> program or batch file"
>
>
>
My team installed Python in C:\Python27 folder and I installed ROBOT framework and all required libraries with the following command
`... | 2019/07/01 | [
"https://Stackoverflow.com/questions/56838851",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9717530/"
] | I've installed robotframework using this command "sudo pip3 install robotframework" in jenkins server. and now my jenkins pipeline script can now run my robot scripts | Thanks, It worked , first I cd to the Site packeges where Robot is installed and ran with Python -m command cd Users\babo\AppData\Roaming\Python\Python27\site-packages\robot>C:\Python27\python.exe -m robot.run -d Results C:\Users\bab\Robot\_Sframe\E2EAutomation\Test\_Suite\Enrollment\_834.robo
We can close this |
56,838,851 | I am getting an error when execute robot scripts through CMD (windows)
>
> 'robot' is not recognized as an internal or external command, operable
> program or batch file"
>
>
>
My team installed Python in C:\Python27 folder and I installed ROBOT framework and all required libraries with the following command
`... | 2019/07/01 | [
"https://Stackoverflow.com/questions/56838851",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9717530/"
] | Thanks a lot, it works for me. Just write the following in the terminal:
```sh
python -m robot "your file name"
```
In this case the file name is `TC1.robot`, so the command would be:
```sh
python -m robot TC1.robot
``` | Thanks, It worked , first I cd to the Site packeges where Robot is installed and ran with Python -m command cd Users\babo\AppData\Roaming\Python\Python27\site-packages\robot>C:\Python27\python.exe -m robot.run -d Results C:\Users\bab\Robot\_Sframe\E2EAutomation\Test\_Suite\Enrollment\_834.robo
We can close this |
56,838,851 | I am getting an error when execute robot scripts through CMD (windows)
>
> 'robot' is not recognized as an internal or external command, operable
> program or batch file"
>
>
>
My team installed Python in C:\Python27 folder and I installed ROBOT framework and all required libraries with the following command
`... | 2019/07/01 | [
"https://Stackoverflow.com/questions/56838851",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9717530/"
] | I was getting an error when executing robot scripts through linux command of
```
sudo pip install robotframework
```
and the below command worked for me:
```
sudo pip3 install robotframework
``` | Thanks, It worked , first I cd to the Site packeges where Robot is installed and ran with Python -m command cd Users\babo\AppData\Roaming\Python\Python27\site-packages\robot>C:\Python27\python.exe -m robot.run -d Results C:\Users\bab\Robot\_Sframe\E2EAutomation\Test\_Suite\Enrollment\_834.robo
We can close this |
56,838,851 | I am getting an error when execute robot scripts through CMD (windows)
>
> 'robot' is not recognized as an internal or external command, operable
> program or batch file"
>
>
>
My team installed Python in C:\Python27 folder and I installed ROBOT framework and all required libraries with the following command
`... | 2019/07/01 | [
"https://Stackoverflow.com/questions/56838851",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9717530/"
] | Thanks a lot, it works for me. Just write the following in the terminal:
```sh
python -m robot "your file name"
```
In this case the file name is `TC1.robot`, so the command would be:
```sh
python -m robot TC1.robot
``` | I've installed robotframework using this command "sudo pip3 install robotframework" in jenkins server. and now my jenkins pipeline script can now run my robot scripts |
56,838,851 | I am getting an error when execute robot scripts through CMD (windows)
>
> 'robot' is not recognized as an internal or external command, operable
> program or batch file"
>
>
>
My team installed Python in C:\Python27 folder and I installed ROBOT framework and all required libraries with the following command
`... | 2019/07/01 | [
"https://Stackoverflow.com/questions/56838851",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9717530/"
] | I was getting an error when executing robot scripts through linux command of
```
sudo pip install robotframework
```
and the below command worked for me:
```
sudo pip3 install robotframework
``` | I've installed robotframework using this command "sudo pip3 install robotframework" in jenkins server. and now my jenkins pipeline script can now run my robot scripts |
56,838,851 | I am getting an error when execute robot scripts through CMD (windows)
>
> 'robot' is not recognized as an internal or external command, operable
> program or batch file"
>
>
>
My team installed Python in C:\Python27 folder and I installed ROBOT framework and all required libraries with the following command
`... | 2019/07/01 | [
"https://Stackoverflow.com/questions/56838851",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9717530/"
] | Thanks a lot, it works for me. Just write the following in the terminal:
```sh
python -m robot "your file name"
```
In this case the file name is `TC1.robot`, so the command would be:
```sh
python -m robot TC1.robot
``` | I was getting an error when executing robot scripts through linux command of
```
sudo pip install robotframework
```
and the below command worked for me:
```
sudo pip3 install robotframework
``` |
56,646,940 | I load a saved h5 model and want to save the model as pb.
The model is saved during training with the `tf.keras.callbacks.ModelCheckpoint` callback function.
TF version: 2.0.0a
**edit**: same issue also with 2.0.0-beta1
My steps to save a pb:
1. I first set `K.set_learning_phase(0)`
2. then I load the model wit... | 2019/06/18 | [
"https://Stackoverflow.com/questions/56646940",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6510273/"
] | I do save the model to `pb` from `h5` model:
```py
import logging
import tensorflow as tf
from tensorflow.compat.v1 import graph_util
from tensorflow.python.keras import backend as K
from tensorflow import keras
# necessary !!!
tf.compat.v1.disable_eager_execution()
h5_path = '/path/to/model.h5'
model = keras.models... | I'm wondering the same thing, as I'm trying to use get\_session() and set\_session() to free up GPU memory. These functions seem to be missing and [aren't in the TF2.0 Keras documentation](http://faroit.com/keras-docs/2.0.0/backend/). I imagine it has something to do with Tensorflow's switch to eager execution, as dire... |
56,646,940 | I load a saved h5 model and want to save the model as pb.
The model is saved during training with the `tf.keras.callbacks.ModelCheckpoint` callback function.
TF version: 2.0.0a
**edit**: same issue also with 2.0.0-beta1
My steps to save a pb:
1. I first set `K.set_learning_phase(0)`
2. then I load the model wit... | 2019/06/18 | [
"https://Stackoverflow.com/questions/56646940",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6510273/"
] | I do save the model to `pb` from `h5` model:
```py
import logging
import tensorflow as tf
from tensorflow.compat.v1 import graph_util
from tensorflow.python.keras import backend as K
from tensorflow import keras
# necessary !!!
tf.compat.v1.disable_eager_execution()
h5_path = '/path/to/model.h5'
model = keras.models... | use
```
from tensorflow.compat.v1.keras.backend import get_session
```
in keras 2 & tensorflow 2.2
then call
```
import logging
import tensorflow as tf
from tensorflow.compat.v1 import graph_util
from tensorflow.python.keras import backend as K
from tensorflow import keras
from tensorflow.compat.v1.keras.backend i... |
62,655,911 | I'm looking at using Pandas UDF's in PySpark (v3). For a number of reasons, I understand iterating and UDF's in general are bad and I understand that the simple examples I show here can be done PySpark using SQL functions - all of that is besides the point!
I've been following this guide: <https://databricks.com/blog/... | 2020/06/30 | [
"https://Stackoverflow.com/questions/62655911",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1802510/"
] | I figured this out. So simple after you write it down and publish the problem to the world.
All that needs to happen is to return an array and then convert to a Pandas Series:
```
@pandas_udf('long')
def test4(x: pd.Series, y: pd.Series) -> pd.Series:
return pd.Series([a if a > b else b for a, b in zip(x, y)])
d... | I've spent the last two days looking for this answer, thank you simon\_dmorias!
I needed a slightly modified example here. I'm breaking out the single pandas\_udf into multiple components for easier management. Here is an example of what I'm using for others to reference:
```
xdf = pd.DataFrame(([1, 2, 3,'Fixed'], [4... |
62,374,607 | I have a list 2,3,4,3,5,9,4,5,6
I want to iterate over the list until I get the first highest number that is followed by a lower number. Then to iterate over the rest of the number until I get the lowest number followed by a higher number. Then the next highest highest number that is followed by a lower number.And so o... | 2020/06/14 | [
"https://Stackoverflow.com/questions/62374607",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13744765/"
] | you need to add the new user ONLY after you have checked all of them. instead you have it in the middle of your for loop, so it's going to add it over and over.
try this:
```
var doesExistFlag = false;
for (let i = 0; i < this.users.length; i++) {
if (this.users[i].user == this.adminId) {
doesExistFlag = true... | `id` is the name of the field ...which is never being compared to.
`adminId` probably should be `userId`, for the sake of readability.
While frankly speaking, just sort it on the server-side already. |
62,374,607 | I have a list 2,3,4,3,5,9,4,5,6
I want to iterate over the list until I get the first highest number that is followed by a lower number. Then to iterate over the rest of the number until I get the lowest number followed by a higher number. Then the next highest highest number that is followed by a lower number.And so o... | 2020/06/14 | [
"https://Stackoverflow.com/questions/62374607",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13744765/"
] | You could use array `some()` in the following way
```js
var input = [
{ id: 1, user: 32, permissions: 'sample', confirmed: false },
{ id: 2, user: 41, permissions: 'sample', confirmed: false },
{ id: 3, user: 12, permissions: 'sample', confirmed: false },
{ id: 4, user: 5, permissions: 'sample', confirmed:... | you need to add the new user ONLY after you have checked all of them. instead you have it in the middle of your for loop, so it's going to add it over and over.
try this:
```
var doesExistFlag = false;
for (let i = 0; i < this.users.length; i++) {
if (this.users[i].user == this.adminId) {
doesExistFlag = true... |
62,374,607 | I have a list 2,3,4,3,5,9,4,5,6
I want to iterate over the list until I get the first highest number that is followed by a lower number. Then to iterate over the rest of the number until I get the lowest number followed by a higher number. Then the next highest highest number that is followed by a lower number.And so o... | 2020/06/14 | [
"https://Stackoverflow.com/questions/62374607",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13744765/"
] | You could use array `some()` in the following way
```js
var input = [
{ id: 1, user: 32, permissions: 'sample', confirmed: false },
{ id: 2, user: 41, permissions: 'sample', confirmed: false },
{ id: 3, user: 12, permissions: 'sample', confirmed: false },
{ id: 4, user: 5, permissions: 'sample', confirmed:... | `id` is the name of the field ...which is never being compared to.
`adminId` probably should be `userId`, for the sake of readability.
While frankly speaking, just sort it on the server-side already. |
58,031,373 | I have a queue of 500 processes that I want to run through a python script, I want to run every N processes in parallel.
What my python script does so far:
It runs N processes in parallel, waits for all of them to terminate, then runs the next N files.
What I need to do:
When one of the N processes is finished, anoth... | 2019/09/20 | [
"https://Stackoverflow.com/questions/58031373",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11597586/"
] | Advanced PDF Template is not yet supported in SuiteBundle. | Update:
I noticed that when I create a new advanced template by customizing a standard one, I can see the new template in the bundle creation process.
If I start from a "saved search", I don't...
It is weird, ins't it? |
60,740,554 | I try to implement Apache Airflow with the CeleryExecutor. For the database I use Postgres, for the celery message queue I use Redis. When using LocalExecutor everything works fine, but when I set the CeleryExecutor in the airflow.cfg and want to set the Postgres database as the result\_backend
```
result_backend = po... | 2020/03/18 | [
"https://Stackoverflow.com/questions/60740554",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4296244/"
] | You need to add the `db+` prefix to the database connection string:
```py
f"db+postgresql+psycopg2://{user}:{password}@{host}/{database}"
```
This is also mentioned in the docs: <https://docs.celeryproject.org/en/stable/userguide/configuration.html#database-url-examples> | You need to add the `db+` prefix to the database connection string:
```
result_backend = db+postgresql://airflow_user:*******@localhost/airflow
``` |
5,556,360 | I'm having a problem getting matplotlib to work in ubuntu 10.10.
First I install the matplotlib using apt-get, and later I found that the version is 0.99 and some examples on the official site just won't work. Then I download the 1.01 version and install it without uninstalling the 0.99 version. To make the situation ... | 2011/04/05 | [
"https://Stackoverflow.com/questions/5556360",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/693500/"
] | Ben Gamari has [packaged](https://launchpad.net/~bgamari/+archive/matplotlib-unofficial) matplotlib 1.0 for Ubuntu. | Try installing it with `pip`:
```
sudo apt-get install python-pip
sudo pip install matplotlib
```
I just tested this and it should install matplotlib 1.0.1. |
5,556,360 | I'm having a problem getting matplotlib to work in ubuntu 10.10.
First I install the matplotlib using apt-get, and later I found that the version is 0.99 and some examples on the official site just won't work. Then I download the 1.01 version and install it without uninstalling the 0.99 version. To make the situation ... | 2011/04/05 | [
"https://Stackoverflow.com/questions/5556360",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/693500/"
] | Ben Gamari has [packaged](https://launchpad.net/~bgamari/+archive/matplotlib-unofficial) matplotlib 1.0 for Ubuntu. | I was having the same issue on Ubuntu 12.04. I solved it installing **python-gtk2-dev** and re-installing **matplotlib**:
```
sudo apt-get install python-gtk2-dev
sudo pip install --upgrade matplotlib
```
The message about dependencies changed to:
```
Gtk+: gtk+: 2.24.10, glib: 2.32.3, pygtk: 2.24.0,
pyg... |
45,803,713 | Presently we have a big-data cluster built using Cloudera-Virtual machines. By default the Python version on the VM is 2.7.
For one of my programs I need Python 3.6. My team is very skeptical about 2 installations and afraid of breaking existing cluster/VM. I was planning to follow this article and install 2 versions ... | 2017/08/21 | [
"https://Stackoverflow.com/questions/45803713",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/864598/"
] | It seems that [`miniconda`](https://conda.io/miniconda.html) is what you need.
using it you can manage multiple python environments with different versions of python.
**to install miniconda3 just run:**
-----------------------------------
```
# this will download & install miniconda3 on your home dir
wget https://rep... | ShmulikA's suggestion is pretty good.
Here I'd like to add another one - I use Python 2.7.x, but for few prototypes, I had to go with Python 3.x. For this I used the **`pyenv`** utility.
Once installed, all you have to do is:
```
pyenv install 3.x.x
```
Can list all the available Python variants:
```
pyenv versio... |
66,588,659 | I have a variable that saves the user's input. If the user inputs a list, e.g `["oranges","apples","pears"]` python seems to take this as a string, and print every character, instead of every word, that the code would print if fruit was simply a list. How do I the code to do this? Here is what I've tried...
```
fruit ... | 2021/03/11 | [
"https://Stackoverflow.com/questions/66588659",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | python takes inputs as one huge string so instead of that being a list it is just a string like that looks like this
```py
'["oranges","apples","pears"]'
```
turning this into a list will just look like
```py
['[', '"', 'o', 'r', 'a', 'n', 'g', 'e', 's', '"', ',', '"', 'a', 'p', 'p', 'l', 'e', 's', '"', ',', '"', '... | You will have to split word is list by comma.
```
fruit = list(fruit.split(","))
fruit = input("What is you favourite fruit?")
fruit = fruit.split(",")
for i in fruit:
print(i)
``` |
62,616,736 | I've been using the Fermipy conda environment on Python 2.7.14 64-bit on macOS Catalina 10.15.5 and overnight received the error "r.start is not a function" when trying to connect to the Jyputer server through Vscode (if I try on Jupyter Notebook/Lab the server instantly dies). I had a bunch of clutter on my system so ... | 2020/06/27 | [
"https://Stackoverflow.com/questions/62616736",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13820618/"
] | As answered here, <https://github.com/microsoft/vscode-python/issues/12355#issuecomment-652515770>
VSCode changed how it launches jupyter kernels, and the new method is incompatible with python 2.7.
Add this line to your VSCode settings.json file and restart.
```
"python.experiments.optOutFrom": ["LocalZMQKernel - e... | I got the same message. (r.start is not a function.) I had an old uninstalled version of anaconda on the computer which had left behind a folder containing its python version. Jupyter was supposed to be running from new venv after setting both python and jupyter path in vscode. I fully deleted remaining files from old ... |
72,285,267 | I have a below dictionary defined with IP address of the application for the respective region. Region is user input variable, based on the input i need to procees the IP in rest of my script.
```
app_list=["puppet","dns","ntp"]
dns={'apac':["172.118.162.93","172.118.144.93"],'euro':["172.118.76.93","172.118.204.93",... | 2022/05/18 | [
"https://Stackoverflow.com/questions/72285267",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3619226/"
] | ```
# use a nested dict comprehension
# use enumerate for the index of the list items and add it to the key using f-string
{key: {f"{k}.{i}": e for k, v in val.items() for i, e in enumerate(v)} for key, val in my_dict.items()}
{'Ka': {'Ka.0': '0.80', 'Ka.1': '0.1',
'Ba.0': '0.50', 'Ba.1': '1.1',
'FC.0':... | ```
from collections import defaultdict
new = defaultdict(dict)
for k, values in d.items():
for sub_key, values in values.items():
for value in values:
existing_key_count = sum(1 for existing_key in new[k].keys() if existing_key.startswith(sub_key))
new_key = f"{sub_key}.{existing_ke... |
72,285,267 | I have a below dictionary defined with IP address of the application for the respective region. Region is user input variable, based on the input i need to procees the IP in rest of my script.
```
app_list=["puppet","dns","ntp"]
dns={'apac':["172.118.162.93","172.118.144.93"],'euro':["172.118.76.93","172.118.204.93",... | 2022/05/18 | [
"https://Stackoverflow.com/questions/72285267",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3619226/"
] | ```
sample_dict = {'Ka': {'Ka': ['0.80', '0.1'],
'Ba': ['0.50', '1.1'],
'FC': ['0.78', '0.0'],
'AA': ['0.66', '8.1']},
'AL': {'AR': ['2.71', '7.3'], 'KK': ['10.00', '90.0']}}
for item, value in sample_dict.items():
print(item, value, type(value))
if type(value)==dict:
for item2 in list(value):
... | ```
from collections import defaultdict
new = defaultdict(dict)
for k, values in d.items():
for sub_key, values in values.items():
for value in values:
existing_key_count = sum(1 for existing_key in new[k].keys() if existing_key.startswith(sub_key))
new_key = f"{sub_key}.{existing_ke... |
45,732,286 | I am working with protein sequences. My goal is to create a convolutional network which will predict three angles for each amino acid in the protein. I'm having trouble debugging a TFLearn DNN model that requires a reshape operation.
The input data describes (currently) 25 proteins of varying lengths. To use Tensors I... | 2017/08/17 | [
"https://Stackoverflow.com/questions/45732286",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9376487/"
] | There is a new plugin (since a year),
called [chartjs-plugin-piechart-outlabels](https://www.npmjs.com/package/chartjs-plugin-piechart-outlabels)
Just import the source
`<script src="https://cdn.jsdelivr.net/npm/chartjs-plugin-piechart-outlabels"></script>`
and use it with the outlabeledPie type
```
var randomS... | The real problem lies with the overlapping of the labels when the slices are small.You can use [PieceLabel.js](https://emn178.github.io/Chart.PieceLabel.js/samples/demo/) which solves the issue of overlapping labels by hiding it . You mentioned that you **cannot hide labels** so use legends, which will display names of... |
45,732,286 | I am working with protein sequences. My goal is to create a convolutional network which will predict three angles for each amino acid in the protein. I'm having trouble debugging a TFLearn DNN model that requires a reshape operation.
The input data describes (currently) 25 proteins of varying lengths. To use Tensors I... | 2017/08/17 | [
"https://Stackoverflow.com/questions/45732286",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9376487/"
] | The real problem lies with the overlapping of the labels when the slices are small.You can use [PieceLabel.js](https://emn178.github.io/Chart.PieceLabel.js/samples/demo/) which solves the issue of overlapping labels by hiding it . You mentioned that you **cannot hide labels** so use legends, which will display names of... | I resolved:
We add script to file global:
```
if(window.Chartist && Chartist.Pie && !Chartist.Pie.prototype.resolveOverlap) {
Chartist.Pie.prototype.resolveOverlap = function() {
this.on('draw', function(ctx) {
if(ctx.type == 'label') {
let gText = $(ctx.group._n... |
45,732,286 | I am working with protein sequences. My goal is to create a convolutional network which will predict three angles for each amino acid in the protein. I'm having trouble debugging a TFLearn DNN model that requires a reshape operation.
The input data describes (currently) 25 proteins of varying lengths. To use Tensors I... | 2017/08/17 | [
"https://Stackoverflow.com/questions/45732286",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9376487/"
] | There is a new plugin (since a year),
called [chartjs-plugin-piechart-outlabels](https://www.npmjs.com/package/chartjs-plugin-piechart-outlabels)
Just import the source
`<script src="https://cdn.jsdelivr.net/npm/chartjs-plugin-piechart-outlabels"></script>`
and use it with the outlabeledPie type
```
var randomS... | I resolved:
We add script to file global:
```
if(window.Chartist && Chartist.Pie && !Chartist.Pie.prototype.resolveOverlap) {
Chartist.Pie.prototype.resolveOverlap = function() {
this.on('draw', function(ctx) {
if(ctx.type == 'label') {
let gText = $(ctx.group._n... |
45,732,286 | I am working with protein sequences. My goal is to create a convolutional network which will predict three angles for each amino acid in the protein. I'm having trouble debugging a TFLearn DNN model that requires a reshape operation.
The input data describes (currently) 25 proteins of varying lengths. To use Tensors I... | 2017/08/17 | [
"https://Stackoverflow.com/questions/45732286",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9376487/"
] | There is a new plugin (since a year),
called [chartjs-plugin-piechart-outlabels](https://www.npmjs.com/package/chartjs-plugin-piechart-outlabels)
Just import the source
`<script src="https://cdn.jsdelivr.net/npm/chartjs-plugin-piechart-outlabels"></script>`
and use it with the outlabeledPie type
```
var randomS... | I can't find an exact plugin but I make one.
```
const data = {
labels: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
datasets: [
{
data: [1, 2, 3, 4, 5, 6],
backgroundColor: [
"#316065",
"#1A7F89",
"#2D9CA7",
... |
45,732,286 | I am working with protein sequences. My goal is to create a convolutional network which will predict three angles for each amino acid in the protein. I'm having trouble debugging a TFLearn DNN model that requires a reshape operation.
The input data describes (currently) 25 proteins of varying lengths. To use Tensors I... | 2017/08/17 | [
"https://Stackoverflow.com/questions/45732286",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9376487/"
] | I can't find an exact plugin but I make one.
```
const data = {
labels: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
datasets: [
{
data: [1, 2, 3, 4, 5, 6],
backgroundColor: [
"#316065",
"#1A7F89",
"#2D9CA7",
... | I resolved:
We add script to file global:
```
if(window.Chartist && Chartist.Pie && !Chartist.Pie.prototype.resolveOverlap) {
Chartist.Pie.prototype.resolveOverlap = function() {
this.on('draw', function(ctx) {
if(ctx.type == 'label') {
let gText = $(ctx.group._n... |
58,523,431 | `driver.getWindowHandles()` returns Set
so, if we want to choose window by index, we have to wrap Set into ArrayList:
```
var tabsList = new ArrayList<>(driver.getWindowHandles());
var nextTab = tabsList.get(1);
driver.switchTo().window(nextTab);
```
in python we can access windows by index immediately:
```
next_wi... | 2019/10/23 | [
"https://Stackoverflow.com/questions/58523431",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11705114/"
] | Window Handles
--------------
In a discussion, regarding [window-handles](/questions/tagged/window-handles "show questions tagged 'window-handles'") Simon (creator of WebDriver) clearly mentioned that:
>
> While the datatype used for storing the list of handles may be ordered by insertion, the order in which the Web... | One comment - take into account the order of Set is not fixed, so it will return you a random window by the usage above. |
58,523,431 | `driver.getWindowHandles()` returns Set
so, if we want to choose window by index, we have to wrap Set into ArrayList:
```
var tabsList = new ArrayList<>(driver.getWindowHandles());
var nextTab = tabsList.get(1);
driver.switchTo().window(nextTab);
```
in python we can access windows by index immediately:
```
next_wi... | 2019/10/23 | [
"https://Stackoverflow.com/questions/58523431",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11705114/"
] | Because Sets do not impose an order,\* which is important since there is no guaranteed order of the window handles returned. This is because the window handles represent not only tabs but also tabs in other browser windows. There is no reliable definition of their overall order which would work across platforms and bro... | One comment - take into account the order of Set is not fixed, so it will return you a random window by the usage above. |
58,523,431 | `driver.getWindowHandles()` returns Set
so, if we want to choose window by index, we have to wrap Set into ArrayList:
```
var tabsList = new ArrayList<>(driver.getWindowHandles());
var nextTab = tabsList.get(1);
driver.switchTo().window(nextTab);
```
in python we can access windows by index immediately:
```
next_wi... | 2019/10/23 | [
"https://Stackoverflow.com/questions/58523431",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11705114/"
] | Because Sets do not impose an order,\* which is important since there is no guaranteed order of the window handles returned. This is because the window handles represent not only tabs but also tabs in other browser windows. There is no reliable definition of their overall order which would work across platforms and bro... | Window Handles
--------------
In a discussion, regarding [window-handles](/questions/tagged/window-handles "show questions tagged 'window-handles'") Simon (creator of WebDriver) clearly mentioned that:
>
> While the datatype used for storing the list of handles may be ordered by insertion, the order in which the Web... |
53,372,966 | While executing the following python script using cloud-composer, I get `*** Task instance did not exist in the DB` under the `gcs2bq` task Log in Airflow
Code:
```
import datetime
import os
import csv
import pandas as pd
import pip
from airflow import models
#from airflow.contrib.operators import dataproc_operator
fr... | 2018/11/19 | [
"https://Stackoverflow.com/questions/53372966",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6039925/"
] | I have stumbled on this issue also. What helped for me was to do this line:
```
spark.sql("SET spark.sql.hive.manageFilesourcePartitions=False")
```
and then use `spark.sql(query)` instead of using dataframe.
I do not know what happens under the hood, but this solved my problem.
Although it might be too late for ... | I know the topic is quite old but:
1. I've received same error but the actual source problem was hidden much deeper in logs. If you facing same problem as me, go to the end of your stack trace and you might find actual reason for job to be failing. In my case:
a. `org.apache.spark.sql.hive.client.Shim_v0_13.getPar... |
70,339,321 | The decision variable of my optimization problem (which I am aiming at keeping linear) is a placement binary vector, where the value in each position is either 0 or 1 (two different possible locations of item i).
One component of the objective function is this:
[](https://i.... | 2021/12/13 | [
"https://Stackoverflow.com/questions/70339321",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11422437/"
] | My notation is: `xprev[i]` is the previous solution and `x[i]` is the current one. I assume `xprev[i]` is a binary constant and `x[i]` is a binary variable. Then we can write
```
sum(i, |xprev[i]-x[i]|)
=sum(i|xprev[i]=0, x[i]) + sum(i|xprev[i]=1, 1-x[i])
=sum(i, x[i]*(1-xprev[i]) + (1-x[i])*xprev[i])
``... | **UPDATE**:
If what you need to replace is a XOR gate, then you could use a combination of other gates, which are linear, to replace it. Here are some of them <https://en.wikipedia.org/wiki/XOR_gate#Alternatives>.
Example: `A XOR B = (A OR B) AND (NOT A + NOT B)`. When A and B are binary, that should translate mathema... |
65,493,246 | I am using python through a secure shell. When I use pydot and graphviz package, it shows error [Errno 2] dot not found in path. I searched so many solutions. People suggest 'sudo apt install graphviz' or 'sudo apt-get install graphviz'. But when I use 'sudo', it shows 'username is not in the sudoers file.This incident... | 2020/12/29 | [
"https://Stackoverflow.com/questions/65493246",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14644632/"
] | You can use `_source` to limit what's retrieved:
```
POST indexname/_search
{
"_source": "scores.a/*"
}
```
Alternatively, you could employ `script_fields` which do exactly the same but offer playroom for value modification too:
```
POST indexname/_search
{
"script_fields": {
"scores_prefixed_with_a": {
... | Use [`.filter()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter) - [`.reduce()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce) on [`Object.keys()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Ob... |
10,234,575 | I first installed pymongo using easy\_install, that didn't work so I tried with pip and it is still failing.
This is fine in the terminal:
```
Macintosh:etc me$ python
Python 2.7.2 (v2.7.2:8527427914a2, Jun 11 2011, 14:13:39)
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
Type "help", "copyright", "credits" or "licen... | 2012/04/19 | [
"https://Stackoverflow.com/questions/10234575",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4533572/"
] | Found it! Required a path append before importing of the pymongo module
```
sys.path.append('/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages')
import pymongo
```
Would ideally like to find a way to append this to the pythonpath permanently, but this works for now! | I'm not sure why the last message says "Successfully installed pymongo" but it obviously failed due to the fact that you don't have gcc installed on your system. You need to do the following:
RHEL/Centos: sudo yum install gcc python-devel
Debian/Ubuntu: sudo apt-get install gcc python-dev
Then try and install pymongo... |
1,941,894 | I'm trying to get virtualenv to work on my machine. I'm using python2.6, and after installing pip, and using pip to install virtualenv, running "virtualenv --no-site-packages cyclesg" results in the following:
```
New python executable in cyclesg/bin/python
Installing setuptools....
Complete output from command /hom... | 2009/12/21 | [
"https://Stackoverflow.com/questions/1941894",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/236267/"
] | Are you on mandriva?
In order to support multilib (mixing x86/x86\_64) Mandriva messes up your python installation. They patched python, which breaks virtualenv; instead of fixing python, they then proceeded to patch virtualenv. This is useless if you are using your own virtualenv installed from pip.
Here is the bug:... | Are you on a linux based system? It looks like virtualenv is trying to build a new python exectable but can't find the files to do that. Try installing the `python-dev` package. |
65,465,114 | I am new to python programming. Following the AWS learning path:
<https://aws.amazon.com/getting-started/hands-on/build-train-deploy-machine-learning-model-sagemaker/?trk=el_a134p000003yWILAA2&trkCampaign=DS_SageMaker_Tutorial&sc_channel=el&sc_campaign=Data_Scientist_Hands-on_Tutorial&sc_outcome=Product_Marketing&sc_g... | 2020/12/27 | [
"https://Stackoverflow.com/questions/65465114",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2601359/"
] | If you just remove it then the prediction will work. Therefore, recommend removing this code line.
xgb\_predictor.content\_type = 'text/csv' | Removing xgb\_predictor.content\_type = 'text/csv' will work.
But best way is that you first check the attributes of the object:
```
xgb_predictor.__dict__.keys()
```
This way, you will know that which attributes can be set. |
63,767,925 | I'm really new to programming (two days old), so excuse my python dumbness. I've recently run into a problem with adding up to numbers from a list. I've managed to come up with this program:
```
list_nums = ["17", "3"]
num1 = list_nums[0]
num2 = list_nums[1] ... | 2020/09/06 | [
"https://Stackoverflow.com/questions/63767925",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14231446/"
] | `"17"` and `"3"`These are string, if you remove double-quotes from them, they become integers `17` and `3`.
So if you want to add 2 numbers, they have to be `integer` or `float` in Python.
Just remove double-quotes in list:
`list_nums = [17, 3]` | Your `num1` and `num2` variables contain string values `'17'` and `'3'`. Operator `+` for strings works as a concatenation, e.g. `'17' + '3' == '173'`. If you need to get 20 out of it, you need to work with numeric types, like integers. For that, you either need to remove quotes from your 17 and 3 literals:
```
list_n... |
40,851,872 | Can I get python to print the source code for `__builtins__` directly?
OR (more preferably):
What is the pathname of the source code for `__builtins__`?
---
I at least know the following things:
* `__builtins__` is a module, by typing `type(__builtins__)`.
* I have tried the best-answer-suggestions to a more gene... | 2016/11/28 | [
"https://Stackoverflow.com/questions/40851872",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | The `__builtin__` module is implemented in [`Python/bltinmodule.c`](https://github.com/python/cpython/blob/2.7/Python/bltinmodule.c), a rather unusual location for a rather unusual module. | I can't try it right now, but python default ide is able to open core modules easily (I tried with math and some more)
<https://docs.python.org/2/library/idle.html>
On menus. Open module. |
8,275,793 | I have managed to write some simple scripts in python for android using sl4a. I can also create shortcuts on my home screen for them. But the icon chosen for this is always the python sl4a icon. Can I change this so different scripts have different icons? | 2011/11/26 | [
"https://Stackoverflow.com/questions/8275793",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1024495/"
] | You can change it if you build the .APK file from your computer and pick the icon there. You develop the Python SL4A application and you pick the logo in the /res/drawable folder. | I guess it depends on your launcher.
With ADW launcher, you can do a long press on your shortcut from your home screen and then select the icon you want to use by pressing the icon button.
For other launchers I've no idea. |
8,275,793 | I have managed to write some simple scripts in python for android using sl4a. I can also create shortcuts on my home screen for them. But the icon chosen for this is always the python sl4a icon. Can I change this so different scripts have different icons? | 2011/11/26 | [
"https://Stackoverflow.com/questions/8275793",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1024495/"
] | You can change it if you build the .APK file from your computer and pick the icon there. You develop the Python SL4A application and you pick the logo in the /res/drawable folder. | From what I know raduq's answer is correct as when you run a script it is not an actual application, therefor it does not have it's own icon. When you build the script into it's own apk you are able to define your own icons for your project as it is installed as an actual application within your Android system.
Once y... |
51,952,761 | In tkinter, when a button has the focus, you can press the space bar to execute the command associated with that button. I'm trying to make pressing the Enter key do the same thing. I'm certain I've done this in the past, but I can't find the code, and what I'm doing now isn't working. I'm using python 3.6.1 on a Mac.
... | 2018/08/21 | [
"https://Stackoverflow.com/questions/51952761",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/908293/"
] | The only thing your Ajax is sending is this.refs.search.value - not the name "search" / not url encoded / not multi-part encoded. Indeed, you seem to have invented your own encoding system.
Try:
```
xhr.open('get','//localhost:80/ReactStudy/travelReduxApp/public/server/search.php?search=' + value,true);
```
in Ajax... | ```
<?php
header('Access-Control-Allow-Origin:* ');
/*shows warning without isset*/
/*$form = $_GET["search"];
echo $form;*/
/*with isset shows not found*/
if(isset($_POST["search"])){
$form = $_GET["search"];
echo $form;
}else{
echo "not found";`ghd`
}
?>
``` |
37,357,896 | I am using sublime to automatically word-wrap python code-lines that go beyond 79 Characters as the Pep-8 defines. Initially i was doing return to not go beyond the limit.
The only downside with that is that anyone else not having the word-wrap active wouldn't have the limitation. So should i strive forward of actual... | 2016/05/21 | [
"https://Stackoverflow.com/questions/37357896",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1767754/"
] | PEP8 wants you to perform an actual word wrap. The point of PEP8’s stylistic rules is that the file looks the same in every editor, so you cannot rely on editor visualizations to satisfy PEP8.
This also makes you choose the point where to break deliberately. For example, Sublime will do a pretty basic job in wrapping ... | In-file word wrapping would let your code conform to Pep-8 most consistently, even if other programmers are looking at your code using different coding environments. That seems to me to be the best solution to keeping to the standard, particularly if you are expecting that others will, at some point, be looking at your... |
43,630,195 | `A = [[[1,2,3],[4]],[[1,4],[2,3]]]`
Here I want to find lists in A which sum of all sublists in list not grater than 5.
Which the result should be `[[1,4],[2,3]]`
I tried a long time to solve this problem in python. But I still can't figure out the right solution, which I stuck at loop out multiple loops. My code as... | 2017/04/26 | [
"https://Stackoverflow.com/questions/43630195",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5702561/"
] | A simple solution which you can think of would be like this -
```
A = [[[1,2,3],[4]],[[1,4],[2,3]]]
r = [] # this will be our result
for list in A: # Iterate through each item in A
f = True # This is a flag we set for a favorable sublist
for item in list: # Here we iterate through each list in the su... | This should work for your problem:
```
>>> for alist in A:
... if max(sum(sublist) for sublist in alist) <= 5:
... print(alist)
...
[[1, 4], [2, 3]]
``` |
43,630,195 | `A = [[[1,2,3],[4]],[[1,4],[2,3]]]`
Here I want to find lists in A which sum of all sublists in list not grater than 5.
Which the result should be `[[1,4],[2,3]]`
I tried a long time to solve this problem in python. But I still can't figure out the right solution, which I stuck at loop out multiple loops. My code as... | 2017/04/26 | [
"https://Stackoverflow.com/questions/43630195",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5702561/"
] | Simplification of @KindStranger method in a one-liner:
```
>> [sub for x in A for sub in x if max(sum(sub) for sub in x) <= 5]
[[1, 4], [2, 3]]
``` | This should work for your problem:
```
>>> for alist in A:
... if max(sum(sublist) for sublist in alist) <= 5:
... print(alist)
...
[[1, 4], [2, 3]]
``` |
43,630,195 | `A = [[[1,2,3],[4]],[[1,4],[2,3]]]`
Here I want to find lists in A which sum of all sublists in list not grater than 5.
Which the result should be `[[1,4],[2,3]]`
I tried a long time to solve this problem in python. But I still can't figure out the right solution, which I stuck at loop out multiple loops. My code as... | 2017/04/26 | [
"https://Stackoverflow.com/questions/43630195",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5702561/"
] | Simplification of @KindStranger method in a one-liner:
```
>> [sub for x in A for sub in x if max(sum(sub) for sub in x) <= 5]
[[1, 4], [2, 3]]
``` | A simple solution which you can think of would be like this -
```
A = [[[1,2,3],[4]],[[1,4],[2,3]]]
r = [] # this will be our result
for list in A: # Iterate through each item in A
f = True # This is a flag we set for a favorable sublist
for item in list: # Here we iterate through each list in the su... |
43,630,195 | `A = [[[1,2,3],[4]],[[1,4],[2,3]]]`
Here I want to find lists in A which sum of all sublists in list not grater than 5.
Which the result should be `[[1,4],[2,3]]`
I tried a long time to solve this problem in python. But I still can't figure out the right solution, which I stuck at loop out multiple loops. My code as... | 2017/04/26 | [
"https://Stackoverflow.com/questions/43630195",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5702561/"
] | A simple solution which you can think of would be like this -
```
A = [[[1,2,3],[4]],[[1,4],[2,3]]]
r = [] # this will be our result
for list in A: # Iterate through each item in A
f = True # This is a flag we set for a favorable sublist
for item in list: # Here we iterate through each list in the su... | The one with `all()`
```
[t for item in A for t in item if all(sum(t)<=5 for t in item)]
``` |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.