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
51,878,354
Is there a built-in function that works like zip(), but fills the results so that the length of the resulting list is the length of the longest input and fills the list **from the left** with e.g. `None`? There is already an [answer](https://stackoverflow.com/a/1277311/2648551) using [zip\_longest](https://docs.python...
2018/08/16
[ "https://Stackoverflow.com/questions/51878354", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2648551/" ]
Use **`zip_longest`** but reverse lists. **Example**: ``` from itertools import zip_longest header = ["title", "firstname", "lastname"] person_1 = ["Dr.", "Joe", "Doe"] person_2 = ["Mary", "Poppins"] person_3 = ["Smith"] print(dict(zip_longest(reversed(header), reversed(person_2)))) # {'lastname': 'Poppins', 'first...
The generic "magic zip" generator function with a variable number of args (which only uses lazy-evaluation functions and no python loops): ``` import itertools def magic_zip(*args): return itertools.zip_longest(*map(reversed,args)) ``` testing (of course in the case of a dict build, only 2 params are needed): ...
51,878,354
Is there a built-in function that works like zip(), but fills the results so that the length of the resulting list is the length of the longest input and fills the list **from the left** with e.g. `None`? There is already an [answer](https://stackoverflow.com/a/1277311/2648551) using [zip\_longest](https://docs.python...
2018/08/16
[ "https://Stackoverflow.com/questions/51878354", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2648551/" ]
Simply use `zip_longest` and read the arguments in the reverse direction: ``` In [20]: dict(zip_longest(header[::-1], person_1[::-1])) Out[20]: {'lastname': 'Doe', 'firstname': 'Joe', 'title': 'Dr.'} In [21]: dict(zip_longest(header[::-1], person_2[::-1])) Out[21]: {'lastname': 'Poppins', 'firstname': 'Mary', 'title'...
``` def magic_zip(*lists): max_len = max(map(len, lists)) return zip(*([None] * (max_len - len(l)) + l for l in lists)) ```
51,878,354
Is there a built-in function that works like zip(), but fills the results so that the length of the resulting list is the length of the longest input and fills the list **from the left** with e.g. `None`? There is already an [answer](https://stackoverflow.com/a/1277311/2648551) using [zip\_longest](https://docs.python...
2018/08/16
[ "https://Stackoverflow.com/questions/51878354", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2648551/" ]
Simply use `zip_longest` and read the arguments in the reverse direction: ``` In [20]: dict(zip_longest(header[::-1], person_1[::-1])) Out[20]: {'lastname': 'Doe', 'firstname': 'Joe', 'title': 'Dr.'} In [21]: dict(zip_longest(header[::-1], person_2[::-1])) Out[21]: {'lastname': 'Poppins', 'firstname': 'Mary', 'title'...
The generic "magic zip" generator function with a variable number of args (which only uses lazy-evaluation functions and no python loops): ``` import itertools def magic_zip(*args): return itertools.zip_longest(*map(reversed,args)) ``` testing (of course in the case of a dict build, only 2 params are needed): ...
51,878,354
Is there a built-in function that works like zip(), but fills the results so that the length of the resulting list is the length of the longest input and fills the list **from the left** with e.g. `None`? There is already an [answer](https://stackoverflow.com/a/1277311/2648551) using [zip\_longest](https://docs.python...
2018/08/16
[ "https://Stackoverflow.com/questions/51878354", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2648551/" ]
The generic "magic zip" generator function with a variable number of args (which only uses lazy-evaluation functions and no python loops): ``` import itertools def magic_zip(*args): return itertools.zip_longest(*map(reversed,args)) ``` testing (of course in the case of a dict build, only 2 params are needed): ...
``` def magic_zip(*lists): max_len = max(map(len, lists)) return zip(*([None] * (max_len - len(l)) + l for l in lists)) ```
25,438,170
Input: ``` A B C D E F ``` This file is NOT exclusively tab-delimited, some entries are space-delimited to look like they were tab-delimited (which is annoying). I tried reading in the file with the `csv` module using the canonical tab delimited option hoping it wouldn't mind a few spaces (needless to sa...
2014/08/22
[ "https://Stackoverflow.com/questions/25438170", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3878253/" ]
Just use .split(): ``` csv='''\ A\tB\tC D E F ''' data=[] for line in csv.splitlines(): data.append(line.split()) print data # [['A', 'B', 'C'], ['D', 'E', 'F']] ``` Or, more succinctly: ``` >>> [line.split() for line in csv.splitlines()] [['A', 'B', 'C'], ['D', 'E', 'F']] ``` For a file, something...
Why not just roll your own splitter rather than the CSV module? ``` delimeters = [',', ' ', '\t'] unique = '[**This is a unique delimeter**]' with open(fileName) as f: for l in f: for d in delimeters: l = unique.join(l.split(d)) row = l.split(unique) ```
25,438,170
Input: ``` A B C D E F ``` This file is NOT exclusively tab-delimited, some entries are space-delimited to look like they were tab-delimited (which is annoying). I tried reading in the file with the `csv` module using the canonical tab delimited option hoping it wouldn't mind a few spaces (needless to sa...
2014/08/22
[ "https://Stackoverflow.com/questions/25438170", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3878253/" ]
Just use .split(): ``` csv='''\ A\tB\tC D E F ''' data=[] for line in csv.splitlines(): data.append(line.split()) print data # [['A', 'B', 'C'], ['D', 'E', 'F']] ``` Or, more succinctly: ``` >>> [line.split() for line in csv.splitlines()] [['A', 'B', 'C'], ['D', 'E', 'F']] ``` For a file, something...
.split() is an easy and nice solution for the situation that "consecutive, arbitrarily-mixed tabs and blanks as one delimiter"; However, this does not work while value with blank (enclosed by quote mark) appears. First, we may replace each tab in the text file with one blank `' '`; This can simplify the situation to "...
25,438,170
Input: ``` A B C D E F ``` This file is NOT exclusively tab-delimited, some entries are space-delimited to look like they were tab-delimited (which is annoying). I tried reading in the file with the `csv` module using the canonical tab delimited option hoping it wouldn't mind a few spaces (needless to sa...
2014/08/22
[ "https://Stackoverflow.com/questions/25438170", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3878253/" ]
Why not just roll your own splitter rather than the CSV module? ``` delimeters = [',', ' ', '\t'] unique = '[**This is a unique delimeter**]' with open(fileName) as f: for l in f: for d in delimeters: l = unique.join(l.split(d)) row = l.split(unique) ```
.split() is an easy and nice solution for the situation that "consecutive, arbitrarily-mixed tabs and blanks as one delimiter"; However, this does not work while value with blank (enclosed by quote mark) appears. First, we may replace each tab in the text file with one blank `' '`; This can simplify the situation to "...
46,964,509
I am following a tutorial on using selenium and python to make a web **scraper** for twitter, and I ran into this error. ``` File "C:\Python34\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 62, in __init__ self.service.start() File "C:\Python34\lib\site-packages\selenium\webdriver\common\service...
2017/10/26
[ "https://Stackoverflow.com/questions/46964509", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7922147/" ]
Another way is download and uzip [chromedriver](https://chromedriver.storage.googleapis.com/index.html?path=2.33/) and put 'chromedriver.exe' in C:\Python27\Scripts and then you need not to provide the path of driver, just ``` driver= webdriver.Chrome() ``` will work
If you take a look to your exception: ``` selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home ``` At the [indicated url](https://sites.google.com/a/chromium.org/chromedriver/home), you can see the ...
4,663,024
Hey, I would like to be able to perform [this](https://stackoverflow.com/questions/638048/how-do-i-sum-the-first-value-in-each-tuple-in-a-list-of-tuples-in-python) but with being selective for which lists I sum up. Let's say, that same example, but with only adding up the first number from the 3rd and 4th list.
2011/01/11
[ "https://Stackoverflow.com/questions/4663024", "https://Stackoverflow.com", "https://Stackoverflow.com/users/556344/" ]
Something like: ``` sum(int(tuple_list[i][0]) for i in range(3,5)) ``` range(x, y) generates a list of integers from x(included) to y(excluded) and 1 as the step. If you want to change the `range(x, y, step)` will do the same but increasing by step. You can find the official documentation [here](http://docs.python....
If you want to limit by some property of each element, you can use [`filter()`](http://docs.python.org/library/functions.html#filter) before feeding it to the code posted in your link. This will let you write a unique filter depending on what you want. This doesn't work for the example you gave, but it seemed like you ...
4,663,024
Hey, I would like to be able to perform [this](https://stackoverflow.com/questions/638048/how-do-i-sum-the-first-value-in-each-tuple-in-a-list-of-tuples-in-python) but with being selective for which lists I sum up. Let's say, that same example, but with only adding up the first number from the 3rd and 4th list.
2011/01/11
[ "https://Stackoverflow.com/questions/4663024", "https://Stackoverflow.com", "https://Stackoverflow.com/users/556344/" ]
Something like: ``` sum(int(tuple_list[i][0]) for i in range(3,5)) ``` range(x, y) generates a list of integers from x(included) to y(excluded) and 1 as the step. If you want to change the `range(x, y, step)` will do the same but increasing by step. You can find the official documentation [here](http://docs.python....
``` >>> l1 [(0, 2), (1, 3), (2, 4), (3, 5), (4, 6), (5, 7), (6, 8), (7, 9), (8, 10), (9, 11)] >>> sum([el[0] for (nr, el) in enumerate(l1) if nr in [3, 4]]) 7 >>> ```
4,663,024
Hey, I would like to be able to perform [this](https://stackoverflow.com/questions/638048/how-do-i-sum-the-first-value-in-each-tuple-in-a-list-of-tuples-in-python) but with being selective for which lists I sum up. Let's say, that same example, but with only adding up the first number from the 3rd and 4th list.
2011/01/11
[ "https://Stackoverflow.com/questions/4663024", "https://Stackoverflow.com", "https://Stackoverflow.com/users/556344/" ]
Something like: ``` sum(int(tuple_list[i][0]) for i in range(3,5)) ``` range(x, y) generates a list of integers from x(included) to y(excluded) and 1 as the step. If you want to change the `range(x, y, step)` will do the same but increasing by step. You can find the official documentation [here](http://docs.python....
not seen an answer using reduce yet. `reduce(lambda sumSoFar,(tuple0,tuple1): sumSoFar+tuple0, list, 0)` In essence sum is identical to `reduce(int.__add__, list, 0)` edit: didn't read the predicate part. Easily fixed, but probably not the best answer anymore: ``` predicate = lambda x: x == 2 or x == 4 reduce(lamb...
4,663,024
Hey, I would like to be able to perform [this](https://stackoverflow.com/questions/638048/how-do-i-sum-the-first-value-in-each-tuple-in-a-list-of-tuples-in-python) but with being selective for which lists I sum up. Let's say, that same example, but with only adding up the first number from the 3rd and 4th list.
2011/01/11
[ "https://Stackoverflow.com/questions/4663024", "https://Stackoverflow.com", "https://Stackoverflow.com/users/556344/" ]
``` >>> l1 [(0, 2), (1, 3), (2, 4), (3, 5), (4, 6), (5, 7), (6, 8), (7, 9), (8, 10), (9, 11)] >>> sum([el[0] for (nr, el) in enumerate(l1) if nr in [3, 4]]) 7 >>> ```
If you want to limit by some property of each element, you can use [`filter()`](http://docs.python.org/library/functions.html#filter) before feeding it to the code posted in your link. This will let you write a unique filter depending on what you want. This doesn't work for the example you gave, but it seemed like you ...
4,663,024
Hey, I would like to be able to perform [this](https://stackoverflow.com/questions/638048/how-do-i-sum-the-first-value-in-each-tuple-in-a-list-of-tuples-in-python) but with being selective for which lists I sum up. Let's say, that same example, but with only adding up the first number from the 3rd and 4th list.
2011/01/11
[ "https://Stackoverflow.com/questions/4663024", "https://Stackoverflow.com", "https://Stackoverflow.com/users/556344/" ]
``` >>> l1 [(0, 2), (1, 3), (2, 4), (3, 5), (4, 6), (5, 7), (6, 8), (7, 9), (8, 10), (9, 11)] >>> sum([el[0] for (nr, el) in enumerate(l1) if nr in [3, 4]]) 7 >>> ```
not seen an answer using reduce yet. `reduce(lambda sumSoFar,(tuple0,tuple1): sumSoFar+tuple0, list, 0)` In essence sum is identical to `reduce(int.__add__, list, 0)` edit: didn't read the predicate part. Easily fixed, but probably not the best answer anymore: ``` predicate = lambda x: x == 2 or x == 4 reduce(lamb...
64,773,690
I'm new to python and I'm trying to use the census geocoding services API to geocode addresses then convert the output to a dataframe. I've been able to read in my address file and I can see the output, but I can't seem to figure out how to import it into a dataframe. I provided the code I used below as well as the con...
2020/11/10
[ "https://Stackoverflow.com/questions/64773690", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14614221/" ]
To address both the legend and palette issue at the same time. First you could convert the data frame into long format using `pivot_longer()`, then add a column that specifies the colour you want with the associated variable. You can map those colours using `scale_colour_manual()`. Not the most elegant solution but I f...
Since @EJJ's reply did not work for some reason, I used a similar approach but using `melt()`. Here is the code and the plot: ``` colnames(df) <- c("date","Act_day","Rest_day","Act_night","Rest_night") df <- melt(df, id.vars=c("date")) colnames(df) <- c("date","State","value") Plot <- ggplot(df,aes(x = date, ...
26,345,185
I’m having trouble using python’s multiprocessing module. This is the first time I’ve tried using the module. I’ve tried simplifying my processing to the bare bones, but keep getting the same error. I’m using python 2.7.2, and Windows 7. The script I’m trying to run is called `learnmp.py`, and the error message says t...
2014/10/13
[ "https://Stackoverflow.com/questions/26345185", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2241053/" ]
I know it's been a while, but I ran into this same error, also using the version of Python distributed with ArcGIS, and I've found a solution which at least worked in my case. The problem that I had was that I was calling my program name, Test.py, as test.py. Note the difference in case. ``` c:\python27\arcgisx6410.2...
Looks like you might be going down a rabbit-hole looking into `multiprocessing`. As the traceback shows, your python install is trying to look in the ArcGIS version of python before actually looking at your system install. My guess is that the version of python that ships with ArcGIS is slightly customized for some re...
26,345,185
I’m having trouble using python’s multiprocessing module. This is the first time I’ve tried using the module. I’ve tried simplifying my processing to the bare bones, but keep getting the same error. I’m using python 2.7.2, and Windows 7. The script I’m trying to run is called `learnmp.py`, and the error message says t...
2014/10/13
[ "https://Stackoverflow.com/questions/26345185", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2241053/" ]
I know it's been a while, but I ran into this same error, also using the version of Python distributed with ArcGIS, and I've found a solution which at least worked in my case. The problem that I had was that I was calling my program name, Test.py, as test.py. Note the difference in case. ``` c:\python27\arcgisx6410.2...
Microsoft Visual C++ 9.0 is required for some python modules to work in windows,so download below package it will work. `http://aka.ms/vcpython27` This package contains the compiler and set of system headers necessary for producing binary wheels for Python 2.7 packages.
74,113,894
I have a request respond from api and it looks like this: ``` '224014@@@1;1=8.4=0;2=33=0;3=9.4=0@@@2;1=15=0;2=3.3=1;3=4.2=0;4=5.7=0;5=9.4=0;6=22=0@@@3;1=17=0;2=7.4=0;3=27=0@@@4;1=14=0;2=7.8=0;3=5.9=0;4=23=0;5=4.0=1' ``` I had splited them for your EASY READING with some explaination: ``` [1]The 6 digital numbers st...
2022/10/18
[ "https://Stackoverflow.com/questions/74113894", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19998897/" ]
firstly, `sum` is a protected keyword since it is the list sum function, so don't call any variables "sum". to split the string, try: ```py sum=0 sq="" for i in range (0+2,1000+1,2): sum+=i if i<1000: sq=sq+str(i)+", " else: sq=sq+str(i) if i % 40 == 0: sq += "\n" print(sq, end="\n") p...
#### solution ```py sum=0 for i in range(2,1001,2): sum+=i if i%20 == 2: print("\n{}".format(i),end="") # print new line per 20 numbers else: print(", {}".format(i),end="") print("\nSum of all even numbers within 1 and 1000 =",sum) ``` * Output: ```bash 2, 4, 6, 8, 10, 12, 14, 16, 18, 20 22, 24, 26,...
74,113,894
I have a request respond from api and it looks like this: ``` '224014@@@1;1=8.4=0;2=33=0;3=9.4=0@@@2;1=15=0;2=3.3=1;3=4.2=0;4=5.7=0;5=9.4=0;6=22=0@@@3;1=17=0;2=7.4=0;3=27=0@@@4;1=14=0;2=7.8=0;3=5.9=0;4=23=0;5=4.0=1' ``` I had splited them for your EASY READING with some explaination: ``` [1]The 6 digital numbers st...
2022/10/18
[ "https://Stackoverflow.com/questions/74113894", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19998897/" ]
firstly, `sum` is a protected keyword since it is the list sum function, so don't call any variables "sum". to split the string, try: ```py sum=0 sq="" for i in range (0+2,1000+1,2): sum+=i if i<1000: sq=sq+str(i)+", " else: sq=sq+str(i) if i % 40 == 0: sq += "\n" print(sq, end="\n") p...
Uisng `textwrap` [Inbuilt Library](https://docs.python.org/3/library/textwrap.html) ``` import textwrap import re sum=0 sq="" for i in range (0+2,1000+1,2): sum+=i if i<1000: sq=sq+str(i)+"," else: sq=sq+str(i) #print(sq, end="\n") print('\n'.join(textwrap.wrap(sq, 20)))#Mask n here print("Su...
74,113,894
I have a request respond from api and it looks like this: ``` '224014@@@1;1=8.4=0;2=33=0;3=9.4=0@@@2;1=15=0;2=3.3=1;3=4.2=0;4=5.7=0;5=9.4=0;6=22=0@@@3;1=17=0;2=7.4=0;3=27=0@@@4;1=14=0;2=7.8=0;3=5.9=0;4=23=0;5=4.0=1' ``` I had splited them for your EASY READING with some explaination: ``` [1]The 6 digital numbers st...
2022/10/18
[ "https://Stackoverflow.com/questions/74113894", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19998897/" ]
firstly, `sum` is a protected keyword since it is the list sum function, so don't call any variables "sum". to split the string, try: ```py sum=0 sq="" for i in range (0+2,1000+1,2): sum+=i if i<1000: sq=sq+str(i)+", " else: sq=sq+str(i) if i % 40 == 0: sq += "\n" print(sq, end="\n") p...
Try this, ``` lst = [i for i in range(2,1001,2)] for i in range(0, len(lst), 20): print(','.join(str(i) for i in lst[i:i+20])) print(f'Sum of all even numbers within 1 and 1000 : {sum(lst)}') ```
44,211,461
What is the fastest way to combine 100 CSV files with headers into one with the following setup: 1. The total size of files is 200 MB. (The size is reduced to make the computation time visible) 2. The files are located on an SSD with a maximum speed of 240 MB/s. 3. The CPU has 4 cores so multi-threading and multiple p...
2017/05/26
[ "https://Stackoverflow.com/questions/44211461", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3596337/" ]
According to the benchmarks in the question the fastest method is pure Python with undocumented "next()" function behavior with binary files. The method was proposed by [Stefan Pochmann](https://stackoverflow.com/users/1672429/stefan-pochmann) Benchmarks: **Benchmarks (Updated with the methods from comments and posts...
`sed` is probably the fastest. I would also propose an `awk` alternative ``` awk 'NR==1; FNR==1{next} 1' file* > output ``` prints the first line from the first file, then skips all other first lines from the rest of the files. Timings: I tried 10,000 lines long 100 files each around 200MB (not sure). Here is a wor...
42,544,150
I am using python-3.x, and I am trying to do mutation on a binary string that will flip one bit of the elements from 0 to 1 or 1 to 0 by random, I tried some methods but didn't work I don't know where is the problem: ``` x=[0, 0, 0, 0, 0] def mutation (x, muta): for i in range(len(x)): if random.random() ...
2017/03/01
[ "https://Stackoverflow.com/questions/42544150", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7632116/" ]
If you want that your object don't pass from other object then, you should use colldier without [**isTrigger**](https://docs.unity3d.com/ScriptReference/Collider-isTrigger.html) check (isTrigger should be false) and use [OnCollisionEnter](https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnCollisionEnter.html) Eve...
you just using `Bounds` insteads of making many collider.
18,014,633
Consider the following simple python code: ``` f=open('raw1', 'r') i=1 for line in f: line1=line.split() for word in line1: print word, print '\n' ``` In the first for loop i.e "for line in f:", how does python know that I want to read a line and not a word or a character? The second loop is cleare...
2013/08/02
[ "https://Stackoverflow.com/questions/18014633", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2625987/" ]
Python has a notation of what are called "iterables". They're things that know how to let you traverse some data they hold. Some common iterators are lists, sets, dicts, pretty much every data structure. Files are no exception to this. The way things become iterable is by defining a method to return an object with a `...
In python the **for..in** syntax is used over iterables (elements tht can be iterated upon). For a file object, the iterator is the file itself. Please refer [here](http://docs.python.org/release/2.5.2/lib/bltin-file-objects.html) to the documentation of **next()** method - excerpt pasted below: > > A file object is...
32,127,602
After instantiating a deck (`deck = Deck()`), calling `deck.show_deck()` just prints out "two of diamonds" 52 times. The 'copy' part is as per [this answer](https://stackoverflow.com/questions/2196956/add-an-object-to-a-python-list), but doesn't seem to help. Any suggestions? ``` import copy from card import Card cla...
2015/08/20
[ "https://Stackoverflow.com/questions/32127602", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2372996/" ]
The problem here is that the `Card` class has a name variable which is shared with all instances of the `Card` class. When you have: ``` class Card: card_name = '' ``` This means that all `Card` objects will have the same name (`card_name`) which is almost surely not what you want. You have to make the name b...
To expand on what shuttle87 said: ``` class Card: card_name = '' ``` makes `card_name` a static variable (shared between all instances of that class) Once you make the variable non-static (by using `self.card_name` in the `__init__` method) you won't have to worry about the copy part as each instance of the ca...
47,701,629
Is there a way to run an `ipython` like debug console in VC Code that would allow tab completion and other sort of things?
2017/12/07
[ "https://Stackoverflow.com/questions/47701629", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2058333/" ]
Meanwhile, I have become a big fan of [PDB++](https://pypi.org/project/pdbpp/) debugger for python. It works like the iPython CLI, so I think the question has become obsolete specifically for me, but still may have some value for others.
It seems this is a desired feature for VS Code but not yet implemented. See this post: <https://github.com/DonJayamanne/vscodeJupyter/issues/19> I'm trying to see if one could use the config file of VS Code to define an ipython debug configuration e.g.: `{ "name": "ipython", "type": "python", "request": "launch", ...
47,701,629
Is there a way to run an `ipython` like debug console in VC Code that would allow tab completion and other sort of things?
2017/12/07
[ "https://Stackoverflow.com/questions/47701629", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2058333/" ]
It seems this is a desired feature for VS Code but not yet implemented. See this post: <https://github.com/DonJayamanne/vscodeJupyter/issues/19> I'm trying to see if one could use the config file of VS Code to define an ipython debug configuration e.g.: `{ "name": "ipython", "type": "python", "request": "launch", ...
the vscode debug console does allow for auto completion ... however, I am not sure if what you wanted was a way to trigger your code from an ipython shell, if so. you can start ipython like so, ``` python -m debugpy --listen 5678 `which ipython` ``` now you can connect to this remote debugger from vscode.
47,701,629
Is there a way to run an `ipython` like debug console in VC Code that would allow tab completion and other sort of things?
2017/12/07
[ "https://Stackoverflow.com/questions/47701629", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2058333/" ]
It seems this is a desired feature for VS Code but not yet implemented. See this post: <https://github.com/DonJayamanne/vscodeJupyter/issues/19> I'm trying to see if one could use the config file of VS Code to define an ipython debug configuration e.g.: `{ "name": "ipython", "type": "python", "request": "launch", ...
For tab completion you could install pyreadline3: ``` python -m pip install pyreadline3 ``` This is not neccessary on Linux, but on Windows it is.
47,701,629
Is there a way to run an `ipython` like debug console in VC Code that would allow tab completion and other sort of things?
2017/12/07
[ "https://Stackoverflow.com/questions/47701629", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2058333/" ]
Meanwhile, I have become a big fan of [PDB++](https://pypi.org/project/pdbpp/) debugger for python. It works like the iPython CLI, so I think the question has become obsolete specifically for me, but still may have some value for others.
No, currently (unfortunately) not. Here's an ongoing thread about this on github. The issue has P1 status, so will hopefully be implemented soon: <https://github.com/microsoft/vscode-python/issues/6972>
47,701,629
Is there a way to run an `ipython` like debug console in VC Code that would allow tab completion and other sort of things?
2017/12/07
[ "https://Stackoverflow.com/questions/47701629", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2058333/" ]
No, currently (unfortunately) not. Here's an ongoing thread about this on github. The issue has P1 status, so will hopefully be implemented soon: <https://github.com/microsoft/vscode-python/issues/6972>
the vscode debug console does allow for auto completion ... however, I am not sure if what you wanted was a way to trigger your code from an ipython shell, if so. you can start ipython like so, ``` python -m debugpy --listen 5678 `which ipython` ``` now you can connect to this remote debugger from vscode.
47,701,629
Is there a way to run an `ipython` like debug console in VC Code that would allow tab completion and other sort of things?
2017/12/07
[ "https://Stackoverflow.com/questions/47701629", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2058333/" ]
No, currently (unfortunately) not. Here's an ongoing thread about this on github. The issue has P1 status, so will hopefully be implemented soon: <https://github.com/microsoft/vscode-python/issues/6972>
For tab completion you could install pyreadline3: ``` python -m pip install pyreadline3 ``` This is not neccessary on Linux, but on Windows it is.
47,701,629
Is there a way to run an `ipython` like debug console in VC Code that would allow tab completion and other sort of things?
2017/12/07
[ "https://Stackoverflow.com/questions/47701629", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2058333/" ]
Meanwhile, I have become a big fan of [PDB++](https://pypi.org/project/pdbpp/) debugger for python. It works like the iPython CLI, so I think the question has become obsolete specifically for me, but still may have some value for others.
the vscode debug console does allow for auto completion ... however, I am not sure if what you wanted was a way to trigger your code from an ipython shell, if so. you can start ipython like so, ``` python -m debugpy --listen 5678 `which ipython` ``` now you can connect to this remote debugger from vscode.
47,701,629
Is there a way to run an `ipython` like debug console in VC Code that would allow tab completion and other sort of things?
2017/12/07
[ "https://Stackoverflow.com/questions/47701629", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2058333/" ]
Meanwhile, I have become a big fan of [PDB++](https://pypi.org/project/pdbpp/) debugger for python. It works like the iPython CLI, so I think the question has become obsolete specifically for me, but still may have some value for others.
For tab completion you could install pyreadline3: ``` python -m pip install pyreadline3 ``` This is not neccessary on Linux, but on Windows it is.
57,689,479
I am converting pdfs to text and got this code off a previous post: [Extracting text from a PDF file using PDFMiner in python?](https://stackoverflow.com/questions/26494211/extracting-text-from-a-pdf-file-using-pdfminer-in-python) When I print(text) it has done exactly what I want, but then I need to save this to a ...
2019/08/28
[ "https://Stackoverflow.com/questions/57689479", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11759292/" ]
The problem is your third argument. Third positional argument accepted by `open` is buffering, not encoding. Call `open` like this: ``` open('GMCAECON.txt', 'w', encoding='utf-8') ``` and your problem should go away.
when you do `file = open('GMCAECON.txt', 'w', 'utf-8')` you pass positional arguments to `open()`. Third argument you pass is `encoding`, however the third argument it expect is `buffering`. You need to pass `encoding` as keyword argument, e.g. `file = open('GMCAECON.txt', 'w', encoding='utf-8')` Note that it's much b...
58,466,174
We would like to remove the key and the values from a YAML file using python, for example ``` - misc_props: - attribute: tmp-1 value: 1 - attribute: tmp-2 value: 604800 - attribute: tmp-3 value: 100 - attribute: tmp-4 value: 1209600 name: temp_key1 attr-1: 20 attr-2: 1 - misc_props: - a...
2019/10/19
[ "https://Stackoverflow.com/questions/58466174", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5596456/" ]
It is not sufficient to delete a key-value pair to get your desired output. ``` import sys import ruamel.yaml yaml = ruamel.yaml.YAML() with open('input.yaml') as fp: data = yaml.load(fp) del data[1]['misc_props'] yaml.dump(data, sys.stdout) ``` as that gives: ``` - misc_props: - attribute: tmp-1 value: ...
Did you try using the yaml module? ``` import yaml with open('./old.yaml') as file: old_yaml = yaml.full_load(file) #This is the part of the code which filters out the undesired keys new_yaml = filter(lambda x: x['name']!='temp_key2', old_yaml) with open('./new.yaml', 'w') as file: documents = yaml.dump(new...
11,211,650
I'm using Python 2.7 on Windows and I am writing a script that uses both time and datetime modules. I've done this before, but python seems to be touchy about having both modules loaded and the methods I've used before don't seem to be working. Here are the different syntax I've used and the errors I am currently getti...
2012/06/26
[ "https://Stackoverflow.com/questions/11211650", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1070061/" ]
You can use **as** while importing time. ``` import time as t from datetime import datetime ... t.sleep(2) ```
Don't use `from ... import *` – this is a convenience syntax for interactive use, and leads to confusion in scripts. Here' a version that should work: ``` import time import datetime ... checktime = datetime.datetime.today() - datetime.timedelta(days=int(2)) checktime = checktime.timetuple() ... filetimesecs = os.pat...
11,211,650
I'm using Python 2.7 on Windows and I am writing a script that uses both time and datetime modules. I've done this before, but python seems to be touchy about having both modules loaded and the methods I've used before don't seem to be working. Here are the different syntax I've used and the errors I am currently getti...
2012/06/26
[ "https://Stackoverflow.com/questions/11211650", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1070061/" ]
You can use **as** while importing time. ``` import time as t from datetime import datetime ... t.sleep(2) ```
These two modules define some functions/types with the sasme names. The best way is to import them explicitly and use what you need: ``` import datetime import time datetime.datetime.today() # Datetime object for today time.time() # Current time ``` More generally, you can't just expect to blindly switch between `fr...
11,211,650
I'm using Python 2.7 on Windows and I am writing a script that uses both time and datetime modules. I've done this before, but python seems to be touchy about having both modules loaded and the methods I've used before don't seem to be working. Here are the different syntax I've used and the errors I am currently getti...
2012/06/26
[ "https://Stackoverflow.com/questions/11211650", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1070061/" ]
Don't use `from ... import *` – this is a convenience syntax for interactive use, and leads to confusion in scripts. Here' a version that should work: ``` import time import datetime ... checktime = datetime.datetime.today() - datetime.timedelta(days=int(2)) checktime = checktime.timetuple() ... filetimesecs = os.pat...
Never use imports of the form `from x import *` because you don't know what you'll be getting. In this case the second import is wiping out some symbols from the first import because they have the same name. Either use `import x` and qualify everything you use from that module with `x.y`, or import only selected items...
11,211,650
I'm using Python 2.7 on Windows and I am writing a script that uses both time and datetime modules. I've done this before, but python seems to be touchy about having both modules loaded and the methods I've used before don't seem to be working. Here are the different syntax I've used and the errors I am currently getti...
2012/06/26
[ "https://Stackoverflow.com/questions/11211650", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1070061/" ]
Don't use `from ... import *` – this is a convenience syntax for interactive use, and leads to confusion in scripts. Here' a version that should work: ``` import time import datetime ... checktime = datetime.datetime.today() - datetime.timedelta(days=int(2)) checktime = checktime.timetuple() ... filetimesecs = os.pat...
There can be name conflicts when you just do import \*. I strongly recommend not to do that. ``` import time import datetime . . . . time.sleep(60) ``` You can also do the following if you don't want to prepend all function with `time.` or `datetime.` ``` from datetime import X, Y from time import Z, W X.somethi...
11,211,650
I'm using Python 2.7 on Windows and I am writing a script that uses both time and datetime modules. I've done this before, but python seems to be touchy about having both modules loaded and the methods I've used before don't seem to be working. Here are the different syntax I've used and the errors I am currently getti...
2012/06/26
[ "https://Stackoverflow.com/questions/11211650", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1070061/" ]
These two modules define some functions/types with the sasme names. The best way is to import them explicitly and use what you need: ``` import datetime import time datetime.datetime.today() # Datetime object for today time.time() # Current time ``` More generally, you can't just expect to blindly switch between `fr...
There can be name conflicts when you just do import \*. I strongly recommend not to do that. ``` import time import datetime . . . . time.sleep(60) ``` You can also do the following if you don't want to prepend all function with `time.` or `datetime.` ``` from datetime import X, Y from time import Z, W X.somethi...
11,211,650
I'm using Python 2.7 on Windows and I am writing a script that uses both time and datetime modules. I've done this before, but python seems to be touchy about having both modules loaded and the methods I've used before don't seem to be working. Here are the different syntax I've used and the errors I am currently getti...
2012/06/26
[ "https://Stackoverflow.com/questions/11211650", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1070061/" ]
My guess is that you have conflicts because of your `from something import *`. Since `datetime` exports a `time` class, this could conflict with the `time` module. Conclusion: don't use `import *` ;-)
### Insted of that you can make it simple ```py from datetime import * from time import * ```
11,211,650
I'm using Python 2.7 on Windows and I am writing a script that uses both time and datetime modules. I've done this before, but python seems to be touchy about having both modules loaded and the methods I've used before don't seem to be working. Here are the different syntax I've used and the errors I am currently getti...
2012/06/26
[ "https://Stackoverflow.com/questions/11211650", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1070061/" ]
Never use imports of the form `from x import *` because you don't know what you'll be getting. In this case the second import is wiping out some symbols from the first import because they have the same name. Either use `import x` and qualify everything you use from that module with `x.y`, or import only selected items...
There can be name conflicts when you just do import \*. I strongly recommend not to do that. ``` import time import datetime . . . . time.sleep(60) ``` You can also do the following if you don't want to prepend all function with `time.` or `datetime.` ``` from datetime import X, Y from time import Z, W X.somethi...
11,211,650
I'm using Python 2.7 on Windows and I am writing a script that uses both time and datetime modules. I've done this before, but python seems to be touchy about having both modules loaded and the methods I've used before don't seem to be working. Here are the different syntax I've used and the errors I am currently getti...
2012/06/26
[ "https://Stackoverflow.com/questions/11211650", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1070061/" ]
Don't use `from ... import *` – this is a convenience syntax for interactive use, and leads to confusion in scripts. Here' a version that should work: ``` import time import datetime ... checktime = datetime.datetime.today() - datetime.timedelta(days=int(2)) checktime = checktime.timetuple() ... filetimesecs = os.pat...
``` from time import * import time as t from datetime import * import datetime as dt secs=69 print (dt.timedelta(seconds=secs)) now = datetime.now() #Time current_time = now.strftime("%H:%M:%S") print("Current Time =", current_time) #converting conversion = dt.timedelta(seconds=secs) print("Converted: ", conversion...
11,211,650
I'm using Python 2.7 on Windows and I am writing a script that uses both time and datetime modules. I've done this before, but python seems to be touchy about having both modules loaded and the methods I've used before don't seem to be working. Here are the different syntax I've used and the errors I am currently getti...
2012/06/26
[ "https://Stackoverflow.com/questions/11211650", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1070061/" ]
You can use **as** while importing time. ``` import time as t from datetime import datetime ... t.sleep(2) ```
There can be name conflicts when you just do import \*. I strongly recommend not to do that. ``` import time import datetime . . . . time.sleep(60) ``` You can also do the following if you don't want to prepend all function with `time.` or `datetime.` ``` from datetime import X, Y from time import Z, W X.somethi...
11,211,650
I'm using Python 2.7 on Windows and I am writing a script that uses both time and datetime modules. I've done this before, but python seems to be touchy about having both modules loaded and the methods I've used before don't seem to be working. Here are the different syntax I've used and the errors I am currently getti...
2012/06/26
[ "https://Stackoverflow.com/questions/11211650", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1070061/" ]
Don't use `from ... import *` – this is a convenience syntax for interactive use, and leads to confusion in scripts. Here' a version that should work: ``` import time import datetime ... checktime = datetime.datetime.today() - datetime.timedelta(days=int(2)) checktime = checktime.timetuple() ... filetimesecs = os.pat...
As everyone rightly mentioned in above comments, this problem was due to: ``` from datetime import * ``` But I was facing the issue where I wrote this in a file and tried to run and since it wasn't working I removed that entire import statement from that file but when I tried to run it again, it was still trowing sa...
19,034,959
I need to install some modules for python on Ubuntu Linux 12.04. I want pygame and livewires but I'm not sure how to install them. I have the py file for livewires, which has been specially edited (from a book I'm reading) and I want to install it but I'm not sure how to, I also want to install pygame.
2013/09/26
[ "https://Stackoverflow.com/questions/19034959", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2765940/" ]
There are two nice ways to install Python packages on Ubuntu (and similar Linux systems): ``` sudo apt-get install python-pygame ``` to use the Debian/Ubuntu package manager APT. This only works for packages that are shipped by Ubuntu, unless you change the APT configuration, and in particular there seems to be no P...
You can use several approaches: 1 - Download the package by yourself. This is what I use the most. If the package follows the specifications, you should be able to install it by moving to its uncompressed folder and typing in the console: ``` python setup.py build python setup.py install ``` 2 - Use pip. Pip is pre...
19,034,959
I need to install some modules for python on Ubuntu Linux 12.04. I want pygame and livewires but I'm not sure how to install them. I have the py file for livewires, which has been specially edited (from a book I'm reading) and I want to install it but I'm not sure how to, I also want to install pygame.
2013/09/26
[ "https://Stackoverflow.com/questions/19034959", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2765940/" ]
Try to install pip. ``` apt-get install python-pip pip install pygame ```
You can use several approaches: 1 - Download the package by yourself. This is what I use the most. If the package follows the specifications, you should be able to install it by moving to its uncompressed folder and typing in the console: ``` python setup.py build python setup.py install ``` 2 - Use pip. Pip is pre...
19,034,959
I need to install some modules for python on Ubuntu Linux 12.04. I want pygame and livewires but I'm not sure how to install them. I have the py file for livewires, which has been specially edited (from a book I'm reading) and I want to install it but I'm not sure how to, I also want to install pygame.
2013/09/26
[ "https://Stackoverflow.com/questions/19034959", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2765940/" ]
You can use several approaches: 1 - Download the package by yourself. This is what I use the most. If the package follows the specifications, you should be able to install it by moving to its uncompressed folder and typing in the console: ``` python setup.py build python setup.py install ``` 2 - Use pip. Pip is pre...
``` curl -O http://python-distribute.org/distribute_setup.py sudo python distribute_setup.py sudo easy_install pygame ``` [Differences between distribute, distutils, setuptools and distutils2](https://stackoverflow.com/questions/6344076/differences-between-distribute-distutils-setuptools-and-distutils2)
19,034,959
I need to install some modules for python on Ubuntu Linux 12.04. I want pygame and livewires but I'm not sure how to install them. I have the py file for livewires, which has been specially edited (from a book I'm reading) and I want to install it but I'm not sure how to, I also want to install pygame.
2013/09/26
[ "https://Stackoverflow.com/questions/19034959", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2765940/" ]
There are two nice ways to install Python packages on Ubuntu (and similar Linux systems): ``` sudo apt-get install python-pygame ``` to use the Debian/Ubuntu package manager APT. This only works for packages that are shipped by Ubuntu, unless you change the APT configuration, and in particular there seems to be no P...
Try to install pip. ``` apt-get install python-pip pip install pygame ```
19,034,959
I need to install some modules for python on Ubuntu Linux 12.04. I want pygame and livewires but I'm not sure how to install them. I have the py file for livewires, which has been specially edited (from a book I'm reading) and I want to install it but I'm not sure how to, I also want to install pygame.
2013/09/26
[ "https://Stackoverflow.com/questions/19034959", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2765940/" ]
There are two nice ways to install Python packages on Ubuntu (and similar Linux systems): ``` sudo apt-get install python-pygame ``` to use the Debian/Ubuntu package manager APT. This only works for packages that are shipped by Ubuntu, unless you change the APT configuration, and in particular there seems to be no P...
``` curl -O http://python-distribute.org/distribute_setup.py sudo python distribute_setup.py sudo easy_install pygame ``` [Differences between distribute, distutils, setuptools and distutils2](https://stackoverflow.com/questions/6344076/differences-between-distribute-distutils-setuptools-and-distutils2)
19,034,959
I need to install some modules for python on Ubuntu Linux 12.04. I want pygame and livewires but I'm not sure how to install them. I have the py file for livewires, which has been specially edited (from a book I'm reading) and I want to install it but I'm not sure how to, I also want to install pygame.
2013/09/26
[ "https://Stackoverflow.com/questions/19034959", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2765940/" ]
There are two nice ways to install Python packages on Ubuntu (and similar Linux systems): ``` sudo apt-get install python-pygame ``` to use the Debian/Ubuntu package manager APT. This only works for packages that are shipped by Ubuntu, unless you change the APT configuration, and in particular there seems to be no P...
It depends on the Ubuntu version and the IDE you are using. Ubuntu 15 and older come with Python 2.7 and Ubuntu 16.04 comes with both Python 2.7 and 3.5. Now based on the IDE you are using there are several ways to do this. Let`s say you only installed Spyder from Ubuntu app store or installed Jupyter. In other words ...
19,034,959
I need to install some modules for python on Ubuntu Linux 12.04. I want pygame and livewires but I'm not sure how to install them. I have the py file for livewires, which has been specially edited (from a book I'm reading) and I want to install it but I'm not sure how to, I also want to install pygame.
2013/09/26
[ "https://Stackoverflow.com/questions/19034959", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2765940/" ]
Try to install pip. ``` apt-get install python-pip pip install pygame ```
``` curl -O http://python-distribute.org/distribute_setup.py sudo python distribute_setup.py sudo easy_install pygame ``` [Differences between distribute, distutils, setuptools and distutils2](https://stackoverflow.com/questions/6344076/differences-between-distribute-distutils-setuptools-and-distutils2)
19,034,959
I need to install some modules for python on Ubuntu Linux 12.04. I want pygame and livewires but I'm not sure how to install them. I have the py file for livewires, which has been specially edited (from a book I'm reading) and I want to install it but I'm not sure how to, I also want to install pygame.
2013/09/26
[ "https://Stackoverflow.com/questions/19034959", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2765940/" ]
Try to install pip. ``` apt-get install python-pip pip install pygame ```
It depends on the Ubuntu version and the IDE you are using. Ubuntu 15 and older come with Python 2.7 and Ubuntu 16.04 comes with both Python 2.7 and 3.5. Now based on the IDE you are using there are several ways to do this. Let`s say you only installed Spyder from Ubuntu app store or installed Jupyter. In other words ...
19,034,959
I need to install some modules for python on Ubuntu Linux 12.04. I want pygame and livewires but I'm not sure how to install them. I have the py file for livewires, which has been specially edited (from a book I'm reading) and I want to install it but I'm not sure how to, I also want to install pygame.
2013/09/26
[ "https://Stackoverflow.com/questions/19034959", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2765940/" ]
It depends on the Ubuntu version and the IDE you are using. Ubuntu 15 and older come with Python 2.7 and Ubuntu 16.04 comes with both Python 2.7 and 3.5. Now based on the IDE you are using there are several ways to do this. Let`s say you only installed Spyder from Ubuntu app store or installed Jupyter. In other words ...
``` curl -O http://python-distribute.org/distribute_setup.py sudo python distribute_setup.py sudo easy_install pygame ``` [Differences between distribute, distutils, setuptools and distutils2](https://stackoverflow.com/questions/6344076/differences-between-distribute-distutils-setuptools-and-distutils2)
54,396,228
I am trying to build a chat app with Django but when I try to run it I get this error ``` No application configured for scope type 'websocket' ``` my routing.py file is ``` from channels.auth import AuthMiddlewareStack from channels.routing import ProtocolTypeRouter , URLRouter import chat.routing application = ...
2019/01/28
[ "https://Stackoverflow.com/questions/54396228", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10974783/" ]
Your xpath can be more specific, would suggest you go with incremental approach, first try with: ``` driver.find_element_by_xpath('//*[@id="form1"]//div[@class="screen-group-content"]') ``` If above returns True ``` driver.find_element_by_xpath('//*[@id="form1"]//div[@class="screen-group-content"]//table[@class="a...
did you have try using regular expressions? Using **Selenium**: ``` import re from selenium import webdriver #n = webdriver.Firefox() or n.webdriver.Chrome() n.get_url( your_url ) html_source_code = str(n.page_source) # Using a regular expression # The element that you want to fetch/collect # will be inside of t...
54,396,228
I am trying to build a chat app with Django but when I try to run it I get this error ``` No application configured for scope type 'websocket' ``` my routing.py file is ``` from channels.auth import AuthMiddlewareStack from channels.routing import ProtocolTypeRouter , URLRouter import chat.routing application = ...
2019/01/28
[ "https://Stackoverflow.com/questions/54396228", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10974783/" ]
Your xpath can be more specific, would suggest you go with incremental approach, first try with: ``` driver.find_element_by_xpath('//*[@id="form1"]//div[@class="screen-group-content"]') ``` If above returns True ``` driver.find_element_by_xpath('//*[@id="form1"]//div[@class="screen-group-content"]//table[@class="a...
The table is in an iFrame. You have to select it. Following [this](https://stackoverflow.com/questions/48656659/how-can-i-parse-table-data-from-website-using-selenium), I edited the code as follows: ``` wait = WebDriverWait(driver, 10) wait.until(eConds.frame_to_be_available_and_switch_to_it((wdBy.CSS_SELECTOR, "ifram...
54,396,228
I am trying to build a chat app with Django but when I try to run it I get this error ``` No application configured for scope type 'websocket' ``` my routing.py file is ``` from channels.auth import AuthMiddlewareStack from channels.routing import ProtocolTypeRouter , URLRouter import chat.routing application = ...
2019/01/28
[ "https://Stackoverflow.com/questions/54396228", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10974783/" ]
The table is in an iFrame. You have to select it. Following [this](https://stackoverflow.com/questions/48656659/how-can-i-parse-table-data-from-website-using-selenium), I edited the code as follows: ``` wait = WebDriverWait(driver, 10) wait.until(eConds.frame_to_be_available_and_switch_to_it((wdBy.CSS_SELECTOR, "ifram...
did you have try using regular expressions? Using **Selenium**: ``` import re from selenium import webdriver #n = webdriver.Firefox() or n.webdriver.Chrome() n.get_url( your_url ) html_source_code = str(n.page_source) # Using a regular expression # The element that you want to fetch/collect # will be inside of t...
21,318,968
I have a textfield in a database that contains the results of a python `json.dumps(list_instance)` operation. As such, the internal fields have a `u'` prefix, and break the browser's `JSON.parse()` function. An example of the JSON string is ``` "density": "{u'Penobscot': 40.75222856500098, u'Sagadahoc': 122.270833...
2014/01/23
[ "https://Stackoverflow.com/questions/21318968", "https://Stackoverflow.com", "https://Stackoverflow.com/users/214892/" ]
Updated solution: `replace(/u'/g, "'"));` => `replace(/u'(?=[^:]+')/g, "'"));`. Tested with the following: `"{u'Penobscot': 40.75222856500098, u'Sagadahoc': 122.27083333333333, u'Lincoln': 67.97977755308392, u'Kennebec': 123.12237174095878, u'Waldo': 48.02117802779616, u'Cumberland': 288.9285325791363, u'Piscataquis'...
a little bit old in the answer but if there is no way to change or access the server response try with: ``` var strExample = {'att1':u'something with u'}; strExample.replace(/u'[\}|\,]/g, "ç'").replace(/u'/g, "'").replace(/ç'/g, "u'"); //{'att1':'something with u'}; ``` The first replace will handle the u' that ar...
21,318,968
I have a textfield in a database that contains the results of a python `json.dumps(list_instance)` operation. As such, the internal fields have a `u'` prefix, and break the browser's `JSON.parse()` function. An example of the JSON string is ``` "density": "{u'Penobscot': 40.75222856500098, u'Sagadahoc': 122.270833...
2014/01/23
[ "https://Stackoverflow.com/questions/21318968", "https://Stackoverflow.com", "https://Stackoverflow.com/users/214892/" ]
Updated solution: `replace(/u'/g, "'"));` => `replace(/u'(?=[^:]+')/g, "'"));`. Tested with the following: `"{u'Penobscot': 40.75222856500098, u'Sagadahoc': 122.27083333333333, u'Lincoln': 67.97977755308392, u'Kennebec': 123.12237174095878, u'Waldo': 48.02117802779616, u'Cumberland': 288.9285325791363, u'Piscataquis'...
I had a similar issue and made this regex that found all of the u's even if the values had them too. ``` replace(/(?!\s|:)((u)(?='))/g, "") ``` The accepted answer, I found, missed these occurrences. I know the OP's doesn't have 'u' for the values and only for keys but thought this may be useful too :)
21,318,968
I have a textfield in a database that contains the results of a python `json.dumps(list_instance)` operation. As such, the internal fields have a `u'` prefix, and break the browser's `JSON.parse()` function. An example of the JSON string is ``` "density": "{u'Penobscot': 40.75222856500098, u'Sagadahoc': 122.270833...
2014/01/23
[ "https://Stackoverflow.com/questions/21318968", "https://Stackoverflow.com", "https://Stackoverflow.com/users/214892/" ]
The accepted solution is wrong. Your code fails because that string is not valid JSON. Fixing the pseudo-JSON string by replacing it is wrong. What you have to do is fix the python code that is producing that broken JSON string, which I am pretty sure it is a str() or unicode() where there should be nothing. What you ...
a little bit old in the answer but if there is no way to change or access the server response try with: ``` var strExample = {'att1':u'something with u'}; strExample.replace(/u'[\}|\,]/g, "ç'").replace(/u'/g, "'").replace(/ç'/g, "u'"); //{'att1':'something with u'}; ``` The first replace will handle the u' that ar...
21,318,968
I have a textfield in a database that contains the results of a python `json.dumps(list_instance)` operation. As such, the internal fields have a `u'` prefix, and break the browser's `JSON.parse()` function. An example of the JSON string is ``` "density": "{u'Penobscot': 40.75222856500098, u'Sagadahoc': 122.270833...
2014/01/23
[ "https://Stackoverflow.com/questions/21318968", "https://Stackoverflow.com", "https://Stackoverflow.com/users/214892/" ]
The accepted solution is wrong. Your code fails because that string is not valid JSON. Fixing the pseudo-JSON string by replacing it is wrong. What you have to do is fix the python code that is producing that broken JSON string, which I am pretty sure it is a str() or unicode() where there should be nothing. What you ...
I had a similar issue and made this regex that found all of the u's even if the values had them too. ``` replace(/(?!\s|:)((u)(?='))/g, "") ``` The accepted answer, I found, missed these occurrences. I know the OP's doesn't have 'u' for the values and only for keys but thought this may be useful too :)
20,332,359
Im trying to use python's default logging module in a multiprocessing scenario. I've read: 1. [Python MultiProcess, Logging, Various Classes](https://stackoverflow.com/questions/17582155/python-multiprocess-logging-various-classes) 2. [Logging using multiprocessing](https://stackoverflow.com/questions/10665090/logging...
2013/12/02
[ "https://Stackoverflow.com/questions/20332359", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3057996/" ]
I'm coming late, so you probably don't need the answer anymore. The problem comes from the fact that you already have a handler set in your main process, and in your worker you are adding another one. This means that in your worker process, two handlers are in fact managing your data, the one in pushing the log to queu...
All your `Worker`s share the same root logger object (obtained in `Worker.__init__` -- the `getLogger` call always returns the same logger). However, every time you create a `Worker`, you add a handler (`QueueHandler`) to that logger. So if you create 10 Workers, you will have 10 (identical) handlers on your root logg...
20,332,359
Im trying to use python's default logging module in a multiprocessing scenario. I've read: 1. [Python MultiProcess, Logging, Various Classes](https://stackoverflow.com/questions/17582155/python-multiprocess-logging-various-classes) 2. [Logging using multiprocessing](https://stackoverflow.com/questions/10665090/logging...
2013/12/02
[ "https://Stackoverflow.com/questions/20332359", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3057996/" ]
I figured out a pretty simple workaround using monkeypatching. It probably isn't robust and I am not an expert with the logging module, but it seemed like the best solution for my situation. After trying some code-changes (to enable passing in an existing logger, from `multiprocess.get_logger()`) I didn't like how much...
All your `Worker`s share the same root logger object (obtained in `Worker.__init__` -- the `getLogger` call always returns the same logger). However, every time you create a `Worker`, you add a handler (`QueueHandler`) to that logger. So if you create 10 Workers, you will have 10 (identical) handlers on your root logg...
20,332,359
Im trying to use python's default logging module in a multiprocessing scenario. I've read: 1. [Python MultiProcess, Logging, Various Classes](https://stackoverflow.com/questions/17582155/python-multiprocess-logging-various-classes) 2. [Logging using multiprocessing](https://stackoverflow.com/questions/10665090/logging...
2013/12/02
[ "https://Stackoverflow.com/questions/20332359", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3057996/" ]
I'm coming late, so you probably don't need the answer anymore. The problem comes from the fact that you already have a handler set in your main process, and in your worker you are adding another one. This means that in your worker process, two handlers are in fact managing your data, the one in pushing the log to queu...
I figured out a pretty simple workaround using monkeypatching. It probably isn't robust and I am not an expert with the logging module, but it seemed like the best solution for my situation. After trying some code-changes (to enable passing in an existing logger, from `multiprocess.get_logger()`) I didn't like how much...
32,209,155
I'm working through <http://www.mypythonquiz.com>, and [question #45](http://www.mypythonquiz.com/question.php?qid=255) asks for the output of the following code: ``` confusion = {} confusion[1] = 1 confusion['1'] = 2 confusion[1.0] = 4 sum = 0 for k in confusion: sum += confusion[k] print sum ``` The output i...
2015/08/25
[ "https://Stackoverflow.com/questions/32209155", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2401331/" ]
First of all: the behaviour is documented explicitly in the docs for the [hash](https://docs.python.org/3.5/library/functions.html#hash) function: > > **`hash(object)`** > > > Return the hash value of the object (if it has one). Hash values are > integers. They are used to quickly compare dictionary keys during a ...
Frankly, the opposite is dangerous! `1 == 1.0`, so it's not improbable to imagine that if you had them point to different keys and tried to access them based on an evaluated number then you'd likely run into trouble with it because the ambiguity is hard to figure out. Dynamic typing means that the value is more import...
32,209,155
I'm working through <http://www.mypythonquiz.com>, and [question #45](http://www.mypythonquiz.com/question.php?qid=255) asks for the output of the following code: ``` confusion = {} confusion[1] = 1 confusion['1'] = 2 confusion[1.0] = 4 sum = 0 for k in confusion: sum += confusion[k] print sum ``` The output i...
2015/08/25
[ "https://Stackoverflow.com/questions/32209155", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2401331/" ]
In python: ``` 1==1.0 True ``` This is because of implicit casting However: ``` 1 is 1.0 False ``` I can see why automatic casting between `float` and `int` is handy, It is relatively safe to cast `int` into `float`, and yet there are other languages (e.g. go) that stay away from implicit casting. It is actuall...
I agree with others that it makes sense to treat `1` and `1.0` as the same in this context. Even if Python did treat them differently, it would probably be a bad idea to try to use `1` and `1.0` as distinct keys for a dictionary. On the other hand -- I have trouble thinking of a natural use-case for using `1.0` as an a...
32,209,155
I'm working through <http://www.mypythonquiz.com>, and [question #45](http://www.mypythonquiz.com/question.php?qid=255) asks for the output of the following code: ``` confusion = {} confusion[1] = 1 confusion['1'] = 2 confusion[1.0] = 4 sum = 0 for k in confusion: sum += confusion[k] print sum ``` The output i...
2015/08/25
[ "https://Stackoverflow.com/questions/32209155", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2401331/" ]
You should consider that the `dict` aims at storing data depending on the logical numeric value, not on how you represented it. The difference between `int`s and `float`s is indeed just an implementation detail and not conceptual. Ideally the only number type should be an arbitrary precision number with unbounded accu...
In python: ``` 1==1.0 True ``` This is because of implicit casting However: ``` 1 is 1.0 False ``` I can see why automatic casting between `float` and `int` is handy, It is relatively safe to cast `int` into `float`, and yet there are other languages (e.g. go) that stay away from implicit casting. It is actuall...
32,209,155
I'm working through <http://www.mypythonquiz.com>, and [question #45](http://www.mypythonquiz.com/question.php?qid=255) asks for the output of the following code: ``` confusion = {} confusion[1] = 1 confusion['1'] = 2 confusion[1.0] = 4 sum = 0 for k in confusion: sum += confusion[k] print sum ``` The output i...
2015/08/25
[ "https://Stackoverflow.com/questions/32209155", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2401331/" ]
Dictionaries are implemented with a hash table. To look up something in a hash table, you start at the position indicated by the hash value, then search different locations until you find a key value that's equal or an empty bucket. If you have two key values that compare equal but have different hashes, you may get i...
Frankly, the opposite is dangerous! `1 == 1.0`, so it's not improbable to imagine that if you had them point to different keys and tried to access them based on an evaluated number then you'd likely run into trouble with it because the ambiguity is hard to figure out. Dynamic typing means that the value is more import...
32,209,155
I'm working through <http://www.mypythonquiz.com>, and [question #45](http://www.mypythonquiz.com/question.php?qid=255) asks for the output of the following code: ``` confusion = {} confusion[1] = 1 confusion['1'] = 2 confusion[1.0] = 4 sum = 0 for k in confusion: sum += confusion[k] print sum ``` The output i...
2015/08/25
[ "https://Stackoverflow.com/questions/32209155", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2401331/" ]
You should consider that the `dict` aims at storing data depending on the logical numeric value, not on how you represented it. The difference between `int`s and `float`s is indeed just an implementation detail and not conceptual. Ideally the only number type should be an arbitrary precision number with unbounded accu...
Dictionaries are implemented with a hash table. To look up something in a hash table, you start at the position indicated by the hash value, then search different locations until you find a key value that's equal or an empty bucket. If you have two key values that compare equal but have different hashes, you may get i...
32,209,155
I'm working through <http://www.mypythonquiz.com>, and [question #45](http://www.mypythonquiz.com/question.php?qid=255) asks for the output of the following code: ``` confusion = {} confusion[1] = 1 confusion['1'] = 2 confusion[1.0] = 4 sum = 0 for k in confusion: sum += confusion[k] print sum ``` The output i...
2015/08/25
[ "https://Stackoverflow.com/questions/32209155", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2401331/" ]
In python: ``` 1==1.0 True ``` This is because of implicit casting However: ``` 1 is 1.0 False ``` I can see why automatic casting between `float` and `int` is handy, It is relatively safe to cast `int` into `float`, and yet there are other languages (e.g. go) that stay away from implicit casting. It is actuall...
Frankly, the opposite is dangerous! `1 == 1.0`, so it's not improbable to imagine that if you had them point to different keys and tried to access them based on an evaluated number then you'd likely run into trouble with it because the ambiguity is hard to figure out. Dynamic typing means that the value is more import...
32,209,155
I'm working through <http://www.mypythonquiz.com>, and [question #45](http://www.mypythonquiz.com/question.php?qid=255) asks for the output of the following code: ``` confusion = {} confusion[1] = 1 confusion['1'] = 2 confusion[1.0] = 4 sum = 0 for k in confusion: sum += confusion[k] print sum ``` The output i...
2015/08/25
[ "https://Stackoverflow.com/questions/32209155", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2401331/" ]
Dictionaries are implemented with a hash table. To look up something in a hash table, you start at the position indicated by the hash value, then search different locations until you find a key value that's equal or an empty bucket. If you have two key values that compare equal but have different hashes, you may get i...
I agree with others that it makes sense to treat `1` and `1.0` as the same in this context. Even if Python did treat them differently, it would probably be a bad idea to try to use `1` and `1.0` as distinct keys for a dictionary. On the other hand -- I have trouble thinking of a natural use-case for using `1.0` as an a...
32,209,155
I'm working through <http://www.mypythonquiz.com>, and [question #45](http://www.mypythonquiz.com/question.php?qid=255) asks for the output of the following code: ``` confusion = {} confusion[1] = 1 confusion['1'] = 2 confusion[1.0] = 4 sum = 0 for k in confusion: sum += confusion[k] print sum ``` The output i...
2015/08/25
[ "https://Stackoverflow.com/questions/32209155", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2401331/" ]
First of all: the behaviour is documented explicitly in the docs for the [hash](https://docs.python.org/3.5/library/functions.html#hash) function: > > **`hash(object)`** > > > Return the hash value of the object (if it has one). Hash values are > integers. They are used to quickly compare dictionary keys during a ...
You should consider that the `dict` aims at storing data depending on the logical numeric value, not on how you represented it. The difference between `int`s and `float`s is indeed just an implementation detail and not conceptual. Ideally the only number type should be an arbitrary precision number with unbounded accu...
32,209,155
I'm working through <http://www.mypythonquiz.com>, and [question #45](http://www.mypythonquiz.com/question.php?qid=255) asks for the output of the following code: ``` confusion = {} confusion[1] = 1 confusion['1'] = 2 confusion[1.0] = 4 sum = 0 for k in confusion: sum += confusion[k] print sum ``` The output i...
2015/08/25
[ "https://Stackoverflow.com/questions/32209155", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2401331/" ]
First of all: the behaviour is documented explicitly in the docs for the [hash](https://docs.python.org/3.5/library/functions.html#hash) function: > > **`hash(object)`** > > > Return the hash value of the object (if it has one). Hash values are > integers. They are used to quickly compare dictionary keys during a ...
Dictionaries are implemented with a hash table. To look up something in a hash table, you start at the position indicated by the hash value, then search different locations until you find a key value that's equal or an empty bucket. If you have two key values that compare equal but have different hashes, you may get i...
32,209,155
I'm working through <http://www.mypythonquiz.com>, and [question #45](http://www.mypythonquiz.com/question.php?qid=255) asks for the output of the following code: ``` confusion = {} confusion[1] = 1 confusion['1'] = 2 confusion[1.0] = 4 sum = 0 for k in confusion: sum += confusion[k] print sum ``` The output i...
2015/08/25
[ "https://Stackoverflow.com/questions/32209155", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2401331/" ]
First of all: the behaviour is documented explicitly in the docs for the [hash](https://docs.python.org/3.5/library/functions.html#hash) function: > > **`hash(object)`** > > > Return the hash value of the object (if it has one). Hash values are > integers. They are used to quickly compare dictionary keys during a ...
I agree with others that it makes sense to treat `1` and `1.0` as the same in this context. Even if Python did treat them differently, it would probably be a bad idea to try to use `1` and `1.0` as distinct keys for a dictionary. On the other hand -- I have trouble thinking of a natural use-case for using `1.0` as an a...
8,758,354
I've been using Python 3 for some months and I would like to create some GUIs. Does anyone know a good GUI Python GUI framework I could use for this? I don't want to use [TkInter](http://wiki.python.org/moin/TkInter) because I don't think it's very good. I also don't want to use [PyQt](http://wiki.python.org/moin/PyQt...
2012/01/06
[ "https://Stackoverflow.com/questions/8758354", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1114830/" ]
Hummm. . . . Hard to believe that Qt is forbidden for commercial use, as it has been created by some of the most important companies in the world . . . <http://qt.nokia.com/> Go for pyQt ;)
Pyside might be the best bet for you : <http://www.pyside.org/> It is basically Qt but under the LGPL license, which means you can use it in your commercial application.
8,758,354
I've been using Python 3 for some months and I would like to create some GUIs. Does anyone know a good GUI Python GUI framework I could use for this? I don't want to use [TkInter](http://wiki.python.org/moin/TkInter) because I don't think it's very good. I also don't want to use [PyQt](http://wiki.python.org/moin/PyQt...
2012/01/06
[ "https://Stackoverflow.com/questions/8758354", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1114830/" ]
First of all, I suggest you to stay with Python 2.x if you want to develop commercial products **at this moment**. This is because it is still the most widely available version of Python. Currently, Ubuntu ships with 2.7.2 and OS X Lion with 2.7.2, too. Regarding PyQT, you can use Nokia's re-implementation of it, [Py...
Hummm. . . . Hard to believe that Qt is forbidden for commercial use, as it has been created by some of the most important companies in the world . . . <http://qt.nokia.com/> Go for pyQt ;)
8,758,354
I've been using Python 3 for some months and I would like to create some GUIs. Does anyone know a good GUI Python GUI framework I could use for this? I don't want to use [TkInter](http://wiki.python.org/moin/TkInter) because I don't think it's very good. I also don't want to use [PyQt](http://wiki.python.org/moin/PyQt...
2012/01/06
[ "https://Stackoverflow.com/questions/8758354", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1114830/" ]
Hummm. . . . Hard to believe that Qt is forbidden for commercial use, as it has been created by some of the most important companies in the world . . . <http://qt.nokia.com/> Go for pyQt ;)
Well, If you feel Qts is not suitable(thats hard to belive either) you could switch to WxPython . It too has an good learning curve and can satisfy your commersial needs
8,758,354
I've been using Python 3 for some months and I would like to create some GUIs. Does anyone know a good GUI Python GUI framework I could use for this? I don't want to use [TkInter](http://wiki.python.org/moin/TkInter) because I don't think it's very good. I also don't want to use [PyQt](http://wiki.python.org/moin/PyQt...
2012/01/06
[ "https://Stackoverflow.com/questions/8758354", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1114830/" ]
First of all, I suggest you to stay with Python 2.x if you want to develop commercial products **at this moment**. This is because it is still the most widely available version of Python. Currently, Ubuntu ships with 2.7.2 and OS X Lion with 2.7.2, too. Regarding PyQT, you can use Nokia's re-implementation of it, [Py...
Pyside might be the best bet for you : <http://www.pyside.org/> It is basically Qt but under the LGPL license, which means you can use it in your commercial application.
8,758,354
I've been using Python 3 for some months and I would like to create some GUIs. Does anyone know a good GUI Python GUI framework I could use for this? I don't want to use [TkInter](http://wiki.python.org/moin/TkInter) because I don't think it's very good. I also don't want to use [PyQt](http://wiki.python.org/moin/PyQt...
2012/01/06
[ "https://Stackoverflow.com/questions/8758354", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1114830/" ]
You probably mean that **PyQt** can only be used for GPL projects. However, the equivalent [PySide](http://www.pyside.org "PySide") Python bindings for QT are LGPL, like QT itself, so you *can* use those; unfortunately, they only support Python 2.5/7 at the moment. If you don't mind being cross-platform, you can fall ...
Pyside might be the best bet for you : <http://www.pyside.org/> It is basically Qt but under the LGPL license, which means you can use it in your commercial application.
8,758,354
I've been using Python 3 for some months and I would like to create some GUIs. Does anyone know a good GUI Python GUI framework I could use for this? I don't want to use [TkInter](http://wiki.python.org/moin/TkInter) because I don't think it's very good. I also don't want to use [PyQt](http://wiki.python.org/moin/PyQt...
2012/01/06
[ "https://Stackoverflow.com/questions/8758354", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1114830/" ]
First of all, I suggest you to stay with Python 2.x if you want to develop commercial products **at this moment**. This is because it is still the most widely available version of Python. Currently, Ubuntu ships with 2.7.2 and OS X Lion with 2.7.2, too. Regarding PyQT, you can use Nokia's re-implementation of it, [Py...
You probably mean that **PyQt** can only be used for GPL projects. However, the equivalent [PySide](http://www.pyside.org "PySide") Python bindings for QT are LGPL, like QT itself, so you *can* use those; unfortunately, they only support Python 2.5/7 at the moment. If you don't mind being cross-platform, you can fall ...
8,758,354
I've been using Python 3 for some months and I would like to create some GUIs. Does anyone know a good GUI Python GUI framework I could use for this? I don't want to use [TkInter](http://wiki.python.org/moin/TkInter) because I don't think it's very good. I also don't want to use [PyQt](http://wiki.python.org/moin/PyQt...
2012/01/06
[ "https://Stackoverflow.com/questions/8758354", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1114830/" ]
First of all, I suggest you to stay with Python 2.x if you want to develop commercial products **at this moment**. This is because it is still the most widely available version of Python. Currently, Ubuntu ships with 2.7.2 and OS X Lion with 2.7.2, too. Regarding PyQT, you can use Nokia's re-implementation of it, [Py...
Well, If you feel Qts is not suitable(thats hard to belive either) you could switch to WxPython . It too has an good learning curve and can satisfy your commersial needs
8,758,354
I've been using Python 3 for some months and I would like to create some GUIs. Does anyone know a good GUI Python GUI framework I could use for this? I don't want to use [TkInter](http://wiki.python.org/moin/TkInter) because I don't think it's very good. I also don't want to use [PyQt](http://wiki.python.org/moin/PyQt...
2012/01/06
[ "https://Stackoverflow.com/questions/8758354", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1114830/" ]
You probably mean that **PyQt** can only be used for GPL projects. However, the equivalent [PySide](http://www.pyside.org "PySide") Python bindings for QT are LGPL, like QT itself, so you *can* use those; unfortunately, they only support Python 2.5/7 at the moment. If you don't mind being cross-platform, you can fall ...
Well, If you feel Qts is not suitable(thats hard to belive either) you could switch to WxPython . It too has an good learning curve and can satisfy your commersial needs
68,935,814
I would like to know how to run the following cURL request using python (I'm working in Jupyter notebook): ``` curl -i -X GET "https://graph.facebook.com/{graph-api-version}/oauth/access_token? grant_type=fb_exchange_token& client_id={app-id}& client_secret={app-secret}& fb_exchange_token={your-access-toke...
2021/08/26
[ "https://Stackoverflow.com/questions/68935814", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16757711/" ]
`decode(String)` returns a `byte[]`, you need to convert that to a string using a `String` constructor and not the `toString()` method: ```java byte[] bytes = java.util.Base64.getDecoder().decode(encodedstring); String s = new String(bytes, java.nio.charset.StandardCharsets.UTF_8); ```
It looks like you need mime decoder message ```js java.util.Base64.Decoder decoder = java.util.Base64.getMimeDecoder(); // Decoding MIME encoded message String dStr = new String(decoder.decode(encodedstring)); System.out.println("Decoded message: "+dStr); ```
58,706,091
I am using cplex .dll file in python to solve a well-formulated lp problem using pulp solver. Here is the code here model is pulp object created using pulp library ==================================================== When I run a.actualSolve(Model) I get following error from subprocess.py file. OSError: [WinError 19...
2019/11/05
[ "https://Stackoverflow.com/questions/58706091", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6369726/" ]
Like the error says, you need to put the closing curly brace on the same line as the subsequent block after the `else`: ``` if (err.status === 'not found') { cb({ statusCode: 404 }) return } else { // <--- now } is on same line as { cb({ statusCode: 500 }) return } ``` From an example from [the docs](https...
**Use below format when you face above error in typescript eslint.** ``` if (Logic1) { //content1 } else if (Logic2) { //content2 } else if (Logic3) { //content3 } else { //content4 } ```
6,369,697
When I run `python manage.py shell`, I can print out the python path ``` >>> import sys >>> sys.path ``` What should I type to introspect all my django settings ?
2011/06/16
[ "https://Stackoverflow.com/questions/6369697", "https://Stackoverflow.com", "https://Stackoverflow.com/users/450278/" ]
``` from django.conf import settings dir(settings) ``` and then choose attribute from what `dir(settings)` have shown you to say: ``` settings.name ``` where `name` is the attribute that is of your interest Alternatively: ``` settings.__dict__ ``` prints all the settings. But it prints also the module standard...
To show all django settings (including default settings not specified in your local settings file): ``` from django.conf import settings dir(settings) ```
6,369,697
When I run `python manage.py shell`, I can print out the python path ``` >>> import sys >>> sys.path ``` What should I type to introspect all my django settings ?
2011/06/16
[ "https://Stackoverflow.com/questions/6369697", "https://Stackoverflow.com", "https://Stackoverflow.com/users/450278/" ]
``` from django.conf import settings dir(settings) ``` and then choose attribute from what `dir(settings)` have shown you to say: ``` settings.name ``` where `name` is the attribute that is of your interest Alternatively: ``` settings.__dict__ ``` prints all the settings. But it prints also the module standard...
In case a newbie stumbles upon this question wanting to be spoon fed the way to print out the values for all settings: ``` def show_settings(): from django.conf import settings for name in dir(settings): print(name, getattr(settings, name)) ```
6,369,697
When I run `python manage.py shell`, I can print out the python path ``` >>> import sys >>> sys.path ``` What should I type to introspect all my django settings ?
2011/06/16
[ "https://Stackoverflow.com/questions/6369697", "https://Stackoverflow.com", "https://Stackoverflow.com/users/450278/" ]
``` from django.conf import settings dir(settings) ``` and then choose attribute from what `dir(settings)` have shown you to say: ``` settings.name ``` where `name` is the attribute that is of your interest Alternatively: ``` settings.__dict__ ``` prints all the settings. But it prints also the module standard...
I know that this is an old question, but with current versions of django (1.6+), you can accomplish this from the command line the following way: ``` python manage.py diffsettings --all ``` The result will show all of the settings including the defautls (denoted by ### in front of the settings name).
6,369,697
When I run `python manage.py shell`, I can print out the python path ``` >>> import sys >>> sys.path ``` What should I type to introspect all my django settings ?
2011/06/16
[ "https://Stackoverflow.com/questions/6369697", "https://Stackoverflow.com", "https://Stackoverflow.com/users/450278/" ]
``` from django.conf import settings dir(settings) ``` and then choose attribute from what `dir(settings)` have shown you to say: ``` settings.name ``` where `name` is the attribute that is of your interest Alternatively: ``` settings.__dict__ ``` prints all the settings. But it prints also the module standard...
In your shell, you can call Django's built-in [diffsettings](https://docs.djangoproject.com/en/2.1/ref/django-admin/#diffsettings): ``` from django.core.management.commands import diffsettings output = diffsettings.Command().handle(default=None, output="hash", all=False) ```
6,369,697
When I run `python manage.py shell`, I can print out the python path ``` >>> import sys >>> sys.path ``` What should I type to introspect all my django settings ?
2011/06/16
[ "https://Stackoverflow.com/questions/6369697", "https://Stackoverflow.com", "https://Stackoverflow.com/users/450278/" ]
I know that this is an old question, but with current versions of django (1.6+), you can accomplish this from the command line the following way: ``` python manage.py diffsettings --all ``` The result will show all of the settings including the defautls (denoted by ### in front of the settings name).
To show all django settings (including default settings not specified in your local settings file): ``` from django.conf import settings dir(settings) ```
6,369,697
When I run `python manage.py shell`, I can print out the python path ``` >>> import sys >>> sys.path ``` What should I type to introspect all my django settings ?
2011/06/16
[ "https://Stackoverflow.com/questions/6369697", "https://Stackoverflow.com", "https://Stackoverflow.com/users/450278/" ]
To show all django settings (including default settings not specified in your local settings file): ``` from django.conf import settings dir(settings) ```
In your shell, you can call Django's built-in [diffsettings](https://docs.djangoproject.com/en/2.1/ref/django-admin/#diffsettings): ``` from django.core.management.commands import diffsettings output = diffsettings.Command().handle(default=None, output="hash", all=False) ```
6,369,697
When I run `python manage.py shell`, I can print out the python path ``` >>> import sys >>> sys.path ``` What should I type to introspect all my django settings ?
2011/06/16
[ "https://Stackoverflow.com/questions/6369697", "https://Stackoverflow.com", "https://Stackoverflow.com/users/450278/" ]
I know that this is an old question, but with current versions of django (1.6+), you can accomplish this from the command line the following way: ``` python manage.py diffsettings --all ``` The result will show all of the settings including the defautls (denoted by ### in front of the settings name).
In case a newbie stumbles upon this question wanting to be spoon fed the way to print out the values for all settings: ``` def show_settings(): from django.conf import settings for name in dir(settings): print(name, getattr(settings, name)) ```
6,369,697
When I run `python manage.py shell`, I can print out the python path ``` >>> import sys >>> sys.path ``` What should I type to introspect all my django settings ?
2011/06/16
[ "https://Stackoverflow.com/questions/6369697", "https://Stackoverflow.com", "https://Stackoverflow.com/users/450278/" ]
In case a newbie stumbles upon this question wanting to be spoon fed the way to print out the values for all settings: ``` def show_settings(): from django.conf import settings for name in dir(settings): print(name, getattr(settings, name)) ```
In your shell, you can call Django's built-in [diffsettings](https://docs.djangoproject.com/en/2.1/ref/django-admin/#diffsettings): ``` from django.core.management.commands import diffsettings output = diffsettings.Command().handle(default=None, output="hash", all=False) ```
6,369,697
When I run `python manage.py shell`, I can print out the python path ``` >>> import sys >>> sys.path ``` What should I type to introspect all my django settings ?
2011/06/16
[ "https://Stackoverflow.com/questions/6369697", "https://Stackoverflow.com", "https://Stackoverflow.com/users/450278/" ]
I know that this is an old question, but with current versions of django (1.6+), you can accomplish this from the command line the following way: ``` python manage.py diffsettings --all ``` The result will show all of the settings including the defautls (denoted by ### in front of the settings name).
In your shell, you can call Django's built-in [diffsettings](https://docs.djangoproject.com/en/2.1/ref/django-admin/#diffsettings): ``` from django.core.management.commands import diffsettings output = diffsettings.Command().handle(default=None, output="hash", all=False) ```
8,114,826
Hi I'm working on converting perl to python for something to do. I've been looking at some code on hash tables in perl and I've come across a line of code that I really don't know how it does what it does in python. I know that it shifts the bit strings of page by 1 ``` %page_table = (); #page table is a h...
2011/11/13
[ "https://Stackoverflow.com/questions/8114826", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1044593/" ]
The only thing confusing is that page table is a hash of hashes. $page\_table{$v} contains a hashref to a hash that contains a key 'page' whose value is an integer. The loop bitshifts that integer but is not very clear perl code. Simpler would be: ``` foreach my $v (@ram) { $page_table{$v}->{page} >>= 1; } ``` N...
Woof! No wonder you want to try Python! Yes, Python can do this because Python dictionaries (what you'd call hashes in Perl) can contain other arrays or dictionaries without doing references to them. However, I **highly** suggest that you look into moving into object oriented programming. After looking at that assign...
8,114,826
Hi I'm working on converting perl to python for something to do. I've been looking at some code on hash tables in perl and I've come across a line of code that I really don't know how it does what it does in python. I know that it shifts the bit strings of page by 1 ``` %page_table = (); #page table is a h...
2011/11/13
[ "https://Stackoverflow.com/questions/8114826", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1044593/" ]
The only thing confusing is that page table is a hash of hashes. $page\_table{$v} contains a hashref to a hash that contains a key 'page' whose value is an integer. The loop bitshifts that integer but is not very clear perl code. Simpler would be: ``` foreach my $v (@ram) { $page_table{$v}->{page} >>= 1; } ``` N...
Here is what my [Pythonizer](https://github.com/snoopyjc/pythonizer) generates for that code: ``` #!/usr/bin/env python3 # Generated by "pythonizer -mV q8114826.pl" v0.974 run by snoopyjc on Thu Apr 21 23:35:38 2022 import perllib, builtins _str = lambda s: "" if s is None else str(s) perllib.init_package("main") num...
8,114,826
Hi I'm working on converting perl to python for something to do. I've been looking at some code on hash tables in perl and I've come across a line of code that I really don't know how it does what it does in python. I know that it shifts the bit strings of page by 1 ``` %page_table = (); #page table is a h...
2011/11/13
[ "https://Stackoverflow.com/questions/8114826", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1044593/" ]
Here is what my [Pythonizer](https://github.com/snoopyjc/pythonizer) generates for that code: ``` #!/usr/bin/env python3 # Generated by "pythonizer -mV q8114826.pl" v0.974 run by snoopyjc on Thu Apr 21 23:35:38 2022 import perllib, builtins _str = lambda s: "" if s is None else str(s) perllib.init_package("main") num...
Woof! No wonder you want to try Python! Yes, Python can do this because Python dictionaries (what you'd call hashes in Perl) can contain other arrays or dictionaries without doing references to them. However, I **highly** suggest that you look into moving into object oriented programming. After looking at that assign...
62,393,428
``` drivers available with me **python shell** '''In [2]: pyodbc.drivers()''' **Output:** **Out[2]: ['SQL Server']** code in settings.py django: **Settings.py in django** '''# Database # https://docs.djangoproject.com/en/2.2/ref/settings/#databases DATABASES = { 'default': { ...
2020/06/15
[ "https://Stackoverflow.com/questions/62393428", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13458554/" ]
Though the documentation suggests using the framework `SearchView`, I've always found that the support/androidx `SearchView` plays nicer with the library components – e.g., `AppCompatActivity`, `MaterialToolbar`, etc. – though I'm not sure exactly what causes these little glitches. Indeed, using `androidx.appcompat.wid...
the above method does not work for me. I don't know why but a tried this and succeed. Refer to the search hint icon through SearchView and set it's visibility to GONE: ``` ImageView icon = (ImageView) mSearchView.findViewById(androidx.appcompat.R.id.search_mag_icon); icon.setVisibility(View.GONE); ``` And then add t...
28,986,131
I need to load 1460 files into a list, from a folder with 163.360 files. I use the following python code to do this: ``` import os import glob Directory = 'C:\\Users\\Nicolai\\Desktop\\sealev\\dkss_all' stationName = '20002' filenames = glob.glob("dkss."+stationName+"*") ``` This has been running fine so far, but...
2015/03/11
[ "https://Stackoverflow.com/questions/28986131", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1972356/" ]
Presuming that `ls` on that same directory is just as slow, you can't reduce the total time needed for the directory listing operation. Filesystems are slow sometimes (which is why, yes, the operating system *does* cache directory entries). However, there actually *is* something you can do in your Python code: You can...
Yes, it is a caching thing. Your harddisk is a slow peripheral, reading 163.360 filenames from it can take some time. Yes, your operating system caches that kind of information for you. Python has to wait for that information to be loaded before it can filter out the matching filenames. You don't have to wait all that...
21,869,675
``` list_ = [(1, 'a'), (2, 'b'), (3, 'c')] item1 = 1 item2 = 'c' #hypothetical: assert list_.index_by_first_value(item1) == 0 assert list_.index_by_second_value(item2) == 2 ``` What would be the fastest way to emulate the `index_by_first/second_value` method in python? If you don't understand what's going on; if you...
2014/02/19
[ "https://Stackoverflow.com/questions/21869675", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3002473/" ]
At first, I thought along [the same lines as Nick T](https://stackoverflow.com/a/21869852/418413). Your method is fine if the number of tuples (N) is short. But of course a linear search is O(N). As the number of tuples increases, the time increases directly with it. You can get O(1) lookup time with a dict mapping the...
Searching a list is O(n). Convert it to a dictionary, then lookups take O(1). ``` >>> list_ = [(1, 'a'), (2, 'b'), (3, 'c')] >>> dict(list_) {1: 'a', 2: 'b', 3: 'c'} >>> dict((k, v) for v, k in list_) {'a': 1, 'c': 3, 'b': 2} ``` If you want the original index you could enumerate it: ``` >>> dict((kv[0], (i, kv[1])...
21,869,675
``` list_ = [(1, 'a'), (2, 'b'), (3, 'c')] item1 = 1 item2 = 'c' #hypothetical: assert list_.index_by_first_value(item1) == 0 assert list_.index_by_second_value(item2) == 2 ``` What would be the fastest way to emulate the `index_by_first/second_value` method in python? If you don't understand what's going on; if you...
2014/02/19
[ "https://Stackoverflow.com/questions/21869675", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3002473/" ]
Searching a list is O(n). Convert it to a dictionary, then lookups take O(1). ``` >>> list_ = [(1, 'a'), (2, 'b'), (3, 'c')] >>> dict(list_) {1: 'a', 2: 'b', 3: 'c'} >>> dict((k, v) for v, k in list_) {'a': 1, 'c': 3, 'b': 2} ``` If you want the original index you could enumerate it: ``` >>> dict((kv[0], (i, kv[1])...
@Nick T I think some time is wasted enumerating the list and then converting it to a dictionary, so even if it is an O(1) lookup for a dict, creating the dict in the first place is too costly to consider it a viable option for large lists. This is the test I used to determine it: ``` import time l = [(i, chr(i)) for...
21,869,675
``` list_ = [(1, 'a'), (2, 'b'), (3, 'c')] item1 = 1 item2 = 'c' #hypothetical: assert list_.index_by_first_value(item1) == 0 assert list_.index_by_second_value(item2) == 2 ``` What would be the fastest way to emulate the `index_by_first/second_value` method in python? If you don't understand what's going on; if you...
2014/02/19
[ "https://Stackoverflow.com/questions/21869675", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3002473/" ]
EDIT: Just kidding. As the lists grow longer it looks like the manual `for` loop takes less time. Updated to generate random lists via kojiro's method: Just some timing tests for your information while maintaining lists. The good thing about preserving list form versus a dictionary is that it's expansible to include t...
Searching a list is O(n). Convert it to a dictionary, then lookups take O(1). ``` >>> list_ = [(1, 'a'), (2, 'b'), (3, 'c')] >>> dict(list_) {1: 'a', 2: 'b', 3: 'c'} >>> dict((k, v) for v, k in list_) {'a': 1, 'c': 3, 'b': 2} ``` If you want the original index you could enumerate it: ``` >>> dict((kv[0], (i, kv[1])...
21,869,675
``` list_ = [(1, 'a'), (2, 'b'), (3, 'c')] item1 = 1 item2 = 'c' #hypothetical: assert list_.index_by_first_value(item1) == 0 assert list_.index_by_second_value(item2) == 2 ``` What would be the fastest way to emulate the `index_by_first/second_value` method in python? If you don't understand what's going on; if you...
2014/02/19
[ "https://Stackoverflow.com/questions/21869675", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3002473/" ]
At first, I thought along [the same lines as Nick T](https://stackoverflow.com/a/21869852/418413). Your method is fine if the number of tuples (N) is short. But of course a linear search is O(N). As the number of tuples increases, the time increases directly with it. You can get O(1) lookup time with a dict mapping the...
@Nick T I think some time is wasted enumerating the list and then converting it to a dictionary, so even if it is an O(1) lookup for a dict, creating the dict in the first place is too costly to consider it a viable option for large lists. This is the test I used to determine it: ``` import time l = [(i, chr(i)) for...