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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
9,045,888 | 2012-01-28T14:16:00.000 | 1 | 0 | 0 | 0 | python,charts,reportlab,curve-fitting | 9,046,880 | 1 | true | 0 | 0 | I would recommend using MatPlotLib. This is exactly the sort of thing it's designed to handle and it will be much easier than trying to piece together something in ReportLab alone, especially since you'll have to do all the calculation of the line on your own and figure out the details of how to draw it in just the ri... | 1 | 0 | 1 | I'm preparing a set of reports using open source ReportLab. The reports contain a number of charts. Everything works well so far.
I've been asked to take a (working) bar chart that shows two series of data and overlay a fitted curve for each series.
I can see how I could overlay a segmented line on the bar graph by c... | Fitted curve on chart using ReportLab | 1.2 | 0 | 0 | 447 |
9,045,937 | 2012-01-28T14:21:00.000 | 2 | 0 | 0 | 0 | python,pdf,reportlab | 9,046,943 | 2 | false | 0 | 0 | At what point do you need this information? It becomes available as the document is constructed, so you can get it after rendering by overriding methods such as afterPage, afterDrawPage, and afterFlowable. You can then get the page number from the DocTemplate class (I believe there's a class variable called something... | 1 | 2 | 0 | How to determine on what page(need a page number) will be each flowable after rendering to pdf. I was thinking to add a custom id attribute to flowable, so i will know what flowable is it. But how can i determine on what page it will be placed?
What is the best way to achieve this? | How to know on what page number flowable was placed during rendering a pdf with reportlab | 0.197375 | 0 | 0 | 1,281 |
9,047,267 | 2012-01-28T17:25:00.000 | 1 | 0 | 0 | 1 | python,multithreading,google-app-engine,web2py,task-queue | 9,047,335 | 3 | false | 1 | 0 | maybe i'm misunderstanding something, but thos sounds like the perfect match for a task queue, and i can't see how multithreading will help, as i thought this only ment that you can serve many responses simultaneously, it won't help if your responses take longer than the 30 second limit.
With a task you can add it, the... | 2 | 1 | 0 | I have my server on Google App Engine
One of my jobs is to match a huge set of records with another.
This takes very long, if i have to match 10000 records with 100.
Whats the best way of implementing this.
Im, using Web2py stack and deployed my application on Google App Engine. | Task Queues or Multi Threading on google app engine | 0.066568 | 0 | 0 | 980 |
9,047,267 | 2012-01-28T17:25:00.000 | 1 | 0 | 0 | 1 | python,multithreading,google-app-engine,web2py,task-queue | 9,047,823 | 3 | false | 1 | 0 | Multithreading your code is not supported on GAE so you can not explicitly use it.
GAE itself can be multithreaded, which means that one frontend instance can handle multiple http requests simultaneously.
In your case, best way to achieve parallel task execution is Task Queue. | 2 | 1 | 0 | I have my server on Google App Engine
One of my jobs is to match a huge set of records with another.
This takes very long, if i have to match 10000 records with 100.
Whats the best way of implementing this.
Im, using Web2py stack and deployed my application on Google App Engine. | Task Queues or Multi Threading on google app engine | 0.066568 | 0 | 0 | 980 |
9,047,378 | 2012-01-28T17:37:00.000 | 2 | 0 | 0 | 0 | python,django,string-formatting,django-queryset | 9,047,552 | 1 | true | 1 | 0 | I eventually found the explanation. I'm not sure this will be of much help to others, but anyways.
The problem came from the fact that params in the call was a list. It appears you can use a list to instantiate a RawQuerySet, but it is not converted into a tuple so you can't use it for string-formatting later on.
Concl... | 1 | 1 | 0 | I'm using a RawQuerySet in Django, and I need to pass it a few parameters (5).
I'm able to call the constructor using MyModel.objects.raw(SQL, params). The SQL is pretty long and not that relevant, but params is [991L, 991L, 991L, 7L, 3].
I do get a RawQuerySet in return. Hence, the call is OK.
However, my problem is ... | Django RawQuerySet.__repr__ : not enough arguments for format string | 1.2 | 0 | 0 | 1,159 |
9,047,402 | 2012-01-28T17:40:00.000 | 1 | 0 | 1 | 0 | python,multithreading | 9,047,422 | 3 | false | 0 | 0 | You can either instrument the program so that it makes regular calls to a timekeeping function, or you can use threads.
If the timekeeping could be done by a second process that'd be better in terms of management complexity, but you don't say why you need the time, so I can't judge whether that's a possibility.
Threads... | 1 | 3 | 0 | How do I keep track of time constantly without the use of threads? I'm asking this as threads in python are generally looked down on especially because it "adds complexity" to any program. My program needs to receive/send WiFi commands, receive/send XBee(Serial) commands, as well as keeping track of time constantly.
W... | Keep track of time constantly without the use of threads | 0.066568 | 0 | 0 | 411 |
9,047,958 | 2012-01-28T19:35:00.000 | 2 | 0 | 0 | 0 | python,opengl | 9,048,066 | 1 | false | 0 | 1 | The OpenGL flag in Pygame is used to turn your window into an OpenGL projection for other libraries - such as Rabbyt or PyOpenGL - to use.
For sites on reading up on all of this, I would recommend starting out at the respective sites for PyGame, OpenGL, et al. I'd post links for them, but the spam protection mechanism ... | 1 | 0 | 0 | I just turned on the pygame.OPENGL flag in my set_mode out of curiosity. It made my code very unhappy: pygame.error: Cannot call on OPENGL Surfaces on the first screen.fill((0, 0, 0)).
I don't NEED OpenGL, but I'm kind of curious about it. Where could I find info about pygame/SDL and OpenGL? | Where can I find information about what/why pygame can(not) do with openGl surfaces? | 0.379949 | 0 | 0 | 919 |
9,048,108 | 2012-01-28T19:57:00.000 | 49 | 0 | 0 | 0 | python,django,django-models,django-admin | 9,048,338 | 1 | true | 1 | 0 | You should use clean to do validation-related work, and to parse/change/otherwise clean the input. Capitalizing fields and generating a slug can happen here. I also use clean to force a field like post_type to a specific value in proxy models. If you raise django.core.exceptions.ValidationError('error text') inside ... | 1 | 40 | 0 | I have a couple of actions to perform when saving a models, especially from the admin. I capitalize a couple of fields and check to make sure that either one field or the other is filled. I also create the field slug. RIght now these are split between overriding the clean and the save functions. It works now, but I am ... | Django Overriding Model Clean() vs Save() | 1.2 | 0 | 0 | 10,208 |
9,048,513 | 2012-01-28T20:52:00.000 | 0 | 0 | 0 | 0 | python,django,google-app-engine,internationalization,django-templates | 9,054,738 | 2 | false | 1 | 0 | There is an earlier error that you did not yet fix:
Error Importing data store piston.gae_store OAuth: "No module named piston.gae_store"
This does not seem to be related to the lines that you change. It will probably even occur when your remove the {% url ...%} completely, right? Try to fix the existing error first. | 1 | 1 | 0 | I have a problem using the tag {% url%} in Django on GAE, I found the problem applying internationalization in JavaScript files, writing:
{% url django.views.i18n.javascript_catalog %}
Django throws the error:
TemplateSyntaxError at / view / test /
Caught ImproperlyConfigured while rendering: Error Importing data
st... | {% url %} not work in Django | 0 | 0 | 0 | 417 |
9,048,558 | 2012-01-28T20:57:00.000 | 1 | 0 | 1 | 1 | python,rest,subprocess,rpc | 9,049,120 | 1 | true | 0 | 0 | I think I'd prefer to use any of the rpc or rest interfaces, because the results you can obtain from them are usually in a format that is easy to parse since those interfaces have been designed for machine interaction. However, a command line interface is designed for human interaction and this means that the output is... | 1 | 0 | 0 | I have a situation where there is a program which is written in c++. It is a kind of a server which you need to start first. Then from another konsole you can call the program passing commandline arguments and it does stuff. Also it provides rpc and rest based access. So you can write a rpc or rest based library to int... | Communicate with another program using subprocess or rpc / rest in python? | 1.2 | 0 | 0 | 492 |
9,049,864 | 2012-01-29T00:26:00.000 | 3 | 0 | 1 | 0 | python,eclipse,pydev | 9,051,495 | 1 | true | 0 | 0 | By catching the eclipse termination, do you mean catching the event of someone pressing the "Terminate" button while debugging? If so, I don't think there is an exception or event you can catch.
Here is a few things i tried on the side that does not work either:
1. Adding signal handlers for SIGTERM, SIGNTEAL, and SIG... | 1 | 4 | 0 | I have a python script which makes use of multiprocessing. I like to debug my scripts in Eclipse, but with multiprocessing, I always have to manually kill the spawned children processes after termination. How can I catch the Eclipse termination action in the script so it can clean up? | How to catch run termination from Eclipse pydev? | 1.2 | 0 | 0 | 2,220 |
9,050,408 | 2012-01-29T02:24:00.000 | 0 | 0 | 1 | 0 | python,gedit | 9,051,488 | 3 | false | 0 | 0 | You almost never need to compile Python code, although sometimes, as a optimization, Python code could be transfered into C code for a higher performance with certain plugins. Python code are translated to *.pyc and run in a PVM. | 1 | 1 | 0 | I am using WinXP.
I am using gedit (2.30.1) as python IDE. But I don't how to compile my code from inside the gedit. I've searched the net, but can't found any good solution. | compiling python code from gedit | 0 | 0 | 0 | 2,601 |
9,055,624 | 2012-01-29T18:33:00.000 | 1 | 0 | 1 | 0 | python,performance,memory,mongodb | 9,056,220 | 2 | true | 1 | 0 | If you are going to display all of the data on the web interface anyways, start simple: Get a the whole document. It reduces your latency by requiring less round trips to the database. | 2 | 0 | 0 | I have documents in Mongo that contain questionnaire-like data (company's name, address, phone numbers, etc.). I should have this data displayed in web interface.
How to make it better: get the whole document as dict into a variable and fill webform from its data or make lots of database requests to fill each field of... | Documents requests and memory issue using MongoDB | 1.2 | 0 | 0 | 66 |
9,055,624 | 2012-01-29T18:33:00.000 | 1 | 0 | 1 | 0 | python,performance,memory,mongodb | 9,057,896 | 2 | false | 1 | 0 | Agree with GPS - if you need all, or most, of the data then it should be a better option to retrieve the document in one request as opposed to hitting the database x number of times. | 2 | 0 | 0 | I have documents in Mongo that contain questionnaire-like data (company's name, address, phone numbers, etc.). I should have this data displayed in web interface.
How to make it better: get the whole document as dict into a variable and fill webform from its data or make lots of database requests to fill each field of... | Documents requests and memory issue using MongoDB | 0.099668 | 0 | 0 | 66 |
9,056,378 | 2012-01-29T20:16:00.000 | 2 | 0 | 1 | 0 | python | 9,056,406 | 2 | false | 0 | 0 | It will depend on the order in which the entries were added to the dicts, AFAIK Python's dict data structure doesn't make any guarantee on the ordering of its entries. | 1 | 2 | 0 | If I have multiple dicts that have the same set of keys (and nearly the same values), will the the two dicts have the same ordering of entries? Or is the process of hashing not that predictable? | Multiple Dicts w/ the Same Set of Keys | 0.197375 | 0 | 0 | 82 |
9,056,646 | 2012-01-29T20:51:00.000 | 0 | 0 | 0 | 0 | python,opencv,colors,detection,threshold | 66,779,646 | 5 | false | 0 | 0 | I know this is an old question, but for completeness I wanted to point out that cv2.moments() will not always work for small contours. In this case, you can use cv2.minEnclosingCircle() which will always return the center coordinates (and radius), even if you have only a single point. Slightly more resource-hungry tho... | 3 | 14 | 1 | There is any method/function in the python wrapper of Opencv that finds black areas in a binary image? (like regionprops in Matlab)
Up to now I load my source image, transform it into a binary image via threshold and then invert it to highlight the black areas (that now are white).
I can't use third party libraries suc... | Python OpenCV - Find black areas in a binary image | 0 | 0 | 0 | 26,428 |
9,056,646 | 2012-01-29T20:51:00.000 | 0 | 0 | 0 | 0 | python,opencv,colors,detection,threshold | 15,779,624 | 5 | false | 0 | 0 | Transform it to binary image using threshold with the CV_THRESH_BINARY_INV flag, you get threshold + inversion in one step. | 3 | 14 | 1 | There is any method/function in the python wrapper of Opencv that finds black areas in a binary image? (like regionprops in Matlab)
Up to now I load my source image, transform it into a binary image via threshold and then invert it to highlight the black areas (that now are white).
I can't use third party libraries suc... | Python OpenCV - Find black areas in a binary image | 0 | 0 | 0 | 26,428 |
9,056,646 | 2012-01-29T20:51:00.000 | 2 | 0 | 0 | 0 | python,opencv,colors,detection,threshold | 9,058,880 | 5 | false | 0 | 0 | After inverting binary image to turn black to white areas, apply cv.FindContours function. It will give you boundaries of the region you need.
Later you can use cv.BoundingRect to get minimum bounding rectangle around region. Once you got the rectangle vertices, you can find its center etc.
Or to find centroid of regio... | 3 | 14 | 1 | There is any method/function in the python wrapper of Opencv that finds black areas in a binary image? (like regionprops in Matlab)
Up to now I load my source image, transform it into a binary image via threshold and then invert it to highlight the black areas (that now are white).
I can't use third party libraries suc... | Python OpenCV - Find black areas in a binary image | 0.07983 | 0 | 0 | 26,428 |
9,058,731 | 2012-01-30T02:36:00.000 | 1 | 0 | 0 | 0 | python,ip,port | 9,058,904 | 1 | true | 0 | 0 | With most routers ports are only mapped when someone connects from the outside (internet/WAN). You're testing it from your LAN so basically you're connecting to your router when you use your public IP. Ask a friend to test, i.e. from an outside connection. | 1 | 1 | 0 | I'm have an issue with running the built in Python server that comes with 3.1, this may or may not be an issue with Python, in fact it probably isn't.
I start my server in the correct directory with "python -m http.server 8000" as the documentation suggests (http://docs.python.org/release/3.1.3/library/http.server.html... | Quick issue with Python 3.1 http server | 1.2 | 0 | 1 | 297 |
9,058,865 | 2012-01-30T03:00:00.000 | 1 | 1 | 0 | 0 | python,imaplib | 9,059,000 | 4 | true | 0 | 0 | Disclaimer: I'm familiar with IMAP but not Python-IMAPClient specifically.
Normally the 'seen' flag determines if an email summary will be shown normal or bold.
You should be able to reset the seen flag. However the recent flag may not be under your direct control. The imap server will set it if notices new messages... | 1 | 4 | 0 | I am retrieving emails from my email server using IMAPClient (Python), by checking for emails flagged with "\Recent". After the email has been read the email server automatically sets the email flag to "\Seen".
What I want to do is reset the email flag to "\Recent" so when I check the email directly on the server is st... | How to change email flag to Recent using IMAPClient | 1.2 | 0 | 0 | 5,938 |
9,062,209 | 2012-01-30T10:08:00.000 | 2 | 0 | 1 | 0 | python,garbage-collection | 16,219,576 | 3 | false | 0 | 0 | My initial guess is that using reference counting can easily remove non-cyclic referenced objects, this may somewhat speed up mark-and-sweep and gain memory immediately. Don't know if my guess is right?
Yes. As soon as the refcount goes to zero and object can be removed. This won't happen in a cyclic referenced obje... | 3 | 23 | 0 | My question is why does python use both reference counting and mark-and-sweep for gc? Why not only mark-and-sweep?
My initial guess is that using reference counting can easily remove non-cyclic referenced objects, this may somewhat speed up mark-and-sweep and gain memory immediately. Don't know if my guess is right?
An... | Why does python use both reference counting and mark-and-sweep for gc? | 0.132549 | 0 | 0 | 7,023 |
9,062,209 | 2012-01-30T10:08:00.000 | 21 | 0 | 1 | 0 | python,garbage-collection | 9,063,805 | 3 | true | 0 | 0 | Python (the language) doesn't say which form of garbage collection it uses. The main implementation (often known as CPython) acts as you describe. Other versions such as Jython or IronPython use a purely garbage collected system.
Yes, there is a benefit of earlier collection with reference counting, but the main reason... | 3 | 23 | 0 | My question is why does python use both reference counting and mark-and-sweep for gc? Why not only mark-and-sweep?
My initial guess is that using reference counting can easily remove non-cyclic referenced objects, this may somewhat speed up mark-and-sweep and gain memory immediately. Don't know if my guess is right?
An... | Why does python use both reference counting and mark-and-sweep for gc? | 1.2 | 0 | 0 | 7,023 |
9,062,209 | 2012-01-30T10:08:00.000 | 17 | 0 | 1 | 0 | python,garbage-collection | 9,062,281 | 3 | false | 0 | 0 | Reference counting deallocates objects sooner than garbage collection.
But as reference counting can't handle reference cycles between unreachable objects, Python uses a garbage collector (really just a cycle collector) to collect those cycles when they exist. | 3 | 23 | 0 | My question is why does python use both reference counting and mark-and-sweep for gc? Why not only mark-and-sweep?
My initial guess is that using reference counting can easily remove non-cyclic referenced objects, this may somewhat speed up mark-and-sweep and gain memory immediately. Don't know if my guess is right?
An... | Why does python use both reference counting and mark-and-sweep for gc? | 1 | 0 | 0 | 7,023 |
9,065,831 | 2012-01-30T14:56:00.000 | 2 | 1 | 1 | 0 | python,serial-port | 9,065,933 | 2 | true | 0 | 0 | I don't think you can do that if you cannot modify the sources of the measurement software.
Serial port protocols are written as "point to point" protocols, so there's no general way to multiplex them. You can write a program that shares the access to the GPS module (handling it exclusively and exposing an API to multi... | 2 | 0 | 0 | I have a GPS module connected through serial port(USB->Virtual COM port). A measurement software is using this port, so with other software I can't access to the data. I would like to create two virtual COM port and share this data through that. Is it possible using Python? Is there any opensource example written in Py... | Share serial port on Windows using python | 1.2 | 0 | 0 | 732 |
9,065,831 | 2012-01-30T14:56:00.000 | 0 | 1 | 1 | 0 | python,serial-port | 9,068,214 | 2 | false | 0 | 0 | Do you need two-way communication, or just reading? You could build or buy hardware to physically split the Rx data line so you could use two COM ports, each of which would read the same data. You could do this with Tx data as well, but you would have to be careful about trashing the data if both ports tried to write... | 2 | 0 | 0 | I have a GPS module connected through serial port(USB->Virtual COM port). A measurement software is using this port, so with other software I can't access to the data. I would like to create two virtual COM port and share this data through that. Is it possible using Python? Is there any opensource example written in Py... | Share serial port on Windows using python | 0 | 0 | 0 | 732 |
9,065,936 | 2012-01-30T15:04:00.000 | 2 | 1 | 1 | 0 | python,logging | 9,065,992 | 1 | false | 0 | 0 | If you have no idea where it fails you could run a debugging session with input that you know causes the error, and step through the code if that is an option.
Another pretty obvious option is to log all exceptions at the entrance of your script and then drill down from there, but I honestly don't think that there is a... | 1 | 1 | 0 | I need to add logging to a milter that I wrote a few months back. It is occasionally rejecting some messages, but I'm not sure why. I know how to add logging to a Python script from the HowTo, but is it necessary for me to add log output commands at every point in my script, or is there a way Python automatically han... | How to automate python logging | 0.379949 | 0 | 0 | 540 |
9,069,298 | 2012-01-30T19:06:00.000 | 5 | 0 | 1 | 0 | python,performance,sorting,reverse,time-complexity | 9,069,357 | 5 | false | 0 | 0 | The sort() method is native, i.e. it's implemented in the host language rather than in Python. Passing a function in the cmp argument forces the native implementation to call that function and execute Python code on each iteration. That's where the performance hit comes from.
On the other hand, passing True in the reve... | 2 | 15 | 0 | When calling sort() on a list in Python, passing cmp=f slows down the sort. Does passing reverse=True affect the efficiency of the sort in any way (or is it identical to sorting without reversing)? | Does passing reverse=True when sorting a list in Python affect efficiency? | 0.197375 | 0 | 0 | 6,526 |
9,069,298 | 2012-01-30T19:06:00.000 | 0 | 0 | 1 | 0 | python,performance,sorting,reverse,time-complexity | 9,089,969 | 5 | false | 0 | 0 | Note that the cmp arg to list.sort and the sorted built-in function are deprecated in Python 2.x and no longer allowed in 3.x, because of the poor performance they give, as you have noticed. Instead, you are supposed to use the key arg to define a custom sorting order. | 2 | 15 | 0 | When calling sort() on a list in Python, passing cmp=f slows down the sort. Does passing reverse=True affect the efficiency of the sort in any way (or is it identical to sorting without reversing)? | Does passing reverse=True when sorting a list in Python affect efficiency? | 0 | 0 | 0 | 6,526 |
9,070,074 | 2012-01-30T20:07:00.000 | 0 | 0 | 1 | 1 | python,macos,python-imaging-library | 10,423,397 | 9 | false | 0 | 0 | I was trying to execute a Python script with administrative privileges in a Mac (running on Lion) and looking at this post I found out that all I needed to do was launch Python with Administrative privileges by using the "sudo" command in the Terminal.
Like that: "sudo Python" and then executing the script.
I know it i... | 2 | 41 | 0 | I've tried googling & looking up some other people's questions. However, I still couldn't find a clear/simple recipe to install PIL (for python 2.6 or 2.7) on mac os x 10.7.2 Lion. | How can I install PIL on mac os x 10.7.2 Lion | 0 | 0 | 0 | 73,763 |
9,070,074 | 2012-01-30T20:07:00.000 | 3 | 0 | 1 | 1 | python,macos,python-imaging-library | 16,826,248 | 9 | false | 0 | 0 | u may try this in terminal:
sudo easy_install pip
sudo pip install pil | 2 | 41 | 0 | I've tried googling & looking up some other people's questions. However, I still couldn't find a clear/simple recipe to install PIL (for python 2.6 or 2.7) on mac os x 10.7.2 Lion. | How can I install PIL on mac os x 10.7.2 Lion | 0.066568 | 0 | 0 | 73,763 |
9,070,218 | 2012-01-30T20:19:00.000 | 1 | 0 | 1 | 1 | python,osx-lion,pip,easy-install,llvm-gcc | 48,595,862 | 4 | false | 0 | 0 | Check if libmemcached is installed. If not found then install it with
brew install libmemcached and rest of things will work just fine.
I resolved this issue while installing django test suite. | 2 | 17 | 0 | I've tried pip and easy_install, but I keep getting the following error:
error: command '/usr/bin/llvm-gcc' failed with exit status 1
I'm running OSX Lion and the install runs inside a virtualenv, with Python 2.7.2.
Thanks in advance. | Error when trying to install pylibmc on Mac OSX Lion | 0.049958 | 0 | 0 | 8,279 |
9,070,218 | 2012-01-30T20:19:00.000 | 20 | 0 | 1 | 1 | python,osx-lion,pip,easy-install,llvm-gcc | 9,074,361 | 4 | true | 0 | 0 | First a question: is libmemcached installed? If not, install it and retry. It probably is but just in case....
If pylibmc still doesn't install the problem is probably that libmemcached is not installed in a directory where gcc can discover it (this was a macports symptom in my case), in which case you can store the lo... | 2 | 17 | 0 | I've tried pip and easy_install, but I keep getting the following error:
error: command '/usr/bin/llvm-gcc' failed with exit status 1
I'm running OSX Lion and the install runs inside a virtualenv, with Python 2.7.2.
Thanks in advance. | Error when trying to install pylibmc on Mac OSX Lion | 1.2 | 0 | 0 | 8,279 |
9,070,807 | 2012-01-30T21:10:00.000 | 1 | 0 | 0 | 1 | python,shell,applet,compiled | 9,071,041 | 2 | false | 0 | 0 | Not sure about generating another shell window, but do you need to have an entire shell open? What about getting the information to the user in a different way, such as:
use another Toplevel window and insert the output into a Text or Listbox, rather than simply printing it. This could also make it easier for users t... | 1 | 0 | 0 | I am trying to make an executable python program on MAC OSX. I used the build applet program and it runs, but I had some data printing in the shell window and the executable file does not open a window. Is there a way to open a shell window with an executable python program?
Thanks | Python shell window in compiled applet | 0.099668 | 0 | 0 | 451 |
9,071,031 | 2012-01-30T21:29:00.000 | 1 | 0 | 1 | 0 | python | 9,071,479 | 2 | true | 0 | 0 | Well, if you need the whole dataset in RAM, there's not much to do but get more RAM. Sounds like you aren't sure if you really need to, but keeping all the data resident requires the smallest amount of thinking :)
If your data comes in a stream over a long period of time, and all you are doing is creating a histogram,... | 2 | 3 | 1 | I have a scientific application that reads a potentially huge data file from disk and transforms it into various Python data structures such as a map of maps, list of lists etc. NumPy is called in for numerical analysis. The problem is, the memory usage can grow rapidly. As swap space is called in, the system slows dow... | How to handle large memory footprint in Python? | 1.2 | 0 | 0 | 294 |
9,071,031 | 2012-01-30T21:29:00.000 | 3 | 0 | 1 | 0 | python | 9,071,108 | 2 | false | 0 | 0 | Have you considered divide and conquer? Maybe your problem lends itself to that. One framework you could use for that is Map/Reduce.
Does your problem have multiple phases such that Phase I requires some data as input and generates an output which can be fed to phase II? In that case you can have 1 process do phase I a... | 2 | 3 | 1 | I have a scientific application that reads a potentially huge data file from disk and transforms it into various Python data structures such as a map of maps, list of lists etc. NumPy is called in for numerical analysis. The problem is, the memory usage can grow rapidly. As swap space is called in, the system slows dow... | How to handle large memory footprint in Python? | 0.291313 | 0 | 0 | 294 |
9,073,096 | 2012-01-31T01:01:00.000 | 1 | 0 | 1 | 1 | python,directory,inotify,pyinotify,spooler | 9,074,009 | 1 | false | 0 | 0 | You don't really want to move them as they're created, but rather as they're closed. Once they're closed (and nobody has any open file handles on them), you can consider them 'complete' and you can move them without any surprises.
You'll probably be good if you look for a 'close_write' event. (Although that doesn't gu... | 1 | 0 | 0 | im trying to move every file in a directory to another when they are created. Maybe i could stop the daemon (pyinotify instance running) cleanly, and the original files continue to be created in the orig/spool directory.
I want to be processed after the daemon starts again. Maybe i can take advantage of the inotify ker... | What is the best way to make a spool in a directory with pyinotify? | 0.197375 | 0 | 0 | 837 |
9,077,225 | 2012-01-31T09:31:00.000 | 1 | 0 | 1 | 0 | python,matlab,for-loop | 9,079,959 | 2 | false | 0 | 0 | In addition to the given answer, be aware that MATLAB's forloop is very slow.
Maybe programming in a functional style using arrayfun, cellfun() and structfun() might be a handier solution, and quite close to Python's map(). | 1 | 1 | 1 | May seem stupid, but after using Matlab for a while (a couple of years), I've tried Python, and despite some Matlab's features that are really handy, I really like Python.
Now, for work, I'm using Matlab again, and sometimes I miss a structure like Python's 'for' loop. Instead of using the standard 'for' that Matlab pr... | For cycle in Python's way in Matlab | 0.099668 | 0 | 0 | 273 |
9,077,687 | 2012-01-31T10:08:00.000 | 85 | 0 | 0 | 1 | python,message-queue,rabbitmq,celery | 9,287,371 | 3 | true | 0 | 0 | You are right, you don't need Celery at all. When you are designing a distributed system there are a lot of options and there is no right way to do things that fits all situations.
Many people find that it is more flexible to have pools of message consumers waiting for a message to appear on their queue, doing some wor... | 3 | 107 | 0 | From my understanding, Celery is a distributed task queue, which means the only thing that it should do is dispatching tasks/jobs to others servers and get the result back. RabbitMQ is a message queue, and nothing more. However, a worker could just listen to the MQ and execute the task when a message is received. This ... | Why use Celery instead of RabbitMQ? | 1.2 | 0 | 0 | 33,423 |
9,077,687 | 2012-01-31T10:08:00.000 | 34 | 0 | 0 | 1 | python,message-queue,rabbitmq,celery | 9,077,760 | 3 | false | 0 | 0 | Celery basically provides a nice interface to doing just what you said, and deals with all the configuration for you. Yes you could do it by hand, but you'd just be rewriting celery. | 3 | 107 | 0 | From my understanding, Celery is a distributed task queue, which means the only thing that it should do is dispatching tasks/jobs to others servers and get the result back. RabbitMQ is a message queue, and nothing more. However, a worker could just listen to the MQ and execute the task when a message is received. This ... | Why use Celery instead of RabbitMQ? | 1 | 0 | 0 | 33,423 |
9,077,687 | 2012-01-31T10:08:00.000 | 0 | 0 | 0 | 1 | python,message-queue,rabbitmq,celery | 71,103,053 | 3 | false | 0 | 0 | In my opinion, it's easy to integrate celery with flower and other monitoring packages than RabbitMQ.
It all depends on the use case anyways...
If you don't need other functionalities celery provides, RabbitMQ would be an easy way out. Weighing out your options wouldn't be a bad idea... | 3 | 107 | 0 | From my understanding, Celery is a distributed task queue, which means the only thing that it should do is dispatching tasks/jobs to others servers and get the result back. RabbitMQ is a message queue, and nothing more. However, a worker could just listen to the MQ and execute the task when a message is received. This ... | Why use Celery instead of RabbitMQ? | 0 | 0 | 0 | 33,423 |
9,078,776 | 2012-01-31T11:31:00.000 | 1 | 0 | 1 | 0 | python,geolocation,coordinates,geospatial,geographic-distance | 9,079,414 | 7 | false | 0 | 0 | Your dictionary idea doesn't sound that bad, though you will need to check points that fall under 'neighbouring' dictionary keys as well.
If you can't find the right tool, and like coding algorithms, you could implement a binary space partition tree which afaik is a less hacky way of achieving a similar thing. | 1 | 19 | 0 | Is there a Python module where I can create objects with a geographical location coordinate (latitude and longitude), and query all the objects for ones which are within a 5km distance (i.e. radius) of a given coordinate?
I've been trying to store the latitude and longitude as keys in dictionaries (as they're indexed b... | Python module for storing and querying geographical coordinates | 0.028564 | 0 | 0 | 11,350 |
9,078,985 | 2012-01-31T11:46:00.000 | 1 | 1 | 1 | 0 | python,python-3.x | 9,080,000 | 1 | false | 0 | 0 | (a) It makes sense
(b) If you really want to avoid it, then just delete the .py files from the egg.
(c) I bet one can reconstruct the full source (less comments) from .pyc files. | 1 | 1 | 0 | I just created an EGG file on a python project and it created a zip file which contained the source as well as the python compiled file(s). Does it make sense to ship the source as part of the EGG file, if so how can I avoid it during egg file creation? | Does it make sense to ship python source files as part of the egg file | 0.197375 | 0 | 0 | 121 |
9,079,036 | 2012-01-31T11:50:00.000 | 0 | 0 | 1 | 0 | python | 50,071,539 | 9 | false | 0 | 0 | Since all you are interested in is whether you have Python 2 or 3, a bit hackish but definitely the simplest and 100% working way of doing that would be as follows:
python
python_version_major = 3/2*2
The only drawback of this is that when there is Python 4, it will probably still give you 3. | 1 | 428 | 0 | I have a Python file which might have to support Python versions < 3.x and >= 3.x. Is there a way to introspect the Python runtime to know the version which it is running (for example, 2.6 or 3.2.x)? | How do I detect the Python version at runtime? | 0 | 0 | 0 | 336,423 |
9,080,634 | 2012-01-31T13:52:00.000 | 0 | 0 | 0 | 0 | python,beautifulsoup,mechanize | 9,081,637 | 3 | false | 1 | 0 | The most generic solution is to check that the </html> closing tag exists. That will allow you to detect truncation of the page.
Anything else, and you will have to describe your failure mode more clearly. | 2 | 0 | 0 | I am writing a basic screen scraping script using Mechanize and BeautifulSoup (BS) in Python. However, the problem I am running into is that for some reason the requested page does not download correctly every time. I am concluding this because when searching the downloaded pages using BS for present tags, I get an err... | Ensure a page has downloaded correctly in Python | 0 | 0 | 1 | 109 |
9,080,634 | 2012-01-31T13:52:00.000 | 0 | 0 | 0 | 0 | python,beautifulsoup,mechanize | 9,081,631 | 3 | false | 1 | 0 | I think you may simple search for html ending tag if this tag is in - this is a valid page. | 2 | 0 | 0 | I am writing a basic screen scraping script using Mechanize and BeautifulSoup (BS) in Python. However, the problem I am running into is that for some reason the requested page does not download correctly every time. I am concluding this because when searching the downloaded pages using BS for present tags, I get an err... | Ensure a page has downloaded correctly in Python | 0 | 0 | 1 | 109 |
9,081,123 | 2012-01-31T14:23:00.000 | 5 | 0 | 0 | 0 | python,django,architecture | 9,081,163 | 3 | false | 1 | 0 | (a) Django is a framework, not a language
(b) I'm not sure what you're missing - there is no reason why you can't have business logic in a web application. In Django, you would normally expect presentation logic to be separated from business logic. Just because it is hosted in the same application server, it doesn't fo... | 3 | 62 | 0 | I often see people claiming their backend is implemented in Django, but isn't Django supposed to be for the frontend? I'd assume the backend refers to the business logic where the frontend refers to the presentation. Am I missing something? | Is Django for the frontend or backend? | 0.321513 | 0 | 0 | 151,975 |
9,081,123 | 2012-01-31T14:23:00.000 | 107 | 0 | 0 | 0 | python,django,architecture | 9,081,179 | 3 | true | 1 | 0 | Neither.
Django is a framework, not a language. Python is the language in which Django is written.
Django is a collection of Python libs allowing you to quickly and efficiently create a quality Web application, and is suitable for both frontend and backend.
However, Django is pretty famous for its "Django admin", an au... | 3 | 62 | 0 | I often see people claiming their backend is implemented in Django, but isn't Django supposed to be for the frontend? I'd assume the backend refers to the business logic where the frontend refers to the presentation. Am I missing something? | Is Django for the frontend or backend? | 1.2 | 0 | 0 | 151,975 |
9,081,123 | 2012-01-31T14:23:00.000 | 13 | 0 | 0 | 0 | python,django,architecture | 9,082,219 | 3 | false | 1 | 0 | It seems you're actually talking about an MVC (Model-View-Controller) pattern, where logic is separated into various "tiers". Django, as a framework, follows MVC (loosely). You have models that contain your business logic and relate directly to tables in your database, views which in effect act like the controller, han... | 3 | 62 | 0 | I often see people claiming their backend is implemented in Django, but isn't Django supposed to be for the frontend? I'd assume the backend refers to the business logic where the frontend refers to the presentation. Am I missing something? | Is Django for the frontend or backend? | 1 | 0 | 0 | 151,975 |
9,083,687 | 2012-01-31T17:02:00.000 | 4 | 0 | 0 | 0 | python,user-interface,tkinter,osx-lion | 32,492,044 | 3 | false | 0 | 1 | I just faced the same issue and found the general cause. The problem with all the published workarounds is that they either don't work for a py2app-built executable (the '-topmost' workaround doesn't) or have serious side effects (the iconify/deiconify works but causes all future modal windows from the app to stop bein... | 1 | 1 | 0 | I have a simple Python script that loads a GUI (created with Tkinter) when run. I used py2app to convert the Python script into a double-click app for OSX. When the app is clicked, Python executes the script. However, Python (and the GUI) load minimized. The user has to click on the Python icon in the tray in order to ... | Python Tkinter GUI Always loads minimized | 0.26052 | 0 | 0 | 1,769 |
9,084,535 | 2012-01-31T17:58:00.000 | 1 | 0 | 1 | 0 | python,windows,api,gps | 9,085,744 | 2 | false | 0 | 0 | What library are you using for processing the GPS data? If you're using gpsd, I'd look to do the following:-
import gps
session - gps.gps()
time = session.utc, session.fix.time
You could then use the information provided by Skippy to update the system clock using the variable 'time' | 1 | 0 | 0 | We have two systems with built in GPS today I spent a little time, and I wrote some code to get the coordinate. My question is How can I get the GPS time and update the system clock under Windows 7 64bit? | Synchronizing windows clock using GPS | 0.099668 | 0 | 0 | 603 |
9,087,448 | 2012-01-31T21:48:00.000 | 1 | 0 | 1 | 1 | python,user-interface,cross-platform | 9,087,791 | 3 | false | 0 | 0 | I find that Python is a very good language for GUI programming. As you have stated, you can use the bindings for wxWidgets (wxPython), but there's also a binding for just about every other cross-platform GUI toolkit you can think of (Tk, Qt, GTK, FLTK, etc.). These GUI toolkits should allow you to make a program that w... | 1 | 1 | 0 | I'm talking about deploying Python-made, GUI-based, desktop applications via .app and .exe format for OSX and Windows. As far as I've gone into Python, I've only seen it as an application that runs on the Terminal / Command Prompt. I know that it is possible to create a user interface for it using various offerings on ... | How does Python come off as a multi-platform programming language? | 0.066568 | 0 | 0 | 643 |
9,087,589 | 2012-01-31T21:58:00.000 | 11 | 0 | 1 | 0 | python,printing,floating-point | 9,087,650 | 3 | true | 0 | 0 | Use '%+06.2f' to set the width and precision appropriately. The equivalent using new-style format strings is '{:+06.2f}'.format(n) (or '{0:+06.2f}' if your version of Python requires the positional component). | 1 | 10 | 0 | I need to format a float to the format +-00.00, tried the basic string formatting but can't get the leading + or - sign or two leading 0s if the value is fractional, any pointers? | Python, want to print float in exact format +-00.00 | 1.2 | 0 | 0 | 15,064 |
9,088,191 | 2012-01-31T22:48:00.000 | 0 | 0 | 0 | 0 | python,http,networking | 9,088,375 | 1 | true | 0 | 0 | You could create a web page with some javascript behind it with a timer and every 90 minutes or so have it programmatically log yourself in using javascript DOM methods.
If the login is done by using a cookie you could always modify the cookie to never expire. | 1 | 0 | 0 | I'm thinking of constantly pinging a website and use python http to send a POST request to the login server if the network is down. Any suggestions? | My internet connection requires a web based login after 90 minutes. What would be the best way to make sure I'm always online? | 1.2 | 0 | 1 | 200 |
9,089,476 | 2012-02-01T01:22:00.000 | 12 | 0 | 1 | 0 | python,autocomplete,codeblocks,python-idle | 16,467,896 | 5 | false | 0 | 1 | I had the same problem with IDLE, because I want to learn Qt and therefore autocompletion is very useful.
As it says in the settings of IDLE, you can trigger the autocomplete with "Control + Space", e.g. after a "QtGui.". Then a menu opens where you can arrow-scroll through the entries. | 4 | 19 | 0 | IDLE is being very dodgy as to when it will actually show an Auto-complete menu. As of late it hasn't been working at all, or, more specifically, only works during an interactive session.
I've been using Code Blocks for C, and have gotten really used to the very nice auto-complete features, so it's a bit frustrating n... | Python IDLE. Auto-complete/Show completions not working | 1 | 0 | 0 | 52,127 |
9,089,476 | 2012-02-01T01:22:00.000 | 0 | 0 | 1 | 0 | python,autocomplete,codeblocks,python-idle | 50,496,493 | 5 | false | 0 | 1 | using the 'IDLE Editor window', you need to save and execute your code first.
The application running, turn back to the Editor window to use the auto-completion. | 4 | 19 | 0 | IDLE is being very dodgy as to when it will actually show an Auto-complete menu. As of late it hasn't been working at all, or, more specifically, only works during an interactive session.
I've been using Code Blocks for C, and have gotten really used to the very nice auto-complete features, so it's a bit frustrating n... | Python IDLE. Auto-complete/Show completions not working | 0 | 0 | 0 | 52,127 |
9,089,476 | 2012-02-01T01:22:00.000 | 1 | 0 | 1 | 0 | python,autocomplete,codeblocks,python-idle | 49,978,980 | 5 | false | 0 | 1 | Sometimes it has to do with the time you have to wait to get a suggestions.
When you go to options > extensions > general at completions popup wait you can change it to about 500ms.
In my case it was 2000ms by default. | 4 | 19 | 0 | IDLE is being very dodgy as to when it will actually show an Auto-complete menu. As of late it hasn't been working at all, or, more specifically, only works during an interactive session.
I've been using Code Blocks for C, and have gotten really used to the very nice auto-complete features, so it's a bit frustrating n... | Python IDLE. Auto-complete/Show completions not working | 0.039979 | 0 | 0 | 52,127 |
9,089,476 | 2012-02-01T01:22:00.000 | 1 | 0 | 1 | 0 | python,autocomplete,codeblocks,python-idle | 39,969,989 | 5 | false | 0 | 1 | In my case, I had to open Options menu -> Extensions tab on the editor and look to make sure AutoComplete and other relevant options were enabled. They actually were, but by just clicking on 'Apply' even though I dint have to change anything did the trick for me. | 4 | 19 | 0 | IDLE is being very dodgy as to when it will actually show an Auto-complete menu. As of late it hasn't been working at all, or, more specifically, only works during an interactive session.
I've been using Code Blocks for C, and have gotten really used to the very nice auto-complete features, so it's a bit frustrating n... | Python IDLE. Auto-complete/Show completions not working | 0.039979 | 0 | 0 | 52,127 |
9,091,073 | 2012-02-01T05:05:00.000 | 2 | 0 | 0 | 0 | python,key,pygame,keypress | 9,091,093 | 1 | true | 0 | 1 | You can keep a state tracker for the keys you only want to recognize once per press - set a flag to True when you see a KEYDOWN event, and then set it to False again when you see a matching KEYUP. Then only respond to a KEYDOWN event if the flag wasn't already True.
The other option is that you can keep a state tracker... | 1 | 3 | 0 | In Pygame, you can set repeated (held down) Key detection with pygame.key.set_repeat().
In my case, I want to mix keys that can be held down and keys that will only be recognized once. Specifically, I want to be able to Move (by holding down key(s)), but I want to require one key press per Fire Missile.
To be clearer, ... | Pygame Mixing Repeated Key Presses and Singular Key Presses | 1.2 | 0 | 0 | 727 |
9,091,252 | 2012-02-01T05:31:00.000 | 0 | 0 | 1 | 0 | python,data-structures | 9,091,268 | 4 | false | 0 | 0 | Given that all data structures exist in memory, and memory is effectively just a list (array)... there is no data structure that couldn't be expressed in terms of the basic Python data structures (with appropriate code to interact with them). | 1 | 2 | 1 | Python has a lot of convenient data structures (lists, tuples, dicts, sets, etc) which can be used to make other 'conventional' data structures (Eg, I can use a Python list to create a stack and a collections.dequeue to make a queue, dicts to make trees and graphs, etc).
There are even third-party data structures that ... | Data structures with Python | 0 | 0 | 0 | 2,410 |
9,091,281 | 2012-02-01T05:37:00.000 | 0 | 0 | 1 | 0 | python,automation,cron | 9,091,488 | 2 | false | 0 | 0 | Write a wrapper python script that imports a, b and c and runs then in sequence (with error checking, notification and accounting). Then schedule this wrapper using the system cron daemon (if on UNIX). | 1 | 4 | 0 | How can I automate running of 3 python scripts. Suppose, I have 3 scripts say a.py,b.py and c.py.
Here a.py runs a web crawler and saves it as a xml file. Now b.py parses the xml file generated and saves as a pickle file. Now c.py inserts the list from pickle file to database.
Is there a way to automate this? | how to automate running a python script | 0 | 0 | 1 | 4,739 |
9,093,046 | 2012-02-01T08:50:00.000 | 0 | 1 | 1 | 0 | python,encryption,rsa,pycrypto | 13,454,184 | 3 | false | 0 | 0 | pycrypto has some shortcomings, in the fact that it only implements the bare-bones, low level encryption/decryption algorithms needed to implement RSA and does not implement a full protocol for public-key encryption.
The current version PyCrypto (2.6) does support all major RSA protocols for signature and encryption n... | 1 | 9 | 0 | I am currently working on a project using python to implement p2p communication between two (or more) computers. Although I am pretty proficient with python, I am by no means an expert; programming and encryption are by no means my profession, simply a hobby. However, in working on this project I have been attempting... | Implementing full RSA in Python | 0 | 0 | 0 | 6,921 |
9,095,758 | 2012-02-01T12:24:00.000 | 1 | 0 | 0 | 0 | javascript,python,ruby | 9,095,840 | 4 | false | 1 | 0 | String manipulation is pretty fast in the server side but it's fine to do on the client side too. However make sure to validate the string once it arrives at the server side because any client can replicate requests to your server with a string and try to cause trouble. | 4 | 1 | 0 | Whenever there is dilemma to do a particular task, which can be accomplished either by client side code or by using a server code, which should be preferred?
For example:
I can iterate through a javascript object and construct a string and then send it to server, or should i send the javascript object and process it in... | Design issue: client side or server side? | 0.049958 | 0 | 1 | 215 |
9,095,758 | 2012-02-01T12:24:00.000 | 0 | 0 | 0 | 0 | javascript,python,ruby | 9,095,857 | 4 | false | 1 | 0 | You must take into consideration a lot of factors, including and especially security ones. For example, if you must do some complicated form validation, then it is extremely important to do it server-side, even if that puts a little more load on the server.
Always keep in mind that a bad guy can change/break your javas... | 4 | 1 | 0 | Whenever there is dilemma to do a particular task, which can be accomplished either by client side code or by using a server code, which should be preferred?
For example:
I can iterate through a javascript object and construct a string and then send it to server, or should i send the javascript object and process it in... | Design issue: client side or server side? | 0 | 0 | 1 | 215 |
9,095,758 | 2012-02-01T12:24:00.000 | 1 | 0 | 0 | 0 | javascript,python,ruby | 9,096,236 | 4 | true | 1 | 0 | (This answer assumes a web programming context)
I personally put a lot of front-end logic in Javascript running on the client side, because it makes things very responsive, even for people with a slow connection. This also means that some functionality continues working even if the user goes offline. I find some progra... | 4 | 1 | 0 | Whenever there is dilemma to do a particular task, which can be accomplished either by client side code or by using a server code, which should be preferred?
For example:
I can iterate through a javascript object and construct a string and then send it to server, or should i send the javascript object and process it in... | Design issue: client side or server side? | 1.2 | 0 | 1 | 215 |
9,095,758 | 2012-02-01T12:24:00.000 | 0 | 0 | 0 | 0 | javascript,python,ruby | 9,095,862 | 4 | false | 1 | 0 | I am a django/python developer and my logic is "templates should be used for rendering". I keep my load minimum on the client side and all computation is done on the server side.
Another reason for doing this is because a user cannot be trusted. Keep the equation simple for the user. | 4 | 1 | 0 | Whenever there is dilemma to do a particular task, which can be accomplished either by client side code or by using a server code, which should be preferred?
For example:
I can iterate through a javascript object and construct a string and then send it to server, or should i send the javascript object and process it in... | Design issue: client side or server side? | 0 | 0 | 1 | 215 |
9,095,796 | 2012-02-01T12:27:00.000 | 1 | 0 | 0 | 0 | python,wxpython,python-2.5 | 9,095,942 | 2 | false | 0 | 1 | Instead of pickling the object, pickle the necessary attributes of the object required to reconstruct a new instance of the object. | 1 | 0 | 0 | how to pickle wx.frame(python GUI) object and unpickle it? | how to pickle wx.frame(python GUI) object and unpickle it? | 0.099668 | 0 | 0 | 460 |
9,097,097 | 2012-02-01T14:05:00.000 | 1 | 0 | 0 | 0 | python,wxpython,wxwidgets | 9,097,809 | 1 | true | 0 | 1 | I don't see an easy way to do this in the API other than just using a loop. There is a weird example in the wxPython demo for the ListCtrl where they somehow set a dict as the data for the list control. You might like that. Alternatively, I enjoy using the ObjectListView widget (http://pypi.python.org/pypi/ObjectListVi... | 1 | 0 | 0 | I want to set an array into a wxListCtrl.
Similar to the Set function when using wx.ListBox or the SetItems function when using wx.ComboBox.
On the wxpython API there only seems to be an Append function. | How to set an array to ListCtrl | 1.2 | 0 | 0 | 186 |
9,097,911 | 2012-02-01T14:52:00.000 | 0 | 0 | 1 | 0 | python | 9,297,208 | 4 | false | 1 | 0 | I have decided to adopt a process rather than a threaded approach to resolving this issue. The primary factor in this decision is simplicity. The second factor is whilst one of these applications will be carrying out data acquisition the other will be communicating with a modem on an ad-hoc basis (receiving calls) I do... | 3 | 4 | 0 | I currently have a couple of small applications < 500 lines. I am intending to eventually run them on a small LINUX ARM box. Is it better to combine these applications and use threading, or continue to have them as two separate applications?
These applications plus a very small website use a small sqlite database, thou... | Python should I use threading | 0 | 0 | 0 | 269 |
9,097,911 | 2012-02-01T14:52:00.000 | 2 | 0 | 1 | 0 | python | 9,098,387 | 4 | false | 1 | 0 | For performance purpose, I will suggest you to use threads, process consumes much more resources than threads, it will be faster to create and need less memory (usefull in embedded environment), but of course, you'll have to deal with the common traps of multithreading programmation (concurent access solved by locks, b... | 3 | 4 | 0 | I currently have a couple of small applications < 500 lines. I am intending to eventually run them on a small LINUX ARM box. Is it better to combine these applications and use threading, or continue to have them as two separate applications?
These applications plus a very small website use a small sqlite database, thou... | Python should I use threading | 0.099668 | 0 | 0 | 269 |
9,097,911 | 2012-02-01T14:52:00.000 | 4 | 0 | 1 | 0 | python | 9,097,976 | 4 | false | 1 | 0 | Depends on whether you need them to share data and how involved the sharing is. Other than that, from a speed point of view, for a multiprocessing machine, threading won't give you much of an advantage over separate processes.
If sharing can easily take place via a flat file or database then just let them be separate r... | 3 | 4 | 0 | I currently have a couple of small applications < 500 lines. I am intending to eventually run them on a small LINUX ARM box. Is it better to combine these applications and use threading, or continue to have them as two separate applications?
These applications plus a very small website use a small sqlite database, thou... | Python should I use threading | 0.197375 | 0 | 0 | 269 |
9,099,145 | 2012-02-01T16:09:00.000 | 56 | 1 | 1 | 0 | python,types | 9,099,337 | 4 | true | 0 | 0 | A bytearray is very similar to a regular python string (str in python2.x, bytes in python3) but with an important difference, whereas strings are immutable, bytearrays are mutable, a bit like a list of single character strings.
This is useful because some applications use byte sequences in ways that perform poorly with... | 1 | 50 | 0 | I recently came across the dataType called bytearray in python. Could someone provide scenarios where bytearrays are required? | Where are python bytearrays used? | 1.2 | 0 | 0 | 36,917 |
9,099,430 | 2012-02-01T16:28:00.000 | 0 | 0 | 1 | 0 | python,multithreading,pyqt4 | 9,099,478 | 3 | false | 0 | 0 | You can use condition variables and have your main thread wait on a message from the sub-thread. The sub-thread can signal the main thread to call that method. | 2 | 0 | 0 | I have a class that inherits from threading.Thread.
After processing an item from a queue I want it to call a function that I handed over to the thread when starting it. Doing that callback from the run-Method will have it run in my worker thread. Is there a way to run that callback inside the MainThread?
Thanks & Gre... | Do a callback from subclassed thread in main thread | 0 | 0 | 0 | 455 |
9,099,430 | 2012-02-01T16:28:00.000 | 0 | 0 | 1 | 0 | python,multithreading,pyqt4 | 9,099,472 | 3 | false | 0 | 0 | Push the method onto a queue and have the main thread sit and wait on that queue, running each method as it pulls them off. | 2 | 0 | 0 | I have a class that inherits from threading.Thread.
After processing an item from a queue I want it to call a function that I handed over to the thread when starting it. Doing that callback from the run-Method will have it run in my worker thread. Is there a way to run that callback inside the MainThread?
Thanks & Gre... | Do a callback from subclassed thread in main thread | 0 | 0 | 0 | 455 |
9,099,523 | 2012-02-01T16:34:00.000 | 0 | 0 | 1 | 0 | python,string,unicode,beautifulsoup | 41,417,621 | 2 | false | 1 | 0 | There should not be any problem just using python's str() method on the navigable string object you have. From my experience with NavigableString's they are already in unicode so if you want a string on which .lower will work then you need to cast it to a python string (UTF-8) then recast it back to unicode. | 1 | 2 | 0 | When I run the following code:
if substr in movie.lowercase:
I get the following error
AttributeError: 'NavigableString' object has no attribute 'lowercase'
movie is from here:
movie = row.td.div.h4.string
I tried to change it to (without success)
movie = row.td.div.h4.string.string
or
movie = unicode(row.td.div.h4.str... | converting NavigableString to unicode string | 0 | 0 | 0 | 7,115 |
9,099,618 | 2012-02-01T16:41:00.000 | 0 | 0 | 0 | 0 | python,browser,tkinter | 9,101,909 | 2 | false | 0 | 1 | Tkinter has no native support for displaying HTML. With a little bit of work you can download the raw html, do a little text manipulation (assuming it's mostly plain text and a few tags for bold, headers, etc), and display it in a text widget. If it's well formed xhtml you can use an xml parser to pull out the relevant... | 2 | 2 | 0 | I am writing a Python program and want at some point to load HTML pages from the web and display them, in particular the support forum section/news section of my program. How can I easily integrate that into my program? | How do i integrate a browser in my tk application? | 0 | 0 | 0 | 720 |
9,099,618 | 2012-02-01T16:41:00.000 | 3 | 0 | 0 | 0 | python,browser,tkinter | 9,133,448 | 2 | true | 0 | 1 | It would be easier to switch toolkits - Gtk+/Qt both have support for WebKit rendering engine. Both toolkits also have Python bindings support. | 2 | 2 | 0 | I am writing a Python program and want at some point to load HTML pages from the web and display them, in particular the support forum section/news section of my program. How can I easily integrate that into my program? | How do i integrate a browser in my tk application? | 1.2 | 0 | 0 | 720 |
9,099,852 | 2012-02-01T16:55:00.000 | 4 | 0 | 0 | 0 | python,python-3.x,pyramid,django-debug-toolbar | 9,115,036 | 1 | true | 0 | 0 | If you're using the system python and you're using Debian, you might need to install the "python-profiler" package via apt. | 1 | 1 | 0 | In fact it is not neccessary for me to have this tab active (I mean my most preferable tabs are sqlalchemy, renderings and request vars), but now I want to optimise my views, so I need this tab enabled. Strange that it works only with Python 3 (on two different computers). | Pyramid debug_toolbar: disabled perfomance tab with Python 2.6, but enabled with python 3.2 | 1.2 | 0 | 0 | 216 |
9,100,616 | 2012-02-01T17:46:00.000 | 13 | 1 | 1 | 0 | python,pylint | 9,100,718 | 2 | true | 0 | 0 | What are you using these classes for?
If they are just a grouping of functions that do not need to maintain any state, there is no need for an __init__() but it would make more sense to just move all of those functions into their own module.
If they do maintain a state (they have instance variables) then you should pro... | 2 | 22 | 0 | We have numerous python classes that do not seem to need __init__, initialising them empty is either perfectly acceptable or even preferable. PyLint seems to think this is a bad thing. Am I missing some insight into why having no __init__ is a Bad Smell? Or should I just suppress those warnings and get over it? | Why does PyLint warn about no __init__? | 1.2 | 0 | 0 | 9,818 |
9,100,616 | 2012-02-01T17:46:00.000 | 2 | 1 | 1 | 0 | python,pylint | 9,100,640 | 2 | false | 0 | 0 | Usually you will at least use the __init__() method to initialize instance variables. If you are not doing this, then by all means turn off that warning. | 2 | 22 | 0 | We have numerous python classes that do not seem to need __init__, initialising them empty is either perfectly acceptable or even preferable. PyLint seems to think this is a bad thing. Am I missing some insight into why having no __init__ is a Bad Smell? Or should I just suppress those warnings and get over it? | Why does PyLint warn about no __init__? | 0.197375 | 0 | 0 | 9,818 |
9,106,166 | 2012-02-02T02:04:00.000 | 3 | 1 | 1 | 0 | python | 9,106,241 | 4 | false | 0 | 0 | Even if you got it to work, this is probably less useful than you think since subsequent imports only copy the existing reference instead of executing the module again. | 2 | 2 | 0 | For imported module, is it possible to get the importing module (name)? I'm wondering if inspect can achieve it or not~ | Is it possible to get "importing module" in "imported module" in Python? | 0.148885 | 0 | 1 | 106 |
9,106,166 | 2012-02-02T02:04:00.000 | 3 | 1 | 1 | 0 | python | 9,106,211 | 4 | false | 0 | 0 | It sounds like you solved your own problem: use the inspect module. I'd traverse up the stack until I found a frame where the current function was not __import__. But I bet if you told people why you want to do this, they'd tell you not to. | 2 | 2 | 0 | For imported module, is it possible to get the importing module (name)? I'm wondering if inspect can achieve it or not~ | Is it possible to get "importing module" in "imported module" in Python? | 0.148885 | 0 | 1 | 106 |
9,106,997 | 2012-02-02T03:59:00.000 | 3 | 0 | 1 | 1 | python,locking,fork,fcntl,flock | 9,627,883 | 1 | true | 0 | 0 | lsof is almost certainly simply not showing flock() locks, so not seeing one tells you nothing about whether there is one.
flock() locks are inherited via fd-sharing (dup() system call, or fork-and-exec that leaves the file open) and anyone with the shared descriptor can unlock the lock, but if the lock is already held... | 1 | 7 | 0 | I have a pretty complicated python program. Internally it has a logging system that uses an exclusive (LOCK_EX) fcntl.flock to manage global locking. Effectively, whenever a log message is dumped, the global file lock is acquired, message is emitted to file (different from lock file) and global file lock is released.... | Deadlock with flock, fork and terminating parent process | 1.2 | 0 | 0 | 2,736 |
9,109,333 | 2012-02-02T08:45:00.000 | 19 | 0 | 1 | 0 | python,namespaces,python-3.x,reserved-words,naming-conventions | 9,109,488 | 4 | false | 0 | 0 | Yes it's bad practice. It might not immediately break anything for you, but it still hurts readability of the code.
To selectively quote from PEP20:
Beautiful is better than ugly.
Simple is better than complex.
Readability counts.
If the implementation is hard to explain, it's a bad idea.
Seeing a call to myobj... | 3 | 52 | 0 | I know to never use built-in function names as variable identifiers.
But are there any reasons not to use them as attribute or method identifiers?
For example, is it safe to write my_object.id = 5, or define an instance method dict in my own class? | Is it bad practice to use a built-in function name as an attribute or method identifier? | 1 | 0 | 0 | 17,150 |
9,109,333 | 2012-02-02T08:45:00.000 | 11 | 0 | 1 | 0 | python,namespaces,python-3.x,reserved-words,naming-conventions | 9,109,359 | 4 | false | 0 | 0 | No, that's fine. Since an object reference is required there is no way to have them shadow the built-in. | 3 | 52 | 0 | I know to never use built-in function names as variable identifiers.
But are there any reasons not to use them as attribute or method identifiers?
For example, is it safe to write my_object.id = 5, or define an instance method dict in my own class? | Is it bad practice to use a built-in function name as an attribute or method identifier? | 1 | 0 | 0 | 17,150 |
9,109,333 | 2012-02-02T08:45:00.000 | 42 | 0 | 1 | 0 | python,namespaces,python-3.x,reserved-words,naming-conventions | 9,109,489 | 4 | true | 0 | 0 | It won't confuse the interpreter but it may confuse people reading your code. Unnecessary use of builtin names for attributes and methods should be avoided.
Another ill-effect is that shadowing builtins confuses syntax highlighters in most python-aware editors (vi, emacs, pydev, idle, etc.) Also, some of the lint too... | 3 | 52 | 0 | I know to never use built-in function names as variable identifiers.
But are there any reasons not to use them as attribute or method identifiers?
For example, is it safe to write my_object.id = 5, or define an instance method dict in my own class? | Is it bad practice to use a built-in function name as an attribute or method identifier? | 1.2 | 0 | 0 | 17,150 |
9,110,305 | 2012-02-02T09:59:00.000 | 1 | 0 | 0 | 1 | python,subprocess,popen | 9,627,884 | 1 | true | 0 | 0 | You can always send something to sub-process even it read nothing. So you just sent to sub-process, if it works OK, then those staff you sent will be dropped, if it failed, then you will read response. | 1 | 1 | 0 | I start a process with POpen and under normal circuimstances it should just do a job and write things to stdout which I then capture. In exceptional cases the process will fallback to an interactive mode and wait for user input. How can I detect that case and react appropriately? | Test if a Popen process is waiting for input | 1.2 | 0 | 0 | 619 |
9,112,571 | 2012-02-02T12:47:00.000 | 0 | 0 | 0 | 0 | python,django,orm | 9,112,738 | 6 | false | 1 | 0 | One of the biggest problem that come to mind is that Building inheritance into Django ORM's is difficult. Essentially this is due to the fact that (Django) ORM layers are trying to bridge the gap by being both relational & OO. Another thing is of course multiple field foreign keys.
One charge leveled at Django ORM is t... | 1 | 20 | 0 | I've heard developers not wanting to use ORM, but don't know why. What are the shortcomings of the ORM? | What are the limitations of Django's ORM? | 0 | 0 | 0 | 8,580 |
9,112,784 | 2012-02-02T13:02:00.000 | 0 | 0 | 1 | 0 | python,heroku,pip | 9,112,921 | 4 | false | 1 | 0 | You can write, say, "-e git+ssh://git@.../PIL#egg=PIL" instead of "PIL" in your requirements.txt file and it'll fetch it from there.
However, this would require you to somehow specify the ssh private key to be used by heroku when pulling. | 1 | 9 | 0 | We have a few in-house libraries that we've split off (for several reasons, mostly administrative or to have the possibility to easily open source them later). They live in private Github repositories, if that matters.
I'd like to deploy an app to Heroku to try it out. It depends on one of those libraries.
I'm supposed... | How do I install in-house requirements for Python Heroku projects? | 0 | 0 | 0 | 1,227 |
9,113,717 | 2012-02-02T14:07:00.000 | 11 | 0 | 0 | 0 | python,gtk3 | 9,114,062 | 1 | false | 0 | 1 | Every TextView widget is associated to a TextBuffer object. The signal you are looking for is changed but of the associated text buffer. If you create a TextView without an associated buffer, a default one is created for you and you can retrieve it with textview.get_buffer() | 1 | 5 | 0 | How can I find out when the text has been changed in a text view widget in the GTK3 framework? I think there must be a signal associated with it, but could not find it.
For example, there is an ontextchanged signal in qt4, so there should be a similar signal in GTK. I am using Python. | Text changed signal for Text View widget in GTK3 | 1 | 0 | 0 | 1,337 |
9,115,979 | 2012-02-02T16:29:00.000 | 6 | 0 | 1 | 0 | python,mongodb | 9,116,463 | 1 | true | 0 | 0 | You can represent a set using a dictionary. Your elements become the keys, and all the values can be set to a constant such as 1. The in operator checks for the existence of a key.
EDIT. MongoDB stores a dict as a BSON document, where the keys must be strings (with some additional restrictions), so the above advice is ... | 1 | 5 | 0 | I am building a web App with mongoDB as the backend. Some of the documents need to store a collection of items in some sort of list, and then the system will need to frequently check if a specified item is present in that list. Using Python's 'in' operator takes Big-O(N) time, n being the size of the list. Since the... | Mongodb with Python's "set()" type | 1.2 | 1 | 0 | 2,402 |
9,117,349 | 2012-02-02T17:54:00.000 | 1 | 0 | 1 | 0 | python,google-refine | 9,130,062 | 2 | false | 0 | 0 | I'm going to mark reclosedev's answer as accepted, but there's still a litle more to the story.
The other answer to this question is that you can set up your own python-based API. For this project, I was able to set up a django app running on a local server. It only took an hour or so to build the API to my existing ... | 1 | 2 | 0 | I'm investigating Google refine to speed up some of my data work -- never used it before this week, but I like a lot of what I see.
My biggest question so far is whether it's possible to call external python functions from Refine. I know you can call jython internally, but that doesn't provide access to C-based python... | Can I call external *python* functions from google refine? | 0.099668 | 0 | 0 | 507 |
9,117,378 | 2012-02-02T17:56:00.000 | 8 | 1 | 0 | 0 | php,python,mysql,html,utf-8 | 9,117,402 | 2 | false | 0 | 0 | This is indeed wildly different. One place will accept only one form; the other place will only accept the other.
Listing here which is correct in which situation is not a good idea - it would be a huge and pointless open-ended list. Simply always look up in the respective documentation which form(s) is/are accepted fo... | 1 | 4 | 0 | In many different code environments' official documentation I see UTF-8 expressed either as upper- or lower- case, and also with and without the dash. Are there any places where one or the other is important to use?
Some places where these strings are found include:
The PHP manual in reference to header() arguments (H... | Are there any places where utf8 vs. utf-8 vs. UTF8 vs. UTF-8 makes a difference? | 1 | 0 | 0 | 699 |
9,117,565 | 2012-02-02T18:09:00.000 | 2 | 0 | 1 | 0 | python,enthought | 9,117,678 | 1 | true | 0 | 0 | It's no problem to have multiple Pythons on your machine. I currently have 2.5, 2.6, 2.7, 3.0, 3.1 and 3.2. Where it can get a little more complicated is if you want to have multiple installations of the same version, i.e. two different distributions based on 2.7, say. But that's not what you are doing here so you have... | 1 | 0 | 0 | I had already installed Python 3.2 on my development computer. It was mainly for exploring it.
Now I have to perform some "real" work, modifying then porting to C++ something in Python, but using the Enthought (EPD Free) package, that depends on Python 2.7.
Do you think I should uninstall Python 3.2, are there any pos... | Should I uninstall Python 3.2 when installing Python 2.7 from the Enthought Python Distribution? | 1.2 | 0 | 0 | 728 |
9,117,566 | 2012-02-02T18:09:00.000 | 1 | 0 | 1 | 1 | python,subprocess,kill | 9,119,121 | 2 | true | 0 | 0 | Not exactly easy, but if your application runs in Linux, you could walk through the /proc filesystem and build a list of all PIDs whose PPID (parent PID) is the same as your subprocess'. | 1 | 1 | 0 | Does python provide a way to find the children of a child process spawned using subprocess, so that I can kill them properly? If not, what is a good way of ensuring that the children of a child are killed? | Killing children of children in python with subprocess | 1.2 | 0 | 0 | 484 |
9,117,590 | 2012-02-02T18:11:00.000 | 2 | 0 | 0 | 0 | python,django,django-urls | 9,117,883 | 2 | false | 1 | 0 | Use the application name in the url tag, e.g. {% url myapp.views.contest_overview %} | 1 | 0 | 0 | Okay I am having a bit of an issue.
I want to create a button with a link, and right now I am using action={% url views.contest_overview %} in hopes that the reverse lookup by Django will match (r'^category/$', views.contest_overview), in my urls.py. However, this is not working and I can't figure out the proper no... | Django url template confusion | 0.197375 | 0 | 0 | 163 |
9,119,330 | 2012-02-02T20:16:00.000 | 10 | 0 | 1 | 0 | python | 9,119,349 | 6 | false | 0 | 0 | Dictionaries are unordered data structures, so you should have no expectations | 1 | 2 | 0 | Ladies and Gents,
I have a question about dictionaries in python. While playing around I noticed something that to me seems strange.
I define a dict like this
stuff={'age':26,'name':'Freddie Mercury', 'ciy':'Vladivostok'}
I then add the word 'first' to stuff like this:
stuff[1]='first'
When I print it out, it's fine... | how is a dictionary sorted? | 1 | 0 | 0 | 352 |
9,121,255 | 2012-02-02T22:55:00.000 | 2 | 0 | 1 | 0 | python,gtk,pygtk,vala | 9,122,595 | 1 | false | 0 | 1 | A lot of Gnome apps are currently being rewritten in vala. This gives better performance and a better integration with the gtk libraries.
I personally think the language is pretty good, for a compiled language, but no doubt it is not as powerful or widely used as python.
If you are building an open source app (or somet... | 1 | 3 | 0 | I am working on cloud storage project and want to build GTK client for it. Possible choices found are pygtk/glade and vala. For the moment I am not familiar neither with pygtk nor with vala. Some googling showed that vala is quite a good choice. But I know python and completely new to vala. So I am looking for very str... | GTK GUI: pygtk vs vala | 0.379949 | 0 | 0 | 2,190 |
9,123,057 | 2012-02-03T02:47:00.000 | 2 | 0 | 1 | 0 | python,datetime | 9,123,081 | 1 | true | 0 | 0 | I would say it may not print microseconds if it happens to be exactly 0. | 1 | 0 | 0 | From logs that my program wrote, I called 33,5k times datetime.now() and 35 times I got datetime in this format: 2012-01-27 21:28:31 and it is supposed to look like this: 2012-01-29 02:20:03.026000. Why this is happening?
UPDATE:
I found it when I wanted to do this: datetime.strptime(my_datetime_variable, "%Y-%m-%d %H:... | datetime.now() sometimes (in same loop) change format and omit %f(microseconds)? Why? | 1.2 | 0 | 0 | 133 |
9,123,764 | 2012-02-03T04:40:00.000 | 2 | 0 | 0 | 0 | python,amazon-mws | 9,312,763 | 1 | false | 1 | 0 | The general gist of it is you use SubmitFeed to send your product list. Then you must check the status of the submission. Once the submission is complete you can then get the results. You have to repeat these steps for images, pricing and availability.
It's a bit of a pain to get started with it, Amazon supply a LOT of... | 1 | 6 | 0 | I heard SubmitFeed API is for adding products. But i didn't find any example.
By the way, i need a Python solution.
Thanks a lot. | How to upload/publish products to Amazon via Amazon MWS API? | 0.379949 | 0 | 1 | 2,077 |
9,124,657 | 2012-02-03T06:36:00.000 | 2 | 0 | 0 | 0 | python,process,cron | 9,126,061 | 3 | false | 0 | 0 | If you really want to run it as fast as possible, there is an alternative to using cron which is write the python program as an endless loop and then start it as a background process using nohup python script.py &. The output of the python process will then be written in nohup.out. | 2 | 3 | 0 | I need to write a python script that constantly checks a remote web service for updates. The faster it loops the better.
How do I get a script to run on my server over and over again without me having to manually start it each time? And if the server crashes or something, how does this script automatically start up aga... | constantly running a script on my server | 0.132549 | 0 | 1 | 3,351 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.