Q_Id int64 337 49.3M | CreationDate stringlengths 23 23 | Users Score int64 -42 1.15k | Other int64 0 1 | Python Basics and Environment int64 0 1 | System Administration and DevOps int64 0 1 | Tags stringlengths 6 105 | A_Id int64 518 72.5M | AnswerCount int64 1 64 | is_accepted bool 2
classes | Web Development int64 0 1 | GUI and Desktop Applications int64 0 1 | Answer stringlengths 6 11.6k | Available Count int64 1 31 | Q_Score int64 0 6.79k | Data Science and Machine Learning int64 0 1 | Question stringlengths 15 29k | Title stringlengths 11 150 | Score float64 -1 1.2 | Database and SQL int64 0 1 | Networking and APIs int64 0 1 | ViewCount int64 8 6.81M |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
20,277,537 | 2013-11-29T02:40:00.000 | 6 | 0 | 0 | 0 | python,django,nginx,gunicorn | 20,278,315 | 2 | true | 1 | 0 | When you hold down F5:
You've started hundreds of requests.
Those requests have filled your gunicorn request queue.
The request handlers have not been culled as soon as the connection drops.
Your latest requests are stuck in the queue behind all the previous requests.
Nginx times out.
For everyone.
Solutions:
Set up... | 1 | 8 | 0 | I'm trying to publish a Django application on the production server using Nginx + Gunicorn. When I doing a simple stress test on the server (holding the F5 key for a minute) the server returns a 504 Gateway Time-out error. Why does this happen? This error only appears for the user when doing multiple concurrent reque... | Django Nginx Gunicorn = 504 Timeout | 1.2 | 0 | 0 | 5,881 |
20,281,990 | 2013-11-29T09:12:00.000 | 0 | 0 | 1 | 0 | python,plugins,intellij-idea | 34,194,349 | 2 | false | 0 | 0 | may be my intellij version is different with you guys.
on Windows platform I fix this problem by:
1.File > Project Structure > Modules
2.on the module's dependencies panel,change the module SDK from JDK to python
3.done | 2 | 3 | 0 | I use intellij with python plugin.
when I want to import python libs like
import random
I got editor error.
No module named random less... (Ctrl+F1)
This inspection detects names that should resolve but don't. Due to dynamic dispatch and duck typing, this is possible in a limited but useful number of cases. T... | Intellij python no recoginiize lib | 0 | 0 | 0 | 2,375 |
20,281,990 | 2013-11-29T09:12:00.000 | 3 | 0 | 1 | 0 | python,plugins,intellij-idea | 25,123,680 | 2 | false | 0 | 0 | You may have fixed this by now, but I was having the same problem and finally solved it, so I figured I'd post the solution for anyone who came here by Googling/Binging the error message:
I went to File > Project Structure > Modules, highlighted the main module, then pressed the plus sign and then "Python" under "Frame... | 2 | 3 | 0 | I use intellij with python plugin.
when I want to import python libs like
import random
I got editor error.
No module named random less... (Ctrl+F1)
This inspection detects names that should resolve but don't. Due to dynamic dispatch and duck typing, this is possible in a limited but useful number of cases. T... | Intellij python no recoginiize lib | 0.291313 | 0 | 0 | 2,375 |
20,283,021 | 2013-11-29T10:00:00.000 | 1 | 1 | 0 | 0 | python,staruml | 45,105,412 | 1 | false | 0 | 0 | There is a simple possibility: Use PyCharm, a python IDE, which has an integrated UML generator (only in the pro version which is free for students). | 1 | 3 | 0 | Is there a way using StarUML for reverse engineering Python code to a class diagramm?
In the StarUML docs, they say there are modules for language support, but I couldn't find any further information about where and how to install and use.
Other UML tools I found didn't match my idea of how a diagramm should look like.... | StarUML for Python | 0.197375 | 0 | 0 | 2,332 |
20,284,421 | 2013-11-29T11:12:00.000 | 5 | 0 | 1 | 0 | python,interpreter | 20,284,486 | 1 | true | 0 | 0 | That's a feature of the terminal, not the interpreter. EscEsc is interpreted as Tab by your terminal, which your interpreter then further interprets as a completion request. | 1 | 1 | 0 | Today by accident I found pressing escesc in a python interpreter lists the contents of the directory the interpreter was started from. Stranger still is that the sequence needs to be performed twice for it to work initially but afterwards works every time.
I couldn't find this feature documented anywhere and I am wond... | python interpreter command inputs | 1.2 | 0 | 0 | 68 |
20,289,809 | 2013-11-29T16:18:00.000 | 1 | 0 | 0 | 0 | python,bash,upload,download,bandwidth | 20,290,664 | 1 | true | 0 | 0 | Just running a few wget's should easily saturate your download bandwidth.
For upload, you might set up a web server on your computer (carefully poking a hole through your firewall for it), and then connect to a web proxy (there are a few of these that'll anonymise your data) and back to your web server. Then connect t... | 1 | 0 | 0 | As the question explain, I would like to saturate my bandwidth. For download I had an idea:
Download a random file (5MB for example) in loop for n time using wget or urllib2.
Delete the file each completed download, with the same loop.
(For wget using a Bash script / For urllib2 using a Python script)
But, I have two... | How do I saturate my upload and download available bandwidth? | 1.2 | 0 | 1 | 1,937 |
20,291,176 | 2013-11-29T17:53:00.000 | 0 | 0 | 0 | 0 | python,list,google-app-engine,jinja2 | 20,301,699 | 2 | false | 1 | 0 | It sounds like you want to use itertools.product(list1, list2). This will create all combinations of list1 and list2.
For example, if list1 = [1,2] and list2 = [1,2,3] then itertools.products(list1,list2) = [ (1,1),(2,1),(3,1),(2,1),(2,2),(2,3)] | 1 | 0 | 0 | I am using Jinja2 template in python for Google App Engine. I need to iterate through 2 lists list1 and list2 in the same loop in the html file. I tried using zip as described in some of the posts but it is not working.
Something similar in C : for(i=0.j=0; I<len(list1) && j < len(list2) ; I++,j++)
Can anyone suggest ... | Iterate through 2 loops in GAE Python templates | 0 | 0 | 0 | 86 |
20,293,848 | 2013-11-29T21:54:00.000 | -1 | 0 | 1 | 1 | python,windows | 20,293,883 | 2 | false | 0 | 0 | You can use os.chdir(target_directory) to change your program's working directory before starting the external application. | 1 | 0 | 0 | For example I know this method: os.system("cmd") but it starts console in the directory of the script or in the dir of the interpreter, is there a way to gain control of this issue ? | how to start external system application in python specifying startup directory? | -0.099668 | 0 | 0 | 46 |
20,294,504 | 2013-11-29T23:04:00.000 | 1 | 0 | 1 | 0 | c#,java,python,path | 20,294,526 | 5 | true | 0 | 0 | A PATH is a file directory on your computer. If you need to install a programming language, you might need to put it in your system PATH variable. This means that the system looks to these files for different information, IE where the libraries for the code you are using are.
Hope that helped! | 1 | 6 | 0 | This is probably a rudimentary question but I am still kinda new to programming and I've wondered for awhile. I've done multiple projects in Python, C#, and Java, and when I try to use new libraries (especially for Python) people always say to make sure its in the right PATH and such. I just followed an online tutorial... | Significance of a PATH explained | 1.2 | 0 | 0 | 670 |
20,294,916 | 2013-11-29T23:58:00.000 | 13 | 0 | 0 | 0 | python,image,matlab,image-processing,gaussian | 20,295,628 | 1 | true | 0 | 0 | Successively applying multiple gaussian blurs to an image has the same effect as applying a single, larger gaussian blur, whose radius is the square root of the sum of the squares of the blur radii that were actually applied. In your case, s2 = sqrt(n*s1^2), and the blur radii is approximated as 3*si where i = 1, 2, wh... | 1 | 10 | 1 | I have two questions relating to repeated Gaussian blur.
What happens when we repeatedly apply gaussian blur to an image keeping the sigma and the radius same ?
And is it possible that after n iterations of repeatedly applying gaussian blur (sigma = s1) the image becomes the same as it would be on applying gaussian bl... | Repeated Gaussian Blur in Image Processing | 1.2 | 0 | 0 | 2,451 |
20,295,446 | 2013-11-30T01:18:00.000 | 0 | 0 | 0 | 0 | python,c,arrays,algorithm,sorting | 20,295,483 | 6 | false | 0 | 0 | Maybe use a nested for loop with the outside one looking at the ith point. then inside loop and calculate all the distances. After calculation use a native python sort for that row and then add it to the main 2d array. | 1 | 0 | 1 | Let's say I am given an array of n points(pair of coordinates). I want to generate a 2D array of points, where ith row has all elements sorted according to their distance from the ith point. There may be better and more efficient algorithms to get the final result, but for some reasons I want to do it by naive algorit... | Custom sorting in for loop | 0 | 0 | 0 | 202 |
20,295,723 | 2013-11-30T02:10:00.000 | 0 | 0 | 1 | 0 | python,oop | 20,295,792 | 2 | false | 0 | 0 | No, its the other way round.
But I can see why the doubt, these statements are confusing: you put self as first argument in instance methods, and you don't put it in static methods.
Note that although there is no need in naming that first parameter self, it is better to follow that convention as it is clearer to the re... | 1 | 0 | 0 | I am learning OOP, so my question on the two statements below probably seems very basic to many, but I just want to check in case I am using Python/OO lingo in the wrong way:
- You must explicitly define 'self' as the first parameter in every class method.
- Python's explicit requirement of self as the first parame... | Is this thinking correct on how 'self' identifies between instance and static members? | 0 | 0 | 0 | 60 |
20,295,961 | 2013-11-30T02:52:00.000 | 1 | 0 | 0 | 0 | python,algorithm,indexing,subset | 20,295,997 | 2 | false | 0 | 0 | I think you could do this by recursively narrowing down ranges, right? You know that all subsets beginning with a given integer will be adjacent, and that for a given first element d there will be (n - d) choose (k-1) of them. You can skip ahead as far as necessary in the virtual list of subsets until you're in the ran... | 1 | 2 | 1 | There are n choose k subsets of {1,2,...,n} of size k. These can be naturally ordered by sorting the elements and using the lexigraphical order.
Is there a fast way to determine the index of a given subset, i.e. its index in the sorted list of all subsets of size k? One method would be to create a dictionary from subs... | Indexing subsets of size k | 0.099668 | 0 | 0 | 397 |
20,296,712 | 2013-11-30T04:57:00.000 | 0 | 0 | 0 | 0 | python,pygame,lines,pixels | 20,298,727 | 2 | false | 0 | 1 | Using float you should get all points without duplications - but you need int.
Using int you always get duplications - int(0.1) == int(0.2) == int(0.3) == etc..
So you have to check if point is on your list. | 1 | 0 | 0 | Assuming I have a line with coordinates x1,y1 and x2,y2, and I know the length of the hypotenuse connecting those two points (thus also knowing the angle of rotation of the line through trig), if the line is 1 pixel thick how can I find every pixel on that line and store it to a list?
I first proposed the simple vector... | How can I find every pixel on a line with pygame? | 0 | 0 | 0 | 369 |
20,297,249 | 2013-11-30T06:18:00.000 | 77 | 0 | 0 | 0 | python,python-2.7 | 20,297,273 | 6 | true | 0 | 0 | bisect.bisect_left returns the leftmost place in the sorted list to insert the given element.
bisect.bisect_right returns the rightmost place in the sorted list to insert the given element.
An alternative question is when are they equivalent? By answering this, the answer to your question becomes clear.
They are equiva... | 3 | 41 | 0 | In my understanding, bisect_left and bisect_right are two different ways of doing the same thing: bisection, one coming from the left and the other coming from the right. Thus, it follows that they have the same result. Under what circumstances are these two not equal, i.e. when will they return different results, assu... | When are bisect_left and bisect_right not equal? | 1.2 | 0 | 0 | 39,432 |
20,297,249 | 2013-11-30T06:18:00.000 | 5 | 0 | 0 | 0 | python,python-2.7 | 33,235,082 | 6 | false | 0 | 0 | There are two things to be understood:
bisect.bisect and bisect.bisect_right work the same way. These return the rightmost position where the element can be inserted without breaking the order of elements. But as opposed to the above, bisect.bisect_left returns the leftmost position where the element can be inserted. U... | 3 | 41 | 0 | In my understanding, bisect_left and bisect_right are two different ways of doing the same thing: bisection, one coming from the left and the other coming from the right. Thus, it follows that they have the same result. Under what circumstances are these two not equal, i.e. when will they return different results, assu... | When are bisect_left and bisect_right not equal? | 0.16514 | 0 | 0 | 39,432 |
20,297,249 | 2013-11-30T06:18:00.000 | 12 | 0 | 0 | 0 | python,python-2.7 | 56,491,997 | 6 | false | 0 | 0 | To me this interpretation of bisect_left/bisect_right makes it more clear:
bisect_left returns the largest index to insert the element w.r.t. <
bisect_right returns the largest index to insert the element w.r.t. <=
For instance, if your data is [0, 0, 0] and you query for 0:
bisect_left returns index 0, because th... | 3 | 41 | 0 | In my understanding, bisect_left and bisect_right are two different ways of doing the same thing: bisection, one coming from the left and the other coming from the right. Thus, it follows that they have the same result. Under what circumstances are these two not equal, i.e. when will they return different results, assu... | When are bisect_left and bisect_right not equal? | 1 | 0 | 0 | 39,432 |
20,298,833 | 2013-11-30T09:53:00.000 | 1 | 1 | 0 | 0 | python,api,flask,arduino | 20,298,873 | 2 | false | 1 | 0 | Configure your WSGI container or its associated web server to only allow access to the Flask application from the IP address assigned to the Arduino's network interface. | 1 | 0 | 0 | I am basically writing an API in Python, using Flask, and I would like to restrict access to its endpoints so that only an entity, namely an Arduino, can have GET and POST access. How should I make this possible and what should I be looking for? | Restrict Python API access to single Arduino entity | 0.099668 | 0 | 0 | 78 |
20,303,411 | 2013-11-30T17:34:00.000 | 2 | 0 | 0 | 0 | python,sockets,multiplayer | 20,303,470 | 1 | true | 0 | 0 | I think you shouldn't even consider storing data like health client-side. Doing that will allow super-easy hacks to be made and the fact that the game is written in Python makes this a lot easier.
So I think you should keep these data in the server-side and use it from there. | 1 | 2 | 0 | I'm making a multilayer, text-based game in python sockets. The game is two player with a server which the clients connect to. I'm not sure whether to store player information (name, health, etc) on the server or on the client? What are the advantages of both? I was thinking about storing the information on the client ... | Should I store player information on server or client? | 1.2 | 0 | 1 | 162 |
20,304,863 | 2013-11-30T19:46:00.000 | 0 | 0 | 1 | 0 | python,database,python-2.7,beautifulsoup,mysql-python | 20,305,193 | 4 | false | 1 | 0 | You're doing it wrong!
Make an object that represents a row in the database, use __getitem__ to pretend it's a dictionary.
Put your database logic in that.
Don't go all noSQL unless your tables are not related. Just by being tables they are ideal for SQL! | 2 | 0 | 0 | I'm getting different information for a particular thing and i'm storing those information in a dictionary
e.g. {property1:val , property2:val, property3:val}
now I have several dictionary of this type (as I get many things ..each dictionary is for a thing)
now I want to save information in DB so there would be as ma... | How to save Information in Database using BeautifulSoup | 0 | 1 | 0 | 861 |
20,304,863 | 2013-11-30T19:46:00.000 | 0 | 0 | 1 | 0 | python,database,python-2.7,beautifulsoup,mysql-python | 20,305,076 | 4 | false | 1 | 0 | If your dictionaries all have the same keys, and each key always has the same value-type, it would be pretty straight-forward to map this to a relational database like MySQL.
Alternatively, you could convert your dictionaries to objects and use an ORM like SQLAlchemy to do the back-end work. | 2 | 0 | 0 | I'm getting different information for a particular thing and i'm storing those information in a dictionary
e.g. {property1:val , property2:val, property3:val}
now I have several dictionary of this type (as I get many things ..each dictionary is for a thing)
now I want to save information in DB so there would be as ma... | How to save Information in Database using BeautifulSoup | 0 | 1 | 0 | 861 |
20,305,033 | 2013-11-30T20:03:00.000 | 0 | 0 | 1 | 0 | python,multiprocessing | 20,305,232 | 3 | false | 0 | 0 | You could touch all your .py's, and then force an import.
But why do you want to do this? | 2 | 3 | 0 | I'm developing an scientific python application that uses multiprocessing and process pools. Sometimes I make a mistake and fork bomb myself. This causes my laptop to freeze and I need to do a hard reset. However, when I load again my python installation appears to be corrupted. I get strange errors on basic import... | How to force python to ignore or recreate pyc/pyo files? | 0 | 0 | 0 | 2,173 |
20,305,033 | 2013-11-30T20:03:00.000 | 0 | 0 | 1 | 0 | python,multiprocessing | 22,438,305 | 3 | false | 0 | 0 | One main use case I see in addition is when you work out of a git repository and switch forth and back on branches. .py files might get checked out with different content but with older time stamp. There you have an issue if you don't force the re-creation of the .pyc files one way or the other.
CKol | 2 | 3 | 0 | I'm developing an scientific python application that uses multiprocessing and process pools. Sometimes I make a mistake and fork bomb myself. This causes my laptop to freeze and I need to do a hard reset. However, when I load again my python installation appears to be corrupted. I get strange errors on basic import... | How to force python to ignore or recreate pyc/pyo files? | 0 | 0 | 0 | 2,173 |
20,306,249 | 2013-11-30T22:13:00.000 | 0 | 1 | 1 | 0 | python,json,unicode,utf-8 | 20,464,991 | 2 | false | 0 | 0 | Well, since you won't post your solution as an answer, I will. This question should not be left showing no answer.
jsonEncoder has an option ensure_ascii.
If ensure_ascii is True (the default), all non-ASCII characters in the output are escaped with \uXXXX sequences, and the results are str instances consisting of ASCI... | 2 | 2 | 0 | I'm using twitter python library to fetch some tweets from a public stream. The library fetches tweets in json format and converts them to python structures. What I'm trying to do is to directly get the json string and write it to a file. Inside the twitter library it first reads a network socket and applies .decode('u... | Python unicode file writing | 0 | 0 | 1 | 984 |
20,306,249 | 2013-11-30T22:13:00.000 | 2 | 1 | 1 | 0 | python,json,unicode,utf-8 | 20,528,987 | 2 | true | 0 | 0 | jsonEncoder has an option ensure_ascii
If ensure_ascii is True (the default), all non-ASCII characters in the
output are escaped with \uXXXX sequences, and the results are str
instances consisting of ASCII characters only.
Make it False and the problem will go away. | 2 | 2 | 0 | I'm using twitter python library to fetch some tweets from a public stream. The library fetches tweets in json format and converts them to python structures. What I'm trying to do is to directly get the json string and write it to a file. Inside the twitter library it first reads a network socket and applies .decode('u... | Python unicode file writing | 1.2 | 0 | 1 | 984 |
20,308,097 | 2013-12-01T02:33:00.000 | 4 | 0 | 0 | 0 | python,mysql,mysql-python,pythonanywhere | 20,309,286 | 1 | true | 1 | 0 | It normally because your mysql network connect be disconnected, may by your network gateway/router, so you have two options. One is always build a mysql connect before every query (not using connect pool etc). Second is try and catch this error, then get connect and query db again. | 1 | 2 | 0 | I am hosting a web app at pythonanywhere.com and experiencing a strange problem. Every half-hour or so I am getting the OperationalError: (2006, 'MySQL server has gone away'). However, if I resave my wsgi.py file, the error disappears. And then appears again some half-an-hour later...
During the loading of the main pag... | Periodic OperationalError: (2006, 'MySQL server has gone away') | 1.2 | 1 | 0 | 2,432 |
20,308,674 | 2013-12-01T04:17:00.000 | 0 | 0 | 0 | 0 | importerror,qpython | 31,173,939 | 2 | false | 1 | 1 | To install _csv or any other module, follow these steps. Here's what I did to install websocket (and all of its dependencies):
To install websocket on the phone:
Start QPython
Click the big button
Select “run local script”
Select “pip_console.py”
Type “pip install websocket” | 2 | 0 | 1 | I put goog_appengine inside android located at /mnt/sdcard
I also put wsgiref folder at same location.
from Qpython I manage to "send control key" + "d"
I got sh $
I put command like the ff:
"$python /mnt/sdcard/google_appengine/appcfg.py"
But Igot ImportError: no module _csv
I feel putting these is not same architect... | ImportError: No module named _csv . Qpython for android logs | 0 | 0 | 0 | 840 |
20,308,674 | 2013-12-01T04:17:00.000 | 0 | 0 | 0 | 0 | importerror,qpython | 21,482,814 | 2 | false | 1 | 1 | You can install _csv from QPython's system. ( You can find system icon in qpython's new version 0.9.6.2 ) | 2 | 0 | 1 | I put goog_appengine inside android located at /mnt/sdcard
I also put wsgiref folder at same location.
from Qpython I manage to "send control key" + "d"
I got sh $
I put command like the ff:
"$python /mnt/sdcard/google_appengine/appcfg.py"
But Igot ImportError: no module _csv
I feel putting these is not same architect... | ImportError: No module named _csv . Qpython for android logs | 0 | 0 | 0 | 840 |
20,308,788 | 2013-12-01T04:41:00.000 | 1 | 0 | 0 | 0 | python,django | 20,308,829 | 2 | false | 1 | 0 | The views.py must be in the same folder as in the urls.py. If not, while importing the views.py, its better to specify the exact path of the views.py, from the SYS_PATH of the project (from the folder where you have the manage.py file), which will help | 1 | 1 | 0 | I have a Django project that I wrote. I am testing it on the development server. It is saying that there is no module named views, even though the file views.py is one level higher than it in the directory views. Why is this? Does the views.py need to be in the same folder as the urls.py? Is that causing this? | Why does Django say there is no module named views? | 0.099668 | 0 | 0 | 166 |
20,311,225 | 2013-12-01T10:36:00.000 | 3 | 0 | 1 | 0 | python,python-2.7,argparse,command-line-arguments | 20,314,797 | 1 | false | 0 | 0 | Your best choice is to test for the presence of various combinations after parse_args and use parser.error to issue an argparse compatible error message. And write your own usage line. And make sure the defaults clearly indicate whether an option has been parsed or not.
If you can change the -a and -e options to comm... | 1 | 0 | 0 | I am using python2.7 and argparse for my script. I am executing script as below:
python2.7 script.py -a valuefora -b valueforb -c valueforc -d valueford
Now what I want is that,
if option -a is given, then only -b, -c, -d options should be asked.
In addition to above, I also want to make this group -a -b -c -d as ... | argparse: how to make group of options required only as group | 0.53705 | 0 | 0 | 348 |
20,312,814 | 2013-12-01T13:48:00.000 | 1 | 0 | 1 | 0 | python,ipython | 20,312,836 | 2 | false | 0 | 0 | Have you tried the %save magic:
Save a set of lines or a macro to a given filename. | 1 | 0 | 0 | I've written code and many functions inside IPython and now I want to export them to a file in a structured way as in a legible script.py. Is there any mechanism in Ipython to provide such an opportunity? | Save the sequence of the written code to an export file in IPython? | 0.099668 | 0 | 0 | 85 |
20,314,048 | 2013-12-01T15:55:00.000 | 2 | 1 | 0 | 0 | python,web,amazon-web-services,server-communication | 20,316,557 | 2 | false | 0 | 0 | Since you are already using aws, for something like this you couldconsider using AWS SQS to add a queue between the two hosts and communicate thru it instead of directly.
Using SQS, it would be easy to write a script to add messages to the SQS queue when something needs to be run on the other host, and equally easy fo... | 1 | 2 | 0 | I have two web hosts. One with a standard shared hosting provider, and the other: AWS Free Tier. I would like for these two servers to be able to communicate with one another. Basically, I would like the shared server to send some information to the AWS server, causing the AWS server to run certain scripts.
I am famili... | What options are there to allow one server to send information to another server? | 0.197375 | 0 | 1 | 43 |
20,315,057 | 2013-12-01T17:29:00.000 | 3 | 0 | 0 | 0 | python,xml,openerp,overwrite | 20,322,373 | 1 | true | 1 | 0 | yes you can. you just need to create a module with two files. one is __openerp__.py with correct dependency to the base modules and an xml file for updating the menu name. | 1 | 2 | 0 | I want to change an openerp module menu name.
I know how to do it, i'ts actually pretty easy, but this one is a core module sale and i don't want to touch it's code, because of updates issues and stuff.
So, i'll need to inherit this view and change it's name, from another module, can i do this without a module.py or a ... | Change menu name openerp | 1.2 | 0 | 0 | 325 |
20,315,970 | 2013-12-01T19:03:00.000 | 1 | 0 | 1 | 1 | java,python,jvm | 20,315,993 | 1 | false | 1 | 0 | Without fixing python so it doesn't do you this, you can start a java service which calls your code and have python talk to it via TCP e.g. using protobuf. This way the service can be running all the time. | 1 | 0 | 0 | We've been working on a web application using Django. One library we needed to use was written in java, so I made a single jar file containing all the java code we need to use. The python script simply calls the java program using subprocess module and resumes its execution.
Everytime the java program is called, it ini... | Keeping JVM running | 0.197375 | 0 | 0 | 469 |
20,317,477 | 2013-12-01T21:29:00.000 | 0 | 0 | 0 | 0 | python,html,css,web-scraping,web-analytics | 20,317,674 | 2 | false | 0 | 0 | It sounds like you want to write a spider to do breadth-first search from the first url until you find a link to the second url.
I suggest you look at the Scrapy package; it makes it very easy to do. | 1 | 2 | 0 | I am trying to find a way to extract the depth of a website using python.
Depth of a subwebsite is equal to the number of clicks required from the main website (e.g. www.ualberta.ca) in order for a user to get to the subwebsite (e.g. www.ualberta.ca/beartracks). so for instance if it takes one additional click to get t... | measuring a depth of a website using python | 0 | 0 | 1 | 470 |
20,320,642 | 2013-12-02T04:05:00.000 | 1 | 0 | 0 | 0 | python,python-2.7,sqlite,sqlalchemy | 20,320,905 | 1 | true | 0 | 0 | Aren't you over-optimizing? You don't need the best solution, you need a solution which is good enough.
Implement the simplest one, using dicts; it has a fair chance to be adequate. If you test it and then find it inadequate, try SQLite or Mongo (both have downsides) and see if it suits you better. But I suspect that ... | 1 | 2 | 0 | Have some programming background, but in the process of both learning Python and making a web app, and I'm a long-time lurker but first-time poster on Stack Overflow, so please bear with me.
I know that SQLite (or another database, seems like PostgreSQL is popular) is the way to store data between sessions. But what's... | What's faster: temporary SQL tables or Python dicts for session data? | 1.2 | 1 | 0 | 2,649 |
20,323,084 | 2013-12-02T07:38:00.000 | 1 | 1 | 0 | 1 | python,python-2.7,gcc,python-3.x,include-path | 20,325,445 | 1 | true | 0 | 0 | GCC probably prefers the 3.3 version if it's installed as the default that's run when you call 'python' without a version? You could always point that binary at the 2.7 to make it the default on your system..
Looking at the m4 source, seems like you might be able to do the following on one line:
PYTHON=/path/to/python... | 1 | 3 | 0 | I am trying to compile a code which uses the Python.h header. In fact it is the lcm library.
Now, I have Python2.7 and Python3.3 installed on my system. The respective header filer are found in /usr/include/python2.7/ and /usr/include/python3.3m/.
The problem is that the code needs the 2.7 version, but gcc always pref... | Python3.3 header preferred over Python2.7 header by gcc | 1.2 | 0 | 0 | 806 |
20,324,828 | 2013-12-02T09:29:00.000 | 0 | 1 | 0 | 1 | python,django,ubuntu | 20,324,883 | 2 | true | 1 | 0 | Sounds like an issue with your path - python not finding django becuase it doesnt know where to look for it. Look up issues regarding path and see if those help. | 1 | 0 | 0 | and thanks ahead of time.
I am relatively new to Linux and am using Ubuntu 12.04.3. Basically, I've been messing around with some files trying to get Django to work. Well, I though I should do another install of Python2.7 for some reason. Stupidly, I manually installed it. Now when I open the Python shell and do 'i... | I need to overwrite an existing Python installation in ubuntu 12.04.3 | 1.2 | 0 | 0 | 533 |
20,325,738 | 2013-12-02T10:15:00.000 | 2 | 0 | 1 | 0 | python,performance,coding-style,standards | 20,325,839 | 2 | false | 0 | 0 | The first one is the better of the two.
The second one would get tripped up if the filename had two or more periods in it. | 1 | 1 | 0 | I am trying to change an extension for a file, and I got two options.
os.path.splitext(os.path.basename(g_filename))[0] + ".new"
os.path.basename(g_filename).split('.')[0] + ".new"
Both gives the same output. So i am getting a new file called oldfile.new from oldfile.old
No possibility of having too many '.' in the fi... | Python-Which command is better for changing the file extension? | 0.197375 | 0 | 0 | 117 |
20,331,622 | 2013-12-02T15:16:00.000 | 0 | 0 | 0 | 0 | python,pywinauto | 20,384,256 | 1 | false | 0 | 1 | ListView in pywinauto inherited from HwndWrapper which has DoubleClick() method, try it. Also make sure you've tried Select(item) for ListView. (You've mentioned select()) | 1 | 0 | 0 | I want to use pywinauto to write an auto-click script. I know I can use app.ListView2.Select(4) to select an item. So I tried to use select() or Check(), but it's not working.
How can I doubleclick an item? | How to doubleclick a listview item with pywinauto? | 0 | 0 | 0 | 2,317 |
20,332,320 | 2013-12-02T15:53:00.000 | 4 | 0 | 1 | 0 | python,pycharm,built-in | 20,691,051 | 3 | false | 0 | 0 | I was getting a similar issue. @property and ValueError were being shown as 'undefined'. I had mucked about with PyCharm's interpreter settings a bit beforehand, and I was able to fix it by using the File -> Invalidate Caches / Restart... and choosing the "Invalidate and Restart" command. | 1 | 9 | 0 | I'm using PyCharm and just trying out some simple stuff. When I try to use raw_input(), the editor is showing an unresolved reference error.
I'm not sure what the issue is. Has anyone seen this before? | pycharm builtin unresolved reference | 0.26052 | 0 | 0 | 13,327 |
20,334,880 | 2013-12-02T18:05:00.000 | 1 | 0 | 1 | 0 | python | 20,334,991 | 3 | false | 0 | 0 | I also use __all__: that explictly tells module users what you intend to export. Searching the module for names is tedious, even if you are careful to do, e.g., import os as _os, etc. A wise man once wrote "explicit is better than implicit" ;-) | 2 | 2 | 0 | From the perspective of an external user of the module, are both necessary?
From my understanding, by correctly prefix hidden functions with an underscore it essentially does the same thing as explicitly define __all__, but I keep seeing developers doing both in their code. Why is that? | Should I define __all__ even if I prefix hidden functions and variables with underscores in modules? | 0.066568 | 0 | 0 | 245 |
20,334,880 | 2013-12-02T18:05:00.000 | 0 | 0 | 1 | 0 | python | 20,334,984 | 3 | false | 0 | 0 | Defining all will overide the default behaviour. There is actually might be one reason to define __all__
When importing a module, you might want that doing from mod import * will import only a minimal amount of things. Even if you prefix everything correctly, there could be reasons not to import everything.
The other p... | 2 | 2 | 0 | From the perspective of an external user of the module, are both necessary?
From my understanding, by correctly prefix hidden functions with an underscore it essentially does the same thing as explicitly define __all__, but I keep seeing developers doing both in their code. Why is that? | Should I define __all__ even if I prefix hidden functions and variables with underscores in modules? | 0 | 0 | 0 | 245 |
20,337,169 | 2013-12-02T20:27:00.000 | 1 | 0 | 1 | 0 | python,import | 20,337,294 | 1 | true | 0 | 0 | Modules that are imported more than one are generally only initialized once and the namespace is introduced into the scope of the module. So in your example above there is one class fruit and the two classes that inherit from it and if you were to introduce 3 varieties of apple there would still only be one underlying... | 1 | 1 | 0 | For instance, consider 3 modules namely "apple", "orange" and "fruit". Module "apple" imports "orange" and "fruit". Module "orange" imports "fruit" only. Since "fruit" is common for both, could this be done in a different way? Is this inefficient in terms of memory usage and speed?
I wonder how this is done in profess... | Import in python, two modules sharing common resource | 1.2 | 0 | 0 | 131 |
20,339,183 | 2013-12-02T22:28:00.000 | 9 | 0 | 1 | 0 | python,setuptools,setup.py | 20,339,277 | 1 | true | 0 | 0 | develop creates an .egg-link file in the site-packages directory, which points back to the location of the project files. The same path is also added to the easy-install.pth file in the same location. Uninstalling with setup.py develop -u removes that link file again.
Do note that any install_requires dependencies not ... | 1 | 10 | 0 | I am trying to improve my workflow when developing python modules and have a rather basic question.
What exactly happens when choosing either option. To my knowledge develop leaves the files in place so I can modify them and play around with the package whereas install copies them in the site-packages folder of my pyth... | Difference between setup.py install and setup.py develop | 1.2 | 0 | 0 | 3,236 |
20,339,505 | 2013-12-02T22:51:00.000 | 3 | 1 | 1 | 0 | python,git,github,version,fileupdate | 20,339,747 | 1 | true | 0 | 0 | Assuming all the computers you are setting this up on have accurate times, you could have it create a timestamp file for each dotfile, which just contains the local modified time of the dotfile. Then you can compare the local timestamp with the remote one.
You could also just do the commit locally and try to merge with... | 1 | 0 | 0 | I'm writing a python script to keep my dotfiles up to date with a repository on GitHub. It copies the dot files into a separate directory ( ~/dotfiles ) so that my home directory is not a git repo. Before copying the files, it does a filecmp.cmp( fileInLocalRepo,fileInHomeDir ) to see if the file has changed since it... | Best way to compare remote git file versions with local file versions? | 1.2 | 0 | 0 | 311 |
20,343,484 | 2013-12-03T05:21:00.000 | 3 | 0 | 1 | 0 | python | 20,343,624 | 1 | false | 0 | 0 | The best I can tell you is importing time and using
time.sleep(60) | 1 | 0 | 0 | I need to execute a function on python on intervals of one minute repeatedly. There is another alternative to the "Busy Waith" method. Maybe some like a timer that wake up every minute. | Timed execution of a function | 0.53705 | 0 | 0 | 62 |
20,346,189 | 2013-12-03T08:31:00.000 | 23 | 0 | 1 | 0 | python,django,import | 20,346,290 | 3 | true | 1 | 0 | You surely must have noticed that almost all Python code does the imports at the top of the file. There's a reason for that: the overhead of importing is minimal, and the likelihood is that you will be importing the code at some point during the process lifetime anyway, so you may as well get it out of the way.
The onl... | 2 | 17 | 0 | I am developing an app in django and I had a doubt if importing a library at the global level has any impact over the memory or performance than importing at the local ( per-function) level. If it is imported per function or view, the modules that are needed alone are imported saving space right? Or are there any negat... | Which is a better practice - global import or local import | 1.2 | 0 | 0 | 4,974 |
20,346,189 | 2013-12-03T08:31:00.000 | -2 | 0 | 1 | 0 | python,django,import | 20,346,377 | 3 | false | 1 | 0 | When the script is run, it will store the modules in memory, i'm sure you understand that.
If you're importing on a local scope, the module will be imported each time the client calls the function. But if the module is imported at a global level, there will be no need for that!
So, in this case: global import wins. | 2 | 17 | 0 | I am developing an app in django and I had a doubt if importing a library at the global level has any impact over the memory or performance than importing at the local ( per-function) level. If it is imported per function or view, the modules that are needed alone are imported saving space right? Or are there any negat... | Which is a better practice - global import or local import | -0.132549 | 0 | 0 | 4,974 |
20,346,778 | 2013-12-03T09:02:00.000 | 2 | 0 | 0 | 0 | python,mysql,django,ftp | 20,346,988 | 1 | true | 1 | 0 | ftp stands for "file transfer protocol", not for "remote shell", so no, you cannot use ftp to execute a command / program / script / whatever. But why don't you just ask your hosting how to get a dump of your data ? | 1 | 0 | 0 | I am newbie to python and django, but this time I need a fast solution. I've got a problems, using hosting where my django application is deployed so I need to migrate to another server, but I have no ssh or telnet to server, only ftp connection for this server. I need to export data from django database. I wanted to w... | Is it possible to run scripts on django using only ftp? | 1.2 | 0 | 0 | 219 |
20,347,235 | 2013-12-03T09:24:00.000 | 0 | 1 | 0 | 0 | python,mechanize,mechanize-python | 22,406,798 | 1 | true | 1 | 0 | Answering my own question. Browser giving an alert message simply means that our the node is injected into DOM. By simply looking for the string that I injected in the response body, I could determine whether the given input is reflected through the browser without proper sanitization. | 1 | 0 | 0 | I am trying to develop a small automated tool in python that can check Forms inputs of a web application for XSS vulnerability. I hope to do this using python mechanize library so that I can automate form filling and submit and get the response from the python code. Though mechanize is also works as a browser, is there... | Identify Browser alert messges in Mechanize - Python | 1.2 | 0 | 1 | 244 |
20,347,467 | 2013-12-03T09:37:00.000 | 1 | 0 | 1 | 0 | python,file,text | 20,347,640 | 2 | false | 0 | 0 | Have you debug your code, I mean, you must have to debug and see that it returns the Entry box value or not, if it returns value, then check what value it return. | 1 | 0 | 0 | I read some strings which are usernames from a file into my Python program, then these strings are tested in if statement to see if they are equal to the value entered in the Entry box, but the value from the Entry box and the file even are not equating in the if statement even when I saw they were the same. | Strings from text file not equating in if statement with program strings in Python | 0.099668 | 0 | 0 | 84 |
20,348,584 | 2013-12-03T10:28:00.000 | 0 | 0 | 0 | 0 | python,mysql,sql,database,mysql-python | 20,348,851 | 2 | false | 0 | 0 | Not sure if I understand what it is you want to do. You want to match a value from a column from one table to a value from a column from another table?
If you'd have the data in two tables in a database, you could make an inner join.
Depending on how big the file is, you could use a manual comparison tool like WinMerge... | 2 | 0 | 0 | I have two databases (infact two database dump ... db1.sql and db2.sql)
both database have only 1 table in each.
in each table there are few columns (not equal number nor type) but 1 or 2 columns have same type and same value
i just want to go through both databases and find a row from each table so that they both ha... | Compare two databases and find common value in a row | 0 | 1 | 0 | 1,032 |
20,348,584 | 2013-12-03T10:28:00.000 | 0 | 0 | 0 | 0 | python,mysql,sql,database,mysql-python | 20,348,719 | 2 | false | 0 | 0 | You can use Join with alias name. | 2 | 0 | 0 | I have two databases (infact two database dump ... db1.sql and db2.sql)
both database have only 1 table in each.
in each table there are few columns (not equal number nor type) but 1 or 2 columns have same type and same value
i just want to go through both databases and find a row from each table so that they both ha... | Compare two databases and find common value in a row | 0 | 1 | 0 | 1,032 |
20,349,474 | 2013-12-03T11:08:00.000 | 3 | 0 | 0 | 0 | python,django | 20,349,538 | 3 | false | 1 | 0 | You run the runserver command only when you develop. After you deploy, the client does not need to run python manage.py runserver command. Calling the url will execute the required view. So it need not be a concern | 1 | 2 | 0 | I'm developing some Python project with Django. When we render the Python/Django application, we need to open the command prompt and type in python manage.py runserver. That's ok on for the development server. But for production, it looks funny. Is there anyway to run the Python/Django project without opening the comma... | How to run Python server without command prompt | 0.197375 | 0 | 0 | 1,565 |
20,350,171 | 2013-12-03T11:40:00.000 | 0 | 0 | 1 | 0 | python,python-2.7,scipy,integrate | 61,066,320 | 1 | false | 0 | 0 | I had the same problem.
My issue was that python-2.7 would not let me import scipy.integrate, but python-3.x would allow the import. | 1 | 3 | 0 | I have a reoccurring issue with importing the integrate module of scipy.
Periodically, I get the Error message "ImportError: cannot import name integrate".
Usually, I use the statement import scipy.integrate to import the module.
Only using import scipy successfully imports scipy but without the integrate module.
The ... | Problems importing scipy.integrate module | 0 | 0 | 0 | 2,625 |
20,350,989 | 2013-12-03T12:17:00.000 | 0 | 0 | 1 | 0 | python,python-2.7,floating-point,floating-point-precision | 20,351,305 | 2 | false | 0 | 0 | The struct module can handle 64 bit floats. Decimals are another matter - the binary representation is a string of digits. Probably not what you want. You could covert it to BCD to halve the amount of storage. | 1 | 0 | 1 | In Python 2.7,I need to record high precision floats (such as np.float64 from numpy or Decimal from decimal module) to a binary file and later read it back. How could I do it? I would like to store only bit image of a high precision float, without any overhead.
Thanks in advance! | How to store high precision floats in a binary file, Python 2.7? | 0 | 0 | 0 | 239 |
20,355,886 | 2013-12-03T16:01:00.000 | 1 | 0 | 1 | 0 | python,json | 20,356,067 | 3 | false | 0 | 0 | The problem is that the data structure has a list enclosing the dictionaries. If you have any control over the data source, that's the place to fix it. Otherwise, the best course is probably to post-process the data after parsing it to eliminate these extra list structures and merge the dictionaries in each list into a... | 1 | 0 | 0 | First, here is a sample JSON feed that I want to read in Python 2.7 with either simplejson or the built in JSON decoder. I am loading the .json file in Python and then searching for a key like "Apple" or "Orange" and when that key is found, I want to bring in the information for it like the types and quantities.
Right ... | Python: TypeError in referencing item in JSON feed | 0.066568 | 0 | 0 | 65 |
20,359,021 | 2013-12-03T18:36:00.000 | 3 | 0 | 1 | 0 | python,encryption,dictionary | 20,359,187 | 2 | false | 0 | 0 | Searching for English words in a block of undifferentiated text like that is certainly possible, and doing it efficiently is a genuinely interesting problem. But it's problematic for lots of reasons, just one of which is that your encrypted text may include text that randomly happens to form an English word completely ... | 1 | 4 | 0 | I am using python to build a Caesar cipher decrypter, It works and decrypts the already encrypted word. However, it shows all its brute force decryption attempts, for example, "HELLO" encrypted with a key of 3 is KHOOR. The results after the decryption is "KHOORJGNNQIFMMPHELLOGDKKNFCJJMEBIILDAHHKCZGGJBYFFIAXEEHZWDDGYVC... | Finding words in a non-spaced paragraph? | 0.291313 | 0 | 0 | 576 |
20,360,686 | 2013-12-03T20:09:00.000 | 24 | 0 | 1 | 0 | python,windows,multiprocessing | 20,360,812 | 2 | false | 0 | 0 | The multiprocessing module works by creating new Python processes that will import your module. If you did not add __name__== '__main__' protection then you would enter a never ending loop of new process creation. It goes like this:
Your module is imported and executes code during the import that cause multiprocessing... | 2 | 24 | 0 | While using multiprocessing in python on windows, it is expected to protect the entry point of the program.
The documentation says "Make sure that the main module can be safely imported by a new Python interpreter without causing unintended side effects (such a starting a new process)". Can anyone explain what exactly ... | Compulsory usage of if __name__=="__main__" in windows while using multiprocessing | 1 | 0 | 0 | 15,856 |
20,360,686 | 2013-12-03T20:09:00.000 | 36 | 0 | 1 | 0 | python,windows,multiprocessing | 20,361,032 | 2 | true | 0 | 0 | Expanding a bit on the good answer you already got, it helps if you understand what Linux-y systems do. They spawn new processes using fork(), which has two good consequences:
All data structures existing in the main program are visible to the child processes. They actually work on copies of the data.
The child proc... | 2 | 24 | 0 | While using multiprocessing in python on windows, it is expected to protect the entry point of the program.
The documentation says "Make sure that the main module can be safely imported by a new Python interpreter without causing unintended side effects (such a starting a new process)". Can anyone explain what exactly ... | Compulsory usage of if __name__=="__main__" in windows while using multiprocessing | 1.2 | 0 | 0 | 15,856 |
20,362,190 | 2013-12-03T21:36:00.000 | 0 | 0 | 0 | 0 | python,pygame | 20,385,564 | 2 | false | 0 | 1 | Just to add a bit to furas answer.
Since this function is called get_ticks, you need to do the actual action to get the ticks.
There is one more thing that troubles me, you are trying to blit a integer to the screen, and this is not possible.
What you need to do is create a surface from the string value of the milisec... | 1 | 0 | 0 | I have stated time=pygame.time.get_ticks
then when bliting thing to the screen
I try window.blit(time, (0,0))
but where the time is supposed to be it just says built in function.
Why is this?? | Trouble with pygame.time.get_ticks | 0 | 0 | 0 | 244 |
20,363,655 | 2013-12-03T23:14:00.000 | 0 | 0 | 0 | 0 | python,selenium | 20,363,967 | 1 | false | 0 | 0 | I'm guessing you need a $DISPLAY variable, and xauth or xhost.
Selenium depends on a browser, and your browser on Linux depends on X11. $DISPLAY tells X11 where to find the X server (the thing that renders the graphics - usually this is on the computer you're sitting in front of), and xauth or xhost tells the remote h... | 1 | 0 | 0 | I am trying to run a python code on a Linux server, and my code involves running Selenium.
soon after I started running the code, the following error popped up:
The browser appears to have exited before we could connect. The output was: Error: cannot open display:
I installed firefox and selenium, but for some reason t... | running a python code that includes selenium module gives an error | 0 | 0 | 1 | 64 |
20,365,356 | 2013-12-04T01:52:00.000 | 1 | 0 | 1 | 0 | python,json,http,flask | 20,365,707 | 1 | true | 1 | 0 | I never needed to do something like this myself, but you can probably do this by subclassing the Response class.
Let's say you create a JSONResponse class as a subclass of Response. The constructor of this class takes the same arguments as the parent class, but instead of a string for the body it takes a dictionary.
So... | 1 | 0 | 0 | I'm (attempting) to create a RESTlike API via Flask and would like to include the HTTP response code inside the returned json response. I've found the flask.jsonify() very helpful in generating my responses and I can manipulate the response via the app.after_request decorator.
The issue I have is that the response dat... | Modifying JSON response via Flask after_request | 1.2 | 0 | 0 | 1,188 |
20,366,522 | 2013-12-04T03:56:00.000 | 0 | 0 | 0 | 0 | python,selenium,phantomjs | 26,636,714 | 2 | false | 1 | 0 | Not sure what version of Ghostdriver you are on, but I got that error on 1.9.7 until I upgraded to selenium 2.40 | 2 | 2 | 0 | I am running a code that has selenium component, which requires phantomJS.
I am getting the following error message:
Unable to start phantomjs with ghostdriver.' ; Screenshot: available
In my code, I specified my phantomJS path(the bin path), but such measure didn't work.
I have placed the phantomJS-osx folder at the ... | Unable to start phantomjs with ghostdriver | 0 | 0 | 1 | 2,389 |
20,366,522 | 2013-12-04T03:56:00.000 | -2 | 0 | 0 | 0 | python,selenium,phantomjs | 20,742,773 | 2 | false | 1 | 0 | This is a bug. Please use selenium 2.37.2 | 2 | 2 | 0 | I am running a code that has selenium component, which requires phantomJS.
I am getting the following error message:
Unable to start phantomjs with ghostdriver.' ; Screenshot: available
In my code, I specified my phantomJS path(the bin path), but such measure didn't work.
I have placed the phantomJS-osx folder at the ... | Unable to start phantomjs with ghostdriver | -0.197375 | 0 | 1 | 2,389 |
20,366,533 | 2013-12-04T03:57:00.000 | 2 | 0 | 0 | 1 | python,gtk,mayavi,spectral | 20,513,075 | 1 | true | 0 | 1 | While using OS X Mavericks one has to use: ipython --pylab=wx instead of ipython --pylab=osx to avoid crashing the X11 window. I don't know why this works. | 1 | 4 | 0 | I updated my MacBook to Mavericks, reinstalled Macports and all Python 2.7 modules I usually use. While running Python I get the following messages:
when importing mlab:
from mayavi import lab
(process:1146): Gtk-WARNING **: Locale not supported by C library.
Using the fallback 'C' locale.
when running a mlab comma... | Gtk-WARNING **: Locale not supported by C library. while using several Python modules (mayavi, spectral) | 1.2 | 0 | 0 | 5,430 |
20,367,296 | 2013-12-04T05:07:00.000 | 1 | 0 | 0 | 0 | java,python,swing,user-interface | 20,367,301 | 1 | true | 0 | 1 | I would suggest you go for JavaFX. It comes with the JDK and has a lot of good features.
Plus, it can inter-operate with Swing, backwards and forwards. It allows you to use CSS to pretty-paint your UI. t gives you best of both the worlds. | 1 | 0 | 0 | I am looking to develop an application as a personal project. What I have in mind is a network-based application that would entail writing code for a typical client-server architecture using TCP Sockets as well as a heavy use of GUIs.
I believe I have quite a few choices: Swing in Java, PyQt, PyGTK, wxpython and the l... | Which language has better support for developing GUIs coupled with network programming, Python or Java? | 1.2 | 0 | 0 | 101 |
20,367,583 | 2013-12-04T05:26:00.000 | 2 | 0 | 1 | 0 | python,for-loop | 20,367,645 | 6 | false | 0 | 0 | continue means "skip to the end of the loop body". If it's a while loop, the loop continues on to the loop test; if it's a for loop, the loop continues on to the next element of whatever it's iterating over.
pass does absolutely nothing. It exists because you have to have something in the body of an empty block stateme... | 2 | 8 | 0 | My test shows that both pass and continue can be used equivalently to construct a empty for-loop for test purpose. Are there any difference between them? | What's the difference between pass and continue in python | 0.066568 | 0 | 0 | 7,025 |
20,367,583 | 2013-12-04T05:26:00.000 | 3 | 0 | 1 | 0 | python,for-loop | 20,367,602 | 6 | false | 0 | 0 | pass does nothing (no operation), while continue make control flow to continue to next cycle of the loop. | 2 | 8 | 0 | My test shows that both pass and continue can be used equivalently to construct a empty for-loop for test purpose. Are there any difference between them? | What's the difference between pass and continue in python | 0.099668 | 0 | 0 | 7,025 |
20,369,840 | 2013-12-04T07:48:00.000 | 0 | 0 | 1 | 0 | python,regex,email,validation,email-address | 20,370,346 | 5 | false | 0 | 0 | Doesn't the email library have functions to extract a sender and their domain?
But if it doesn't, and if it's just one, known domain you want to check for, just check if the msg['from'] contains @foobar.net and be done with it. | 2 | 2 | 0 | I am writing a Python script that checks the inbox of an IMAP account, reads in those e-mails, and replies to specific e-mails. However, for security reasons I need to make sure that the original sender of the e-mail came from a particular domain.
I am reading the e-mails in Python using the email library and its mess... | Verify the domain of an e-mail address | 0 | 0 | 0 | 3,996 |
20,369,840 | 2013-12-04T07:48:00.000 | 0 | 0 | 1 | 0 | python,regex,email,validation,email-address | 20,369,926 | 5 | false | 0 | 0 | I'd definitely recommend to use a regex.
However, you should also be aware that the 'from' field in emails is set by the email client and can be spoofed without much effort. So you should think if maybe also checking for the sending mail server might be an option.
Cheers
Hendrik | 2 | 2 | 0 | I am writing a Python script that checks the inbox of an IMAP account, reads in those e-mails, and replies to specific e-mails. However, for security reasons I need to make sure that the original sender of the e-mail came from a particular domain.
I am reading the e-mails in Python using the email library and its mess... | Verify the domain of an e-mail address | 0 | 0 | 0 | 3,996 |
20,373,039 | 2013-12-04T10:38:00.000 | 16 | 0 | 0 | 0 | python,numpy | 20,375,614 | 4 | false | 0 | 0 | You should use array.astype(bool) (or array.astype(dtype=bool)). Works with matrices too. | 2 | 18 | 1 | I have a n x n matrix in numpy which has 0 and non-0 values. Is there a way to easily convert it to a boolean matrix?
Thanks. | How do I convert a numpy matrix into a boolean matrix? | 1 | 0 | 0 | 34,445 |
20,373,039 | 2013-12-04T10:38:00.000 | 4 | 0 | 0 | 0 | python,numpy | 20,373,327 | 4 | false | 0 | 0 | Simply use equality check:
Suppose a is your numpy matrix, use b = (a == 0) or b = (a != 0) to get the boolean value matrix.
In some case, since the value maybe sufficiently small but non-zero, you may use abs(a) < TH, where TH is the numerical threshold you set. | 2 | 18 | 1 | I have a n x n matrix in numpy which has 0 and non-0 values. Is there a way to easily convert it to a boolean matrix?
Thanks. | How do I convert a numpy matrix into a boolean matrix? | 0.197375 | 0 | 0 | 34,445 |
20,375,551 | 2013-12-04T12:35:00.000 | 24 | 0 | 1 | 0 | python,regex | 20,375,638 | 1 | true | 0 | 0 | \d+ means one or more digit [0-9] (depending on LOCALE)
\d- means a digit followed by a dash -
\w+ means one or more word character [a-zA-Z0-9_] (depending on LOCALE)
\w- means a word char followed by a dash - | 1 | 9 | 0 | As per title, what is the difference between:
\d+ and \d-
\w+ and \w-
in regular expression terms? What influence has + and - ? | What is the difference between \d+ and \d- OR \w+ and \w- in regular expression terms? | 1.2 | 0 | 0 | 16,412 |
20,380,661 | 2013-12-04T16:27:00.000 | 0 | 1 | 0 | 0 | python,database,performance,chat | 20,382,525 | 1 | true | 0 | 0 | The only answer possible at this point is 'try it and see'.
I would start with MySQL (mostly because it's the 'lowest common denominator', freely available everywhere); it should do everything you need up to several thousand users, and if you get that far you should have a far better idea of what you need and where the... | 1 | 0 | 0 | So I was making a simple chat app with python. I want to store user specific data in a database, but I'm unfamiliar with efficiency. I want to store usernames, public rsa keys, missed messages, missed group messages, urls to profile pics etc.
There's a couple of things in there that would have to be grabbed pretty ofte... | efficient database file trees | 1.2 | 1 | 0 | 45 |
20,382,403 | 2013-12-04T17:51:00.000 | 2 | 0 | 1 | 0 | python,module,importerror,cyclic-reference,cyclic-dependency | 20,384,772 | 4 | false | 0 | 0 | A cyclic module dependency is usually a code smell.
It indicates that part of the code should be re-factored so that it is external to both modules. | 3 | 8 | 0 | Trying to find a good and proper pattern to handle a circular module dependency in Python. Usually, the solution is to remove it (through refactoring); however, in this particular case we would really like to have the functionality that requires the circular import.
EDIT: According to answers below, the usual angle of... | How to properly handle a circular module dependency in Python? | 0.099668 | 0 | 0 | 1,088 |
20,382,403 | 2013-12-04T17:51:00.000 | 4 | 0 | 1 | 0 | python,module,importerror,cyclic-reference,cyclic-dependency | 20,387,991 | 4 | true | 0 | 0 | As already said, there's probably some refactoring needed. According to the names, it might be ok if a logging modules uses configuration, when thinking about what things should be in configuration one think about configuration parameters, then a question arises, why is that configuration logging at all?
Chances are th... | 3 | 8 | 0 | Trying to find a good and proper pattern to handle a circular module dependency in Python. Usually, the solution is to remove it (through refactoring); however, in this particular case we would really like to have the functionality that requires the circular import.
EDIT: According to answers below, the usual angle of... | How to properly handle a circular module dependency in Python? | 1.2 | 0 | 0 | 1,088 |
20,382,403 | 2013-12-04T17:51:00.000 | 2 | 0 | 1 | 0 | python,module,importerror,cyclic-reference,cyclic-dependency | 20,389,635 | 4 | false | 0 | 0 | So if I'm reading your use case right, logging accesses configuration to get configuration data. However, configuration has some functions that, when called, require that stuff from logging be imported in configuration.
If that is the case (that is, configuration doesn't really need logging until you start calling func... | 3 | 8 | 0 | Trying to find a good and proper pattern to handle a circular module dependency in Python. Usually, the solution is to remove it (through refactoring); however, in this particular case we would really like to have the functionality that requires the circular import.
EDIT: According to answers below, the usual angle of... | How to properly handle a circular module dependency in Python? | 0.099668 | 0 | 0 | 1,088 |
20,382,484 | 2013-12-04T17:56:00.000 | 0 | 0 | 0 | 0 | python,machine-learning,scipy,scikit-learn,angle | 49,957,628 | 4 | false | 0 | 0 | Another simpler way could be to use time as angle measurements than degree measurements (not DMS though). Since many analytics software features time as a datatype, you can use its periodicity to do your job.
But remember, you need to scale 360 degrees to 24 hours. | 1 | 8 | 1 | I'm using Python for kernel density estimations and gaussian mixture models to rank likelihood of samples of multidimensional data.
Every piece of data is an angle, and I'm not sure how to handle the periodicity of angular data for machine learning.
First I removed all negative angles by adding 360 to them, so all angl... | Periodic Data with Machine Learning (Like Degree Angles -> 179 is 2 different from -179) | 0 | 0 | 0 | 3,296 |
20,389,291 | 2013-12-05T00:51:00.000 | 1 | 0 | 0 | 0 | python | 20,389,326 | 3 | false | 0 | 0 | You could write a very quick CLI which would load the data, and then ask for a python filename, which it would then eval() on the data... | 2 | 0 | 1 | I have a large dataset that I perform experiments on. It takes 30 mins to load the dataset from file into memory using a python program. Then I perform variations of an algorithm on the dataset. Each time I have to vary the algorithm, I have to load the dataset into memory again, which eats up 30 minutes.
Is there any ... | load dataset into memory for future computation in python | 0.066568 | 0 | 0 | 233 |
20,389,291 | 2013-12-05T00:51:00.000 | 0 | 0 | 0 | 0 | python | 68,645,793 | 3 | false | 0 | 0 | One possible solution is to use Jupyter to load it once and keep the Jupyter session running. Then you modify your algorithm in a cell and always rerun that cell alone. You can operate on the loaded dataset in RAM as much as you want until you terminate the Jupyter session. | 2 | 0 | 1 | I have a large dataset that I perform experiments on. It takes 30 mins to load the dataset from file into memory using a python program. Then I perform variations of an algorithm on the dataset. Each time I have to vary the algorithm, I have to load the dataset into memory again, which eats up 30 minutes.
Is there any ... | load dataset into memory for future computation in python | 0 | 0 | 0 | 233 |
20,389,368 | 2013-12-05T00:59:00.000 | 1 | 0 | 0 | 0 | python,sqlalchemy | 20,389,560 | 1 | true | 0 | 0 | You can look at session.new, .dirty, and .deleted to see what objects will be committed, but that doesn't necessarily represent the number of rows, since those objects may set extra rows in a many-to-many association, polymorphic table, etc. | 1 | 0 | 0 | Is there a way to know how many rows were commited on the last commit on a SQLAlchemy Session? For instance, if I had just inserted 2 rows, I wish to know that there were 2 rows inserted, etc. | SQLAlchemy, how many rows were commited on last commit | 1.2 | 1 | 0 | 193 |
20,389,982 | 2013-12-05T02:00:00.000 | 0 | 0 | 0 | 0 | c#,python,database,bigdata | 20,390,085 | 2 | false | 0 | 0 | If you are only doing this once, your approach should be sufficient. The only improvement I would make is to read the big file in chunks instead of line by line. That way you don't have to hit the file system as much. You'd want to make the chunks as big as possible while still fitting in memory.
If you will need to do... | 1 | 0 | 1 | I have a giant (100Gb) csv file with several columns and a smaller (4Gb) csv also with several columns. The first column in both datasets have the same category. I want to create a third csv with the records of the big file which happen to have a matching first column in the small csv. In database terms it would be a ... | Intersecting 2 big datasets | 0 | 1 | 0 | 154 |
20,394,391 | 2013-12-05T07:54:00.000 | 6 | 0 | 1 | 0 | python,caching | 20,394,556 | 3 | false | 0 | 0 | The ways to preserve data between totally separate executions of a process are:
Saving a file.
Handing the data off to another process such as a Memcached or Redis instance, or a database, which will keep the data in memory and/or write it to disk somewhere.
Recording the data in some other, more unusual way such as c... | 2 | 0 | 0 | I have a requirement like
For the first time I run the process, I need to set a=1
And for the remaining times I run the same process, I need to set a=2
Is it possible to maintain cache that tells the process is ran for second time.
I don't want another physical file to be created in my directory structure.
I searched i... | How do I maintain a cache in python | 1 | 0 | 0 | 216 |
20,394,391 | 2013-12-05T07:54:00.000 | 0 | 0 | 1 | 0 | python,caching | 20,394,475 | 3 | false | 0 | 0 | Data cached inside the process dies along with the process. You'll have to cache this info elsewhere since you want it to persist longer than the process lives. A file seems reasonable. | 2 | 0 | 0 | I have a requirement like
For the first time I run the process, I need to set a=1
And for the remaining times I run the same process, I need to set a=2
Is it possible to maintain cache that tells the process is ran for second time.
I don't want another physical file to be created in my directory structure.
I searched i... | How do I maintain a cache in python | 0 | 0 | 0 | 216 |
20,395,090 | 2013-12-05T08:35:00.000 | 1 | 0 | 1 | 0 | python,regex | 20,395,227 | 3 | true | 0 | 0 | Characters between numbers would be (?<=\d)[a-zA-Z]+(?=\d) (i. e. only those characters which are directly embraced by numbers, so for abc234def678hij it would be def), but I have the feeling you mean characters and numbers together; that would be [a-zA-Z0-9]+ plain and simple. | 1 | 0 | 0 | I need a pattern to match characters between numbers, what should I define as a pattern to match characters and number together?
example string(the Bold string is what I should match):
IP/51-0000523b ivr s 2 Up BackGround 5230f668473bd/MainIVR 4566658 00:00:22`... | python regex to match characters and numbers together | 1.2 | 0 | 0 | 67 |
20,395,712 | 2013-12-05T09:08:00.000 | 2 | 0 | 0 | 0 | python,timeout,sparqlwrapper | 59,155,214 | 4 | false | 0 | 0 | As of 2018, you can use SPARQLWrapper.setTimeout() to set the timeout for SPARQLWrapper requests. | 3 | 3 | 0 | I am new to python as well as new to the world of querying the semantic web.
I am using SPARQLWrapper library to query dbpedia, I searched the library documentation but failed to find 'timeout' for a query fired to dbpedia from sparqlWrapper.
Anyone has any idea about the same. | Python : SpaqrlWrapper, Timeout? | 0.099668 | 0 | 0 | 459 |
20,395,712 | 2013-12-05T09:08:00.000 | 1 | 0 | 0 | 0 | python,timeout,sparqlwrapper | 62,625,256 | 4 | false | 0 | 0 | As Karoo mentioned you can use SPARQLWrapper.setTimeout(timeout=(int)).
If you want a timeout as a float, go to the Wrapper.py module and change self.timeout = int(timeout) to self.timeout = float(timeout) in the def setTimeout(self, timeout): function. | 3 | 3 | 0 | I am new to python as well as new to the world of querying the semantic web.
I am using SPARQLWrapper library to query dbpedia, I searched the library documentation but failed to find 'timeout' for a query fired to dbpedia from sparqlWrapper.
Anyone has any idea about the same. | Python : SpaqrlWrapper, Timeout? | 0.049958 | 0 | 0 | 459 |
20,395,712 | 2013-12-05T09:08:00.000 | 0 | 0 | 0 | 0 | python,timeout,sparqlwrapper | 20,419,088 | 4 | true | 0 | 0 | DBPedia uses Virtuoso server for it's endpoint and timeout is a virtuoso-specific option. SparqlWrapper doesn't currently support it.
Next version will feature better modularity and proper vendor-specific extensions might be implemented after that, but I guess you don't have time to wait.
Currently, the only way to add... | 3 | 3 | 0 | I am new to python as well as new to the world of querying the semantic web.
I am using SPARQLWrapper library to query dbpedia, I searched the library documentation but failed to find 'timeout' for a query fired to dbpedia from sparqlWrapper.
Anyone has any idea about the same. | Python : SpaqrlWrapper, Timeout? | 1.2 | 0 | 0 | 459 |
20,397,744 | 2013-12-05T10:40:00.000 | 2 | 0 | 0 | 1 | python,tornado | 20,512,056 | 3 | false | 0 | 0 | There is no public interface to find out whether a path is currently mapped in a Tornado Application. In general, you shouldn't be calling add_handlers after startup anyway - instead, add a wildcard rule (like (r'/game/(.*)', GameHandler)) and then in GameHandler you can check whether the requested game exists or not ... | 2 | 1 | 0 | How to check if application in Tornado listen some url ?
I need to listen lot off urls, for new game I create new and add programmatically handler for that url, but I first need to check. How to check if Tornado already listen url? | How to check if Tornado already listen url? | 0.132549 | 0 | 0 | 566 |
20,397,744 | 2013-12-05T10:40:00.000 | 1 | 0 | 0 | 1 | python,tornado | 20,493,472 | 3 | false | 0 | 0 | I believe you'll need a fine-grained access to the active games, so better keep them in your domain model.
Still, you can examine tornado.web.Application.handlers of your app. | 2 | 1 | 0 | How to check if application in Tornado listen some url ?
I need to listen lot off urls, for new game I create new and add programmatically handler for that url, but I first need to check. How to check if Tornado already listen url? | How to check if Tornado already listen url? | 0.066568 | 0 | 0 | 566 |
20,401,798 | 2013-12-05T13:53:00.000 | 0 | 0 | 1 | 0 | performance,python-2.7,memory,ram | 20,401,961 | 3 | false | 0 | 0 | Once you've hit 100% of your memory, you're going to start hitting the swap on your machine, which uses the disk which is WAYYY slower than memory. After your program is done running, all of the other programs need to re-read thier information back into memory. If the problem doesn't go away after a couple of minutes... | 3 | 2 | 0 | My hardware specs are listed below, though this is probably not important
I use my machine for data processing, which often involves holding large amounts of data in memory (I have made many improvements in my code lately by reading in partial files to decrease memory use, but this remains problematic), with all of my ... | Sluggish after usinge 100% RAM | 0 | 0 | 0 | 542 |
20,401,798 | 2013-12-05T13:53:00.000 | 2 | 0 | 1 | 0 | performance,python-2.7,memory,ram | 20,402,123 | 3 | true | 0 | 0 | There is a concept called 'system-load'. A system under a large load ( comprising of interrupts, IO wait, context switches, computation etc) takes time to recover. The load persists for some time because unlike core-computation, the other operations that make the system work hard, do not simply stop suddenly.
For examp... | 3 | 2 | 0 | My hardware specs are listed below, though this is probably not important
I use my machine for data processing, which often involves holding large amounts of data in memory (I have made many improvements in my code lately by reading in partial files to decrease memory use, but this remains problematic), with all of my ... | Sluggish after usinge 100% RAM | 1.2 | 0 | 0 | 542 |
20,401,798 | 2013-12-05T13:53:00.000 | 0 | 0 | 1 | 0 | performance,python-2.7,memory,ram | 20,405,742 | 3 | false | 0 | 0 | I would have thought that Task Manager, Processes, with appropriate columns selected by View, sorted by clicking on column heading (for Top), would suggest reasons, along with Performance tab info. Then there is Perfmon Resource Monitor and my favourite, logging via Perfmon, Performance, Data Collection Sets, User Def... | 3 | 2 | 0 | My hardware specs are listed below, though this is probably not important
I use my machine for data processing, which often involves holding large amounts of data in memory (I have made many improvements in my code lately by reading in partial files to decrease memory use, but this remains problematic), with all of my ... | Sluggish after usinge 100% RAM | 0 | 0 | 0 | 542 |
20,402,359 | 2013-12-05T14:17:00.000 | 0 | 0 | 0 | 0 | listbox,wxpython | 20,416,806 | 2 | false | 0 | 1 | I don't think there's a direct way to do this, so the only way would be to do it by hand: catch click events, use the HitTest to find which item was selected, and then ignore the event if it's the "deactivated" item. (Tree Controls have the EVT_TREE_SEL_CHANGING which would be useful here, but there's no analog for a ... | 2 | 0 | 0 | I am trying to disable only one item in a listbox with wxpython. I already searched in the Internet for a way to do this, but I found nothing...
I hope you can give me a hint! | Disable only one item in a wxpython.listbox | 0 | 0 | 0 | 389 |
20,402,359 | 2013-12-05T14:17:00.000 | 0 | 0 | 0 | 0 | listbox,wxpython | 20,426,709 | 2 | false | 0 | 1 | You will need to bind to wx.EVT_LISTBOX and check if the selection is in your "deactivated" list. If so, set the selection to a different item in the control. | 2 | 0 | 0 | I am trying to disable only one item in a listbox with wxpython. I already searched in the Internet for a way to do this, but I found nothing...
I hope you can give me a hint! | Disable only one item in a wxpython.listbox | 0 | 0 | 0 | 389 |
20,403,387 | 2013-12-05T15:03:00.000 | 53 | 0 | 1 | 0 | python,pypi | 20,403,468 | 3 | true | 0 | 0 | Login.
Go to your packages.
Check the "remove" checkbox for the particular package.
Click "Remove" button. | 1 | 58 | 0 | How do I remove a package from Pypi?
I uploaded a package to Pypi several months ago. The package is now obsolete and I'd like to formally remove it. I cannot find any documentation on how to remove my package. | How to remove a package from Pypi | 1.2 | 0 | 0 | 27,292 |
20,403,921 | 2013-12-05T15:28:00.000 | 0 | 0 | 0 | 1 | python,asynchronous,twisted,tornado,reactor | 20,429,005 | 2 | false | 1 | 0 | So far I found, that if you merge two twisted applications, you should remove reactor.run() from one of them, leaving only one reactor.run() in the end. And be sure that twisted.reactor implementation is same for both applications.
More comments welcome. | 1 | 2 | 0 | I have two applications, written on twisted framework, for example one using twisted.web, and other using twisted.protocols.*, not web. How can I "merge" them in one, effectively sharing one reactor for both apps?
What are the best practices for that tasks? Actually I need to connect SIPSimpleApp and TornadoWeb. They b... | How to "merge" two Python twisted applications? | 0 | 0 | 0 | 247 |
20,406,598 | 2013-12-05T17:24:00.000 | 1 | 0 | 1 | 0 | python | 20,407,097 | 2 | false | 0 | 0 | Builtins are just names in the global namespace, so the same rule applies to any other non-builtin imported into the namespace. Now consider what happens if a new name is added to the imported module, or a new builtin is added, that has a name that is already in use in your code.
With the current rule, your code still ... | 1 | 4 | 0 | So I see this a lot. People call their dictionaries dict, their lists list, and so on. I know this is frowned upon because it overwrites the built-in value in Python.
The question is, why doesn't this raise an exception? I see a lot of people say to never do this, but why isn't it an error? The only conclusion I ca... | What is the Correct Time to Name a Variable after a Builtin? | 0.099668 | 0 | 0 | 60 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.