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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
166,364 | 2008-10-03T11:10:00.000 | 0 | 0 | 0 | 0 | python,django,apache,session,mod-python | 166,509 | 5 | false | 1 | 0 | Do you have standard database-driven sessions? Is caching enabled in settings? | 4 | 2 | 0 | I am running a Django through mod_python on Apache on a linux box. I have a custom authentication backend, and middleware that requires authentication for all pages, except static content.
My problem is that after I log in, I will still randomly get the log in screen now and again. It seems to me that each apache proce... | Django, mod_python, apache and wacky sessions | 0 | 0 | 0 | 1,356 |
166,944 | 2008-10-03T13:44:00.000 | 7 | 1 | 0 | 1 | php,python | 167,205 | 9 | false | 0 | 0 | I do this kind of thing all the time for quick-and-dirty scripts. It's quite common to have a CGI or PHP script that just uses system/popen to call some external program.
Just be extra careful if your web server is open to the internet at large. Be sure to sanitize your GET/POST input in this case so as to not allow ... | 2 | 85 | 0 | I have a Python script I recently wrote that I call using the command line with some options. I now want a very thin web interface to call this script locally on my Mac.
I don't want to go through the minor trouble of installing mod_python or mod_wsgi on my Mac, so I was just going to do a system() or popen() from PHP ... | Calling Python in PHP | 1 | 0 | 0 | 180,160 |
166,944 | 2008-10-03T13:44:00.000 | 0 | 1 | 0 | 1 | php,python | 45,592,623 | 9 | false | 0 | 0 | Note that if you are using a virtual environment (as in shared hosting) then you must adjust your path to python, e.g: /home/user/mypython/bin/python ./cgi-bin/test.py | 2 | 85 | 0 | I have a Python script I recently wrote that I call using the command line with some options. I now want a very thin web interface to call this script locally on my Mac.
I don't want to go through the minor trouble of installing mod_python or mod_wsgi on my Mac, so I was just going to do a system() or popen() from PHP ... | Calling Python in PHP | 0 | 0 | 0 | 180,160 |
168,409 | 2008-10-03T19:10:00.000 | -5 | 0 | 1 | 0 | python,windows,directory | 168,430 | 19 | false | 0 | 0 | Maybe you should use shell commands. In Unix/Linux, find piped with sort will probably be able to do what you want. | 1 | 174 | 0 | What is the best way to get a list of all files in a directory, sorted by date [created | modified], using python, on a windows machine? | How do you get a directory listing sorted by creation date in python? | -1 | 0 | 0 | 249,871 |
169,810 | 2008-10-04T05:36:00.000 | 3 | 0 | 0 | 0 | python,animation,2d | 1,568,711 | 3 | false | 0 | 1 | You can try pygame, its very easy to handle and similar to SDL under c++ | 1 | 12 | 1 | I'm writing a simulator in Python, and am curious about options and opinions regarding basic 2D animations. By animation, I'm referring to rendering on the fly, not displaying prerendered images.
I'm currently using matplotlib (Wxagg backend), and it's possible that I'll be able to continue using it, but I suspect it w... | 2D animation in Python | 0.197375 | 0 | 0 | 29,957 |
170,426 | 2008-10-04T14:28:00.000 | 0 | 1 | 1 | 0 | python,performance,python-3.x,python-2.x | 170,568 | 6 | false | 0 | 0 | I don't if it faster now, but I have to expect that it eventually will be because that is where new performance work will happen and not all of that will be backported. | 4 | 24 | 0 | On a question of just performance, how does Python 3 compare to Python 2.x? | Performance: Python 3.x vs Python 2.x | 0 | 0 | 0 | 10,338 |
170,426 | 2008-10-04T14:28:00.000 | 3 | 1 | 1 | 0 | python,performance,python-3.x,python-2.x | 170,797 | 6 | false | 0 | 0 | Unless there are plans for a new VM of some kind (and I haven't heard of any such plans), there is all the reason to believe that in the long run the performance of Py3K will, at least asymptotically, equal that of 2.5
It may take a few months, but will eventually happen, as nothing in the new features of Py3k is inher... | 4 | 24 | 0 | On a question of just performance, how does Python 3 compare to Python 2.x? | Performance: Python 3.x vs Python 2.x | 0.099668 | 0 | 0 | 10,338 |
170,426 | 2008-10-04T14:28:00.000 | 4 | 1 | 1 | 0 | python,performance,python-3.x,python-2.x | 170,805 | 6 | false | 0 | 0 | I think ultimately it is too early to make that kind of comparison just yet. Wait until it is out of beta before benchmarking it. The interpreter will probably be polished enormously before the release but overall i think for most uses the performance would be comparable and if you are running a really speed conscious ... | 4 | 24 | 0 | On a question of just performance, how does Python 3 compare to Python 2.x? | Performance: Python 3.x vs Python 2.x | 0.132549 | 0 | 0 | 10,338 |
170,426 | 2008-10-04T14:28:00.000 | 7 | 1 | 1 | 0 | python,performance,python-3.x,python-2.x | 170,521 | 6 | false | 0 | 0 | I'd say any difference will be below trivial. For example, looping over a list will be the exact same.
The idea behind Python 3 is to clean up the language syntax itself - remove ambigious stuff like except Exception1, Exception2, cleanup the standard modules (no urllib, urllib2, httplib etc).
There really isn't much y... | 4 | 24 | 0 | On a question of just performance, how does Python 3 compare to Python 2.x? | Performance: Python 3.x vs Python 2.x | 1 | 0 | 0 | 10,338 |
170,563 | 2008-10-04T16:00:00.000 | 1 | 0 | 1 | 0 | python,python-3.x | 709,574 | 7 | false | 0 | 0 | I remember Adrian (BFDL of django) saying that Guido had given them a time frame of 5 years to port. | 6 | 13 | 0 | Does anyone have an idea how long it will take before "almost all" widely used Python libraries work with Python 3.0?
I am planning to stay on 2.X for a while because I don't want to start porting stuff over and then find that some library I already rely on or a new library I might start using doesn't work yet with py3... | When will most libraries be Python 3 compliant? | 0.028564 | 0 | 0 | 2,267 |
170,563 | 2008-10-04T16:00:00.000 | 1 | 0 | 1 | 0 | python,python-3.x | 172,026 | 7 | false | 0 | 0 | The general idea in the migration plan is to stay on 2.x and then slowly change the code to 3.x. You will have at least 1.5 years to worry about it in. Of course there's the chicken and egg problem though. | 6 | 13 | 0 | Does anyone have an idea how long it will take before "almost all" widely used Python libraries work with Python 3.0?
I am planning to stay on 2.X for a while because I don't want to start porting stuff over and then find that some library I already rely on or a new library I might start using doesn't work yet with py3... | When will most libraries be Python 3 compliant? | 0.028564 | 0 | 0 | 2,267 |
170,563 | 2008-10-04T16:00:00.000 | 1 | 0 | 1 | 0 | python,python-3.x | 170,680 | 7 | false | 0 | 0 | Some comments I saw in the CherryPy repository is that some of the changes to the sockets module are going to require an extensive reworking of the logic. I expect CherryPy will be slower than some of the other projects to get ported to 3.0. | 6 | 13 | 0 | Does anyone have an idea how long it will take before "almost all" widely used Python libraries work with Python 3.0?
I am planning to stay on 2.X for a while because I don't want to start porting stuff over and then find that some library I already rely on or a new library I might start using doesn't work yet with py3... | When will most libraries be Python 3 compliant? | 0.028564 | 0 | 0 | 2,267 |
170,563 | 2008-10-04T16:00:00.000 | 4 | 0 | 1 | 0 | python,python-3.x | 170,613 | 7 | false | 0 | 0 | The examples you have listed will probably be ported very quickly, as they are so widely used.
I would be surprised if BeautifulSoup takes more than a month (In fact, I'm surprised it hasn't been ported already using the py3k betas), more complex things like numpy may take a big longer, especially because 2to3 only wor... | 6 | 13 | 0 | Does anyone have an idea how long it will take before "almost all" widely used Python libraries work with Python 3.0?
I am planning to stay on 2.X for a while because I don't want to start porting stuff over and then find that some library I already rely on or a new library I might start using doesn't work yet with py3... | When will most libraries be Python 3 compliant? | 0.113791 | 0 | 0 | 2,267 |
170,563 | 2008-10-04T16:00:00.000 | 0 | 0 | 1 | 0 | python,python-3.x | 710,561 | 7 | false | 0 | 0 | The libraries you mention will be ported once someone puts some serious time into porting them.
In the specific case of NumPy/SciPy, a large part of the code is written as C extensions. There is no 2to3 tool for C extensions and so it will take a large amount of man hours to port the code over to the format that cPyth... | 6 | 13 | 0 | Does anyone have an idea how long it will take before "almost all" widely used Python libraries work with Python 3.0?
I am planning to stay on 2.X for a while because I don't want to start porting stuff over and then find that some library I already rely on or a new library I might start using doesn't work yet with py3... | When will most libraries be Python 3 compliant? | 0 | 0 | 0 | 2,267 |
170,563 | 2008-10-04T16:00:00.000 | 4 | 0 | 1 | 0 | python,python-3.x | 170,724 | 7 | false | 0 | 0 | Actually, the reply to your question depends on the actions of so many different people (all the maintainers of libraries outside the Python std lib), that I think that no-one can give you a reliable answer to your question.
That said, you've had already some answers, and you will have more. We agree on one thing, thou... | 6 | 13 | 0 | Does anyone have an idea how long it will take before "almost all" widely used Python libraries work with Python 3.0?
I am planning to stay on 2.X for a while because I don't want to start porting stuff over and then find that some library I already rely on or a new library I might start using doesn't work yet with py3... | When will most libraries be Python 3 compliant? | 0.113791 | 0 | 0 | 2,267 |
171,267 | 2008-10-05T00:42:00.000 | 5 | 1 | 0 | 1 | python,unix,shell | 171,271 | 7 | false | 0 | 0 | Well, there's emacs, which is arguably a shell written in lisp :)
Seriously though, are you looking for a reimplementation of an existing shell design in a different language such as Python? Or are you looking for a new implementation of a shell language that looks similar to your language of choice? | 3 | 9 | 0 | Has anyone ever heard of a UNIX shell written in a reasonable language, like Python? | UNIX shell written in a reasonable language? | 0.141893 | 0 | 0 | 3,377 |
171,267 | 2008-10-05T00:42:00.000 | 6 | 1 | 0 | 1 | python,unix,shell | 171,304 | 7 | false | 0 | 0 | From all appearances, Python IS a shell. It runs with #! and it can run interactively. Between the os and shutil packages you have all of the features of standard Unix shells.
Since you can do anything in Python with simple, powerful scripts, you don't really need to spend any time messing with the other shells. | 3 | 9 | 0 | Has anyone ever heard of a UNIX shell written in a reasonable language, like Python? | UNIX shell written in a reasonable language? | 1 | 0 | 0 | 3,377 |
171,267 | 2008-10-05T00:42:00.000 | 3 | 1 | 0 | 1 | python,unix,shell | 171,290 | 7 | false | 0 | 0 | Tclsh is pretty nice (assuming you like Tcl, of course). | 3 | 9 | 0 | Has anyone ever heard of a UNIX shell written in a reasonable language, like Python? | UNIX shell written in a reasonable language? | 0.085505 | 0 | 0 | 3,377 |
171,694 | 2008-10-05T08:27:00.000 | 5 | 0 | 1 | 0 | python,fonts,wxpython | 184,571 | 4 | true | 0 | 1 | You can do this by calling SetFont on the parent window (Frame, Dialog, etc) before adding any widgets. The child widgets will inherit the font. | 1 | 3 | 0 | Many times I will use the same font scheme for static text in a wxPython application. Currently I am making a SetFont() call for each static text object but that seems like a lot of unnecessary work. However, the wxPython demo and wxPython In Action book don't discuss this.
Is there a way to easily apply the same SetFo... | Applying a common font scheme to multiple objects in wxPython | 1.2 | 0 | 0 | 1,595 |
171,785 | 2008-10-05T10:09:00.000 | 5 | 0 | 1 | 1 | python,module | 172,007 | 8 | false | 0 | 0 | In addition to PEP8 and easy_install, you should check out virtualenv. Virtualenv allows you to have multiple different python library trees. At work, we use virtualenv with a bootstrapping environment to quickly set up a development/production environment where we are all in sync w.r.t library versions etc. We general... | 2 | 14 | 0 | When it comes to organizing python modules, my Mac OS X system is a mess. I've packages lying around everywhere on my hdd and no particular system to organize them.
How do you keep everything manageable? | How do you organize Python modules? | 0.124353 | 0 | 0 | 6,801 |
171,785 | 2008-10-05T10:09:00.000 | 5 | 0 | 1 | 1 | python,module | 172,538 | 8 | false | 0 | 0 | There are several families of Python componentry.
The stuff that comes with Python. This takes care of itself.
The stuff that you got with easy_install. This, also, takes care of itself.
The packages that you had to get some other way, either as TARballs or SVN checkouts. Create a Components folder. Put the downloa... | 2 | 14 | 0 | When it comes to organizing python modules, my Mac OS X system is a mess. I've packages lying around everywhere on my hdd and no particular system to organize them.
How do you keep everything manageable? | How do you organize Python modules? | 0.124353 | 0 | 0 | 6,801 |
172,040 | 2008-10-05T14:08:00.000 | 3 | 0 | 0 | 0 | python,django,openid | 172,137 | 7 | false | 1 | 0 | You could probably use the django OpenID library to write a provider to test against. Have one that always authenticates and one that always fails. | 1 | 41 | 0 | I'm developing a website (in Django) that uses OpenID to authenticate users. As I'm currently only running on my local machine I can't authenticate using one of the OpenID providers on the web. So I figure I need to run a local OpenID server that simply lets me type in a username and then passes that back to my main ap... | How do you develop against OpenID locally | 0.085505 | 0 | 0 | 3,845 |
172,306 | 2008-10-05T17:08:00.000 | 2 | 0 | 1 | 0 | python,migration,python-3.x,python-2to3 | 5,324,553 | 7 | false | 0 | 0 | The Zope Toolkit has been in a slow progress to Python 3 support. Slow mainly because many of these libraries are very complex.
For most libraries I use 2to3. Some libraries make do without it because they are simple or have most of the code in a C-extension. zc.buildout, which is a related package, will run the same ... | 4 | 52 | 0 | I'm sure this is a subject that's on most python developers' minds considering that Python 3 is coming out soon. Some questions to get us going in the right direction:
Will you have a python 2 and python 3 version to be maintained concurrently or will you simply have a python 3 version once it's finished?
Have you a... | How are you planning on handling the migration to Python 3? | 0.057081 | 0 | 0 | 10,198 |
172,306 | 2008-10-05T17:08:00.000 | 3 | 0 | 1 | 0 | python,migration,python-3.x,python-2to3 | 172,313 | 7 | false | 0 | 0 | Speaking as a library author:
I'm waiting for the final version to be released. My belief, like that of most of the Python community, is that 2.x will continue to be the dominant version for a period of weeks or months. That's plenty of time to release a nice, polished 3.x release.
I'll be maintaining separate 2.x and ... | 4 | 52 | 0 | I'm sure this is a subject that's on most python developers' minds considering that Python 3 is coming out soon. Some questions to get us going in the right direction:
Will you have a python 2 and python 3 version to be maintained concurrently or will you simply have a python 3 version once it's finished?
Have you a... | How are you planning on handling the migration to Python 3? | 0.085505 | 0 | 0 | 10,198 |
172,306 | 2008-10-05T17:08:00.000 | 5 | 0 | 1 | 0 | python,migration,python-3.x,python-2to3 | 172,350 | 7 | false | 0 | 0 | The main idea of 2.6 is to provide a migration path to 3.0. So you can use from __future__ import X slowly migrating one feature at a time until you get all of them nailed down and can move to 3.0. Many of the 3.0 features will flow into 2.6 as well, so you can make the language gap smaller gradually rather than having... | 4 | 52 | 0 | I'm sure this is a subject that's on most python developers' minds considering that Python 3 is coming out soon. Some questions to get us going in the right direction:
Will you have a python 2 and python 3 version to be maintained concurrently or will you simply have a python 3 version once it's finished?
Have you a... | How are you planning on handling the migration to Python 3? | 0.141893 | 0 | 0 | 10,198 |
172,306 | 2008-10-05T17:08:00.000 | 0 | 0 | 1 | 0 | python,migration,python-3.x,python-2to3 | 174,305 | 7 | false | 0 | 0 | Some of my more complex 2.x code is going to stay at 2.5 or 2.6.
I am moving onto 3.0 for all new development once some of the 3rd party libraries I use often have been updated for 3. | 4 | 52 | 0 | I'm sure this is a subject that's on most python developers' minds considering that Python 3 is coming out soon. Some questions to get us going in the right direction:
Will you have a python 2 and python 3 version to be maintained concurrently or will you simply have a python 3 version once it's finished?
Have you a... | How are you planning on handling the migration to Python 3? | 0 | 0 | 0 | 10,198 |
172,720 | 2008-10-05T21:46:00.000 | 3 | 1 | 1 | 0 | python,optimization,performance | 172,782 | 19 | false | 0 | 0 | Just a note on using psyco: In some cases it can actually produce slower run-times. Especially when trying to use psyco with code that was written in C. I can't remember the the article I read this, but the map() and reduce() functions were mentioned specifically. Luckily you can tell psyco not to handle specified fun... | 7 | 46 | 0 | This is really two questions, but they are so similar, and to keep it simple, I figured I'd just roll them together:
Firstly: Given an established python project, what are some decent ways to speed it up beyond just plain in-code optimization?
Secondly: When writing a program from scratch in python, what are some goo... | Speeding Up Python | 0.031568 | 0 | 0 | 22,486 |
172,720 | 2008-10-05T21:46:00.000 | 4 | 1 | 1 | 0 | python,optimization,performance | 172,737 | 19 | false | 0 | 0 | Run your app through the Python profiler.
Find a serious bottleneck.
Rewrite that bottleneck in C.
Repeat. | 7 | 46 | 0 | This is really two questions, but they are so similar, and to keep it simple, I figured I'd just roll them together:
Firstly: Given an established python project, what are some decent ways to speed it up beyond just plain in-code optimization?
Secondly: When writing a program from scratch in python, what are some goo... | Speeding Up Python | 0.04208 | 0 | 0 | 22,486 |
172,720 | 2008-10-05T21:46:00.000 | 4 | 1 | 1 | 0 | python,optimization,performance | 172,766 | 19 | false | 0 | 0 | People have given some good advice, but you have to be aware that when high performance is needed, the python model is: punt to c. Efforts like psyco may in the future help a bit, but python just isn't a fast language, and it isn't designed to be. Very few languages have the ability to do the dynamic stuff really wel... | 7 | 46 | 0 | This is really two questions, but they are so similar, and to keep it simple, I figured I'd just roll them together:
Firstly: Given an established python project, what are some decent ways to speed it up beyond just plain in-code optimization?
Secondly: When writing a program from scratch in python, what are some goo... | Speeding Up Python | 0.04208 | 0 | 0 | 22,486 |
172,720 | 2008-10-05T21:46:00.000 | 28 | 1 | 1 | 0 | python,optimization,performance | 173,055 | 19 | false | 0 | 0 | Rather than just punting to C, I'd suggest:
Make your code count. Do more with fewer executions of lines:
Change the algorithm to a faster one. It doesn't need to be fancy to be faster in many cases.
Use python primitives that happens to be written in C. Some things will force an interpreter dispatch where some wont. ... | 7 | 46 | 0 | This is really two questions, but they are so similar, and to keep it simple, I figured I'd just roll them together:
Firstly: Given an established python project, what are some decent ways to speed it up beyond just plain in-code optimization?
Secondly: When writing a program from scratch in python, what are some goo... | Speeding Up Python | 1 | 0 | 0 | 22,486 |
172,720 | 2008-10-05T21:46:00.000 | 1 | 1 | 1 | 0 | python,optimization,performance | 175,283 | 19 | false | 0 | 0 | If using psyco, I'd recommend psyco.profile() instead of psyco.full(). For a larger project it will be smarter about the functions that got optimized and use a ton less memory.
I would also recommend looking at iterators and generators. If your application is using large data sets this will save you many copies of cont... | 7 | 46 | 0 | This is really two questions, but they are so similar, and to keep it simple, I figured I'd just roll them together:
Firstly: Given an established python project, what are some decent ways to speed it up beyond just plain in-code optimization?
Secondly: When writing a program from scratch in python, what are some goo... | Speeding Up Python | 0.010526 | 0 | 0 | 22,486 |
172,720 | 2008-10-05T21:46:00.000 | 9 | 1 | 1 | 0 | python,optimization,performance | 172,740 | 19 | false | 0 | 0 | Cython and pyrex can be used to generate c code using a python-like syntax. Psyco is also fantastic for appropriate projects (sometimes you'll not notice much speed boost, sometimes it'll be as much as 50x as fast).
I still reckon the best way is to profile your code (cProfile, etc.) and then just code the bottlenecks ... | 7 | 46 | 0 | This is really two questions, but they are so similar, and to keep it simple, I figured I'd just roll them together:
Firstly: Given an established python project, what are some decent ways to speed it up beyond just plain in-code optimization?
Secondly: When writing a program from scratch in python, what are some goo... | Speeding Up Python | 1 | 0 | 0 | 22,486 |
172,720 | 2008-10-05T21:46:00.000 | 3 | 1 | 1 | 0 | python,optimization,performance | 172,991 | 19 | false | 0 | 0 | This is the procedure that I try to follow:
import psyco; psyco.full()
If it's not fast enough, run the code through a profiler, see where the bottlenecks are. (DISABLE psyco for this step!)
Try to do things such as other people have mentioned to get the code at those bottlenecks as fast as possible.
Stuff like ... | 7 | 46 | 0 | This is really two questions, but they are so similar, and to keep it simple, I figured I'd just roll them together:
Firstly: Given an established python project, what are some decent ways to speed it up beyond just plain in-code optimization?
Secondly: When writing a program from scratch in python, what are some goo... | Speeding Up Python | 0.031568 | 0 | 0 | 22,486 |
173,484 | 2008-10-06T07:37:00.000 | 0 | 0 | 0 | 0 | python,mobile,pys60 | 1,195,831 | 7 | false | 1 | 1 | I have some J2ME experience and now I decided to write a couple of useful apps for my phone so I decided to use PyS60 to study Python by the way:)
Some things I don't like about the platform are:
You can't invoke any graphical functions (module appuifw) from non-main thread.
Python script model is not well-suited for ... | 2 | 10 | 0 | I am in the position of having to make a technology choice early in a project which is targetted at mobile phones. I saw that there is a python derivative for S60 and wondered whether anyone could share experiences, good and bad, and suggest appropriate IDE's and emulators.
Please don't tell me that I should be develo... | Does anyone have experience with PyS60 mobile development | 0 | 0 | 0 | 1,684 |
173,484 | 2008-10-06T07:37:00.000 | 0 | 0 | 0 | 0 | python,mobile,pys60 | 489,368 | 7 | false | 1 | 1 | I've written a calculator, that I'd like to have, and made a simple game.
I wrote it right on the phone. I was writing in text editor then switched to Python and ran a script. It is not very comfortable, but it's ok. Moreover, I was writing all this when I hadn't PC nearby.
It was a great experience! | 2 | 10 | 0 | I am in the position of having to make a technology choice early in a project which is targetted at mobile phones. I saw that there is a python derivative for S60 and wondered whether anyone could share experiences, good and bad, and suggest appropriate IDE's and emulators.
Please don't tell me that I should be develo... | Does anyone have experience with PyS60 mobile development | 0 | 0 | 0 | 1,684 |
174,853 | 2008-10-06T15:47:00.000 | 1 | 0 | 1 | 1 | python,linux | 174,989 | 5 | false | 0 | 0 | The traditional, UNIX-y way to communicate with sub-processes is to open pipes to their standard input/output, and use the select() system call to multiplex the communications in the parent process (available in Python via... the select module).
If you need to kill a slow-running child process, you can just save its pr... | 1 | 10 | 0 | A python script need to spawn multiple sub-processes via fork(). All of those child processes should run simultaneously and the parent process should be waiting for all of them to finish. Having an ability to set some timeout on a "slow" child would be nice.
The parent process goes on processing the rest of the script... | What is the best way to run multiple subprocesses via fork()? | 0.039979 | 0 | 0 | 12,429 |
174,890 | 2008-10-06T15:56:00.000 | 1 | 0 | 0 | 0 | python,xml | 510,324 | 15 | false | 0 | 0 | The DOM has (atleast in level 2) an interface
DATASection, and an operation Document::createCDATASection. They are
extension interfaces, supported only if an implementation supports the
"xml" feature.
from xml.dom import minidom
my_xmldoc=minidom.parse(xmlfile)
my_xmldoc.createCDATASection(data)
now u have cadata node... | 1 | 46 | 0 | I've discovered that cElementTree is about 30 times faster than xml.dom.minidom and I'm rewriting my XML encoding/decoding code. However, I need to output XML that contains CDATA sections and there doesn't seem to be a way to do that with ElementTree.
Can it be done? | How to output CDATA using ElementTree | 0.013333 | 0 | 1 | 52,719 |
175,544 | 2008-10-06T18:21:00.000 | 1 | 0 | 0 | 0 | python,algorithm | 175,612 | 8 | false | 0 | 0 | There are several questions I'd ask before answering this queston:
what happens if there is a conflict, i.e. a worse player books first, then a better player books the same court? Who wins? what happens for the loser?
do you let the best players play as long as the match runs, or do you have fixed time slots?
how ofte... | 3 | 3 | 0 | I'm trying to write a tennis reservation system and I got stucked with this problem.
Let's say you have players with their prefs regarding court number, day and hour.
Also every player is ranked so if there is day/hour slot and there are several players
with preferences for this slot the one with top priority should be... | writing optimization function | 0.024995 | 0 | 0 | 703 |
175,544 | 2008-10-06T18:21:00.000 | -2 | 0 | 0 | 0 | python,algorithm | 175,683 | 8 | false | 0 | 0 | Money. Allocate time slots based on who pays the most. In case of a draw don't let any of them have the slot. | 3 | 3 | 0 | I'm trying to write a tennis reservation system and I got stucked with this problem.
Let's say you have players with their prefs regarding court number, day and hour.
Also every player is ranked so if there is day/hour slot and there are several players
with preferences for this slot the one with top priority should be... | writing optimization function | -0.049958 | 0 | 0 | 703 |
175,544 | 2008-10-06T18:21:00.000 | 0 | 0 | 0 | 0 | python,algorithm | 175,941 | 8 | false | 0 | 0 | Basically, you have the advantage that players have priorities; therefore, you sort the players by descending priority, and then you start allocating slots to them. The first gets their preferred slot, then the next takes his preferred among the free ones and so on. It's a O(N) algorithm. | 3 | 3 | 0 | I'm trying to write a tennis reservation system and I got stucked with this problem.
Let's say you have players with their prefs regarding court number, day and hour.
Also every player is ranked so if there is day/hour slot and there are several players
with preferences for this slot the one with top priority should be... | writing optimization function | 0 | 0 | 0 | 703 |
176,011 | 2008-10-06T20:17:00.000 | 8 | 0 | 1 | 0 | python,arrays,list | 178,511 | 11 | false | 0 | 0 | The standard library arrays are useful for binary I/O, such as translating a list of ints to a string to write to, say, a wave file. That said, as many have already noted, if you're going to do any real work then you should consider using NumPy. | 7 | 425 | 0 | If you are creating a 1d array, you can implement it as a List, or else use the 'array' module in the standard library. I have always used Lists for 1d arrays.
What is the reason or circumstance where I would want to use the array module instead?
Is it for performance and memory optimization, or am I missing something... | Python List vs. Array - when to use? | 1 | 0 | 0 | 353,060 |
176,011 | 2008-10-06T20:17:00.000 | 5 | 0 | 1 | 0 | python,arrays,list | 57,871,856 | 11 | false | 0 | 0 | This answer will sum up almost all the queries about when to use List and Array:
The main difference between these two data types is the operations you can perform on them. For example, you can divide an array by 3 and it will divide each element of array by 3. Same can not be done with the list.
The list is the part ... | 7 | 425 | 0 | If you are creating a 1d array, you can implement it as a List, or else use the 'array' module in the standard library. I have always used Lists for 1d arrays.
What is the reason or circumstance where I would want to use the array module instead?
Is it for performance and memory optimization, or am I missing something... | Python List vs. Array - when to use? | 0.090659 | 0 | 0 | 353,060 |
176,011 | 2008-10-06T20:17:00.000 | 21 | 0 | 1 | 0 | python,arrays,list | 41,944,675 | 11 | false | 0 | 0 | It's a trade off !
pros of each one :
list
flexible
can be heterogeneous
array (ex: numpy array)
array of uniform values
homogeneous
compact (in size)
efficient (functionality and speed)
convenient | 7 | 425 | 0 | If you are creating a 1d array, you can implement it as a List, or else use the 'array' module in the standard library. I have always used Lists for 1d arrays.
What is the reason or circumstance where I would want to use the array module instead?
Is it for performance and memory optimization, or am I missing something... | Python List vs. Array - when to use? | 1 | 0 | 0 | 353,060 |
176,011 | 2008-10-06T20:17:00.000 | 6 | 0 | 1 | 0 | python,arrays,list | 176,073 | 11 | false | 0 | 0 | If you're going to be using arrays, consider the numpy or scipy packages, which give you arrays with a lot more flexibility. | 7 | 425 | 0 | If you are creating a 1d array, you can implement it as a List, or else use the 'array' module in the standard library. I have always used Lists for 1d arrays.
What is the reason or circumstance where I would want to use the array module instead?
Is it for performance and memory optimization, or am I missing something... | Python List vs. Array - when to use? | 1 | 0 | 0 | 353,060 |
176,011 | 2008-10-06T20:17:00.000 | 14 | 0 | 1 | 0 | python,arrays,list | 176,033 | 11 | false | 0 | 0 | My understanding is that arrays are stored more efficiently (i.e. as contiguous blocks of memory vs. pointers to Python objects), but I am not aware of any performance benefit. Additionally, with arrays you must store primitives of the same type, whereas lists can store anything. | 7 | 425 | 0 | If you are creating a 1d array, you can implement it as a List, or else use the 'array' module in the standard library. I have always used Lists for 1d arrays.
What is the reason or circumstance where I would want to use the array module instead?
Is it for performance and memory optimization, or am I missing something... | Python List vs. Array - when to use? | 1 | 0 | 0 | 353,060 |
176,011 | 2008-10-06T20:17:00.000 | 0 | 0 | 1 | 0 | python,arrays,list | 51,371,749 | 11 | false | 0 | 0 | An important difference between numpy array and list is that array slices are views on the original array. This means that the data is not copied, and any modifications to the view will be reflected in the source array. | 7 | 425 | 0 | If you are creating a 1d array, you can implement it as a List, or else use the 'array' module in the standard library. I have always used Lists for 1d arrays.
What is the reason or circumstance where I would want to use the array module instead?
Is it for performance and memory optimization, or am I missing something... | Python List vs. Array - when to use? | 0 | 0 | 0 | 353,060 |
176,011 | 2008-10-06T20:17:00.000 | 5 | 0 | 1 | 0 | python,arrays,list | 176,047 | 11 | false | 0 | 0 | Array can only be used for specific types, whereas lists can be used for any object.
Arrays can also only data of one type, whereas a list can have entries of various object types.
Arrays are also more efficient for some numerical computation. | 7 | 425 | 0 | If you are creating a 1d array, you can implement it as a List, or else use the 'array' module in the standard library. I have always used Lists for 1d arrays.
What is the reason or circumstance where I would want to use the array module instead?
Is it for performance and memory optimization, or am I missing something... | Python List vs. Array - when to use? | 0.090659 | 0 | 0 | 353,060 |
176,179 | 2008-10-06T21:03:00.000 | 1 | 0 | 0 | 0 | python,sockets,networking,ip,multicast | 176,501 | 3 | false | 0 | 0 | The approach you take is going to depend very much on the nature of the data that you're sending, the scale of your network and the quantity of data you're sending. In particular it is going to depend on the number of targets each of your nodes is connected to.
If you're expecting this to scale to a large number of tar... | 2 | 5 | 0 | I have to write a reliable, totally-ordered multicast system from scratch in Python. I can't use any external libraries. I'm allowed to use a central sequencer.
There seems to be two immediate approaches:
write an efficient system, attaching a unique id to each multicasted message,
having the sequencer multicast sequ... | Writing a reliable, totally-ordered multicast system in Python | 0.066568 | 0 | 0 | 3,074 |
176,179 | 2008-10-06T21:03:00.000 | 4 | 0 | 0 | 0 | python,sockets,networking,ip,multicast | 176,287 | 3 | true | 0 | 0 | The flooding approach can cause a bad situation to get worse. If messages are dropped due to high network load, having every node resend every message will only make the situation worse.
The best approach to take depends on the nature of the data you are sending. For example:
Multimedia data: no retries, a dropped pac... | 2 | 5 | 0 | I have to write a reliable, totally-ordered multicast system from scratch in Python. I can't use any external libraries. I'm allowed to use a central sequencer.
There seems to be two immediate approaches:
write an efficient system, attaching a unique id to each multicasted message,
having the sequencer multicast sequ... | Writing a reliable, totally-ordered multicast system in Python | 1.2 | 0 | 0 | 3,074 |
177,284 | 2008-10-07T05:06:00.000 | 0 | 0 | 0 | 0 | python,mysql,sql,oracle,postgresql | 177,302 | 5 | false | 0 | 0 | Can you use the built-in database aggregate functions like MAX(column)? | 1 | 1 | 0 | I have a table that looks something like this:
word big expensive smart fast
dog 9 -10 -20 4
professor 2 4 40 -7
ferrari 7 50 0 48
alaska 10 0 1 0
gnat -3 0 0 0
The + and - values are as... | SQL Absolute value across columns | 0 | 1 | 0 | 4,588 |
177,287 | 2008-10-07T05:08:00.000 | -4 | 0 | 0 | 0 | python,alerts | 177,316 | 6 | false | 0 | 0 | Start an app as a background process that either has a TCP port bound to localhost, or communicates through a file -- your daemon has the file open, and then you echo "foo" > c:\your\file. After, say, 1 second of no activity, you display the message and truncate the file. | 1 | 39 | 0 | Is it possible to produce an alert similar to JavaScript's alert("message") in python, with an application running as a daemon.
This will be run in Windows, Most likely XP but 2000 and Vista are also very real possibilities.
Update:
This is intended to run in the background and alert the user when certain conditions ar... | Alert boxes in Python? | -1 | 0 | 0 | 108,137 |
177,492 | 2008-10-07T07:33:00.000 | 0 | 0 | 0 | 0 | python,django,django-admin | 2,967,841 | 7 | false | 1 | 0 | Another way to do this is to embed the filter in the queryset.
You can dynamically create a proxy model with a manager that filters the way you want, then call admin.site.register() to create a new model admin. All the links would then be relative to this view. | 2 | 6 | 0 | What I would like to achive is:
I go to admin site, apply some filters to the list of objects
I click and object edit, edit, edit, hit 'Save'
Site takes me to the list of objects... unfiltered. I'd like to have the filter from step 1 remembered and applied.
Is there an easy way to do it? | Keeping filters in Django Admin | 0 | 0 | 0 | 3,989 |
177,492 | 2008-10-07T07:33:00.000 | 2 | 0 | 0 | 0 | python,django,django-admin | 177,563 | 7 | false | 1 | 0 | Click 2 times "Back"? | 2 | 6 | 0 | What I would like to achive is:
I go to admin site, apply some filters to the list of objects
I click and object edit, edit, edit, hit 'Save'
Site takes me to the list of objects... unfiltered. I'd like to have the filter from step 1 remembered and applied.
Is there an easy way to do it? | Keeping filters in Django Admin | 0.057081 | 0 | 0 | 3,989 |
179,716 | 2008-10-07T18:18:00.000 | 2 | 0 | 1 | 0 | python,algorithm,datetime | 179,760 | 5 | false | 0 | 0 | Since you seem to be throwing out the 20 minute delta between times 1 and 3 in your example, I'd say you should just sort the list of datetimes, add up the deltas between adjacent times, then divide by n-1.
Do you have any code you can share with us, so we can help you debug it? | 2 | 4 | 0 | I have a series of datetime objects and would like to calculate the average delta between them.
For example, if the input was (2008-10-01 12:15:00, 2008-10-01 12:25:00, 2008-10-01 12:35:00), then the average delta would be exactly 00:10:00, or 10 minutes.
Any suggestions on how to calculate this using Python? | Average difference between dates in Python | 0.07983 | 0 | 0 | 6,291 |
179,716 | 2008-10-07T18:18:00.000 | 0 | 0 | 1 | 0 | python,algorithm,datetime | 179,761 | 5 | true | 0 | 0 | You can subtract each successive date from the one prior (resulting in a timedelta object which represents the difference in days, seconds). You can then average the timedelta objects to find your answer. | 2 | 4 | 0 | I have a series of datetime objects and would like to calculate the average delta between them.
For example, if the input was (2008-10-01 12:15:00, 2008-10-01 12:25:00, 2008-10-01 12:35:00), then the average delta would be exactly 00:10:00, or 10 minutes.
Any suggestions on how to calculate this using Python? | Average difference between dates in Python | 1.2 | 0 | 0 | 6,291 |
179,904 | 2008-10-07T19:11:00.000 | 5 | 0 | 1 | 0 | python,matlab | 181,127 | 21 | false | 0 | 0 | Seems to be pure inertia. Where it is in use, everyone is too busy to learn IDL or numpy in sufficient detail to switch, and don't want to rewrite good working programs. Luckily that's not strictly true, but true enough in enough places that Matlab will be around a long time. Like Fortran (in active use where i wor... | 13 | 53 | 1 | I've been recently asked to learn some MATLAB basics for a class.
What does make it so cool for researchers and people that works in university?
I saw it's cool to work with matrices and plotting things... (things that can be done easily in Python using some libraries).
Writing a function or parsing a file is just pain... | What is MATLAB good for? Why is it so used by universities? When is it better than Python? | 0.047583 | 0 | 0 | 200,558 |
179,904 | 2008-10-07T19:11:00.000 | 2 | 0 | 1 | 0 | python,matlab | 1,890,839 | 21 | false | 0 | 0 | Matlab is good at doing number crunching. Also Matrix and matrix manipulation. It has many helpful built in libraries(depends on the what version) I think it is easier to use than python if you are going to be calculating equations. | 13 | 53 | 1 | I've been recently asked to learn some MATLAB basics for a class.
What does make it so cool for researchers and people that works in university?
I saw it's cool to work with matrices and plotting things... (things that can be done easily in Python using some libraries).
Writing a function or parsing a file is just pain... | What is MATLAB good for? Why is it so used by universities? When is it better than Python? | 0.019045 | 0 | 0 | 200,558 |
179,904 | 2008-10-07T19:11:00.000 | 13 | 0 | 1 | 0 | python,matlab | 179,910 | 21 | false | 0 | 0 | MATLAB is great for doing array manipulation, doing specialized math functions, and for creating nice plots quick.
I'd probably only use it for large programs if I could use a lot of array/matrix manipulation.
You don't have to worry about the IDE as much as in more formal packages, so it's easier for students without ... | 13 | 53 | 1 | I've been recently asked to learn some MATLAB basics for a class.
What does make it so cool for researchers and people that works in university?
I saw it's cool to work with matrices and plotting things... (things that can be done easily in Python using some libraries).
Writing a function or parsing a file is just pain... | What is MATLAB good for? Why is it so used by universities? When is it better than Python? | 1 | 0 | 0 | 200,558 |
179,904 | 2008-10-07T19:11:00.000 | 4 | 0 | 1 | 0 | python,matlab | 179,932 | 21 | false | 0 | 0 | The main reason it is useful in industry is the plug-ins built on top of the core functionality. Almost all active Matlab development for the last few years has focused on these.
Unfortunately, you won't have much opportunity to use these in an academic environment. | 13 | 53 | 1 | I've been recently asked to learn some MATLAB basics for a class.
What does make it so cool for researchers and people that works in university?
I saw it's cool to work with matrices and plotting things... (things that can be done easily in Python using some libraries).
Writing a function or parsing a file is just pain... | What is MATLAB good for? Why is it so used by universities? When is it better than Python? | 0.038077 | 0 | 0 | 200,558 |
179,904 | 2008-10-07T19:11:00.000 | 4 | 0 | 1 | 0 | python,matlab | 180,012 | 21 | false | 0 | 0 | One reason MATLAB is popular with universities is the same reason a lot of things are popular with universities: there's a lot of professors familiar with it, and it's fairly robust.
I've spoken to a lot of folks who are especially interested in MATLAB's nascent ability to tap into the GPU instead of working serially. ... | 13 | 53 | 1 | I've been recently asked to learn some MATLAB basics for a class.
What does make it so cool for researchers and people that works in university?
I saw it's cool to work with matrices and plotting things... (things that can be done easily in Python using some libraries).
Writing a function or parsing a file is just pain... | What is MATLAB good for? Why is it so used by universities? When is it better than Python? | 0.038077 | 0 | 0 | 200,558 |
179,904 | 2008-10-07T19:11:00.000 | 3 | 0 | 1 | 0 | python,matlab | 181,295 | 21 | false | 0 | 0 | I think you answered your own question when you noted that Matlab is "cool to work with matrixes and plotting things". Any application that requires a lot of matrix maths and visualisation will probably be easiest to do in Matlab.
That said, Matlab's syntax feels awkward and shows the language's age. In contrast, Pytho... | 13 | 53 | 1 | I've been recently asked to learn some MATLAB basics for a class.
What does make it so cool for researchers and people that works in university?
I saw it's cool to work with matrices and plotting things... (things that can be done easily in Python using some libraries).
Writing a function or parsing a file is just pain... | What is MATLAB good for? Why is it so used by universities? When is it better than Python? | 0.028564 | 0 | 0 | 200,558 |
179,904 | 2008-10-07T19:11:00.000 | 15 | 0 | 1 | 0 | python,matlab | 181,492 | 21 | false | 0 | 0 | Hold everything. When's the last time you programed your calculator to play tetris? Did you actually think you could write anything you want in those 128k of RAM? Likely not. MATLAB is not for programming unless you're dealing with huge matrices. It's the graphing calculator you whip out when you've got Megabytes to Gi... | 13 | 53 | 1 | I've been recently asked to learn some MATLAB basics for a class.
What does make it so cool for researchers and people that works in university?
I saw it's cool to work with matrices and plotting things... (things that can be done easily in Python using some libraries).
Writing a function or parsing a file is just pain... | What is MATLAB good for? Why is it so used by universities? When is it better than Python? | 1 | 0 | 0 | 200,558 |
179,904 | 2008-10-07T19:11:00.000 | 34 | 0 | 1 | 0 | python,matlab | 193,386 | 21 | false | 0 | 0 | I've been using matlab for many years in my research. It's great for linear algebra and has a large set of well-written toolboxes. The most recent versions are starting to push it into being closer to a general-purpose language (better optimizers, a much better object model, richer scoping rules, etc.).
This past s... | 13 | 53 | 1 | I've been recently asked to learn some MATLAB basics for a class.
What does make it so cool for researchers and people that works in university?
I saw it's cool to work with matrices and plotting things... (things that can be done easily in Python using some libraries).
Writing a function or parsing a file is just pain... | What is MATLAB good for? Why is it so used by universities? When is it better than Python? | 1 | 0 | 0 | 200,558 |
179,904 | 2008-10-07T19:11:00.000 | 3 | 0 | 1 | 0 | python,matlab | 180,736 | 21 | false | 0 | 0 | It's been some time since I've used Matlab, but from memory it does provide (albeit with extra plugins) the ability to generate source to allow you to realise your algorithm on a DSP.
Since python is a general purpose programming language there is no reason why you couldn't do everything in python that you can do in ma... | 13 | 53 | 1 | I've been recently asked to learn some MATLAB basics for a class.
What does make it so cool for researchers and people that works in university?
I saw it's cool to work with matrices and plotting things... (things that can be done easily in Python using some libraries).
Writing a function or parsing a file is just pain... | What is MATLAB good for? Why is it so used by universities? When is it better than Python? | 0.028564 | 0 | 0 | 200,558 |
179,904 | 2008-10-07T19:11:00.000 | 7 | 0 | 1 | 0 | python,matlab | 181,274 | 21 | false | 0 | 0 | Personally, I tend to think of Matlab as an interactive matrix calculator and plotting tool with a few scripting capabilities, rather than as a full-fledged programming language like Python or C. The reason for its success is that matrix stuff and plotting work out of the box, and you can do a few very specific things... | 13 | 53 | 1 | I've been recently asked to learn some MATLAB basics for a class.
What does make it so cool for researchers and people that works in university?
I saw it's cool to work with matrices and plotting things... (things that can be done easily in Python using some libraries).
Writing a function or parsing a file is just pain... | What is MATLAB good for? Why is it so used by universities? When is it better than Python? | 1 | 0 | 0 | 200,558 |
179,904 | 2008-10-07T19:11:00.000 | 6 | 0 | 1 | 0 | python,matlab | 180,017 | 21 | false | 0 | 0 | I believe you have a very good point and it's one that has been raised in the company where I work. The company is limited in it's ability to apply matlab because of the licensing costs involved. One developer proved that Python was a very suitable replacement but it fell on ignorant ears because to the owners of those... | 13 | 53 | 1 | I've been recently asked to learn some MATLAB basics for a class.
What does make it so cool for researchers and people that works in university?
I saw it's cool to work with matrices and plotting things... (things that can be done easily in Python using some libraries).
Writing a function or parsing a file is just pain... | What is MATLAB good for? Why is it so used by universities? When is it better than Python? | 1 | 0 | 0 | 200,558 |
179,904 | 2008-10-07T19:11:00.000 | 6 | 0 | 1 | 0 | python,matlab | 179,912 | 21 | false | 0 | 0 | The most likely reason that it's used so much in universities is that the mathematics faculty are used to it, understand it, and know how to incorporate it into their curriculum. | 13 | 53 | 1 | I've been recently asked to learn some MATLAB basics for a class.
What does make it so cool for researchers and people that works in university?
I saw it's cool to work with matrices and plotting things... (things that can be done easily in Python using some libraries).
Writing a function or parsing a file is just pain... | What is MATLAB good for? Why is it so used by universities? When is it better than Python? | 1 | 0 | 0 | 200,558 |
179,904 | 2008-10-07T19:11:00.000 | 4 | 0 | 1 | 0 | python,matlab | 1,113,065 | 21 | false | 0 | 0 | I know this question is old, and therefore may no longer be
watched, but I felt it was necessary to comment. As an
aerospace engineer at Georgia Tech, I can say, with no
qualms, that MATLAB is awesome. You can have it quickly
interface with your Excel spreadsheets to pull in data about
how high and fast rockets are fly... | 13 | 53 | 1 | I've been recently asked to learn some MATLAB basics for a class.
What does make it so cool for researchers and people that works in university?
I saw it's cool to work with matrices and plotting things... (things that can be done easily in Python using some libraries).
Writing a function or parsing a file is just pain... | What is MATLAB good for? Why is it so used by universities? When is it better than Python? | 0.038077 | 0 | 0 | 200,558 |
180,606 | 2008-10-07T21:51:00.000 | 7 | 0 | 1 | 0 | python,string,ascii | 55,509,509 | 9 | false | 0 | 0 | You can use bytes(list).decode() to do this - and list(string.encode()) to get the values back. | 1 | 86 | 0 | I've got a list in a Python program that contains a series of numbers, which are themselves ASCII values. How do I convert this into a "regular" string that I can echo to the screen? | How do I convert a list of ascii values to a string in python? | 1 | 0 | 0 | 195,998 |
181,543 | 2008-10-08T06:27:00.000 | 37 | 0 | 1 | 0 | python,python-3.x | 181,646 | 5 | false | 0 | 0 | reduce() is not being removed -- it's simply being moved into the functools module. Guido's reasoning is that except for trivial cases like summation, code written using reduce() is usually clearer when written as an accumulation loop. | 3 | 78 | 0 | There seems to be a lot of heated discussion on the net about the changes to the reduce() function in python 3.0 and how it should be removed. I am having a little difficulty understanding why this is the case; I find it quite reasonable to use it in a variety of cases. If the contempt was simply subjective, I cannot i... | What is the problem with reduce()? | 1 | 0 | 0 | 22,140 |
181,543 | 2008-10-08T06:27:00.000 | 4 | 0 | 1 | 0 | python,python-3.x | 43,993,022 | 5 | false | 0 | 0 | The primary reason of reduce's existence is to avoid writing explicit for loops with accumulators. Even though python has some facilities to support the functional style, it is not encouraged. If you like the 'real' and not 'pythonic' functional style - use a modern Lisp (Clojure?) or Haskell instead. | 3 | 78 | 0 | There seems to be a lot of heated discussion on the net about the changes to the reduce() function in python 3.0 and how it should be removed. I am having a little difficulty understanding why this is the case; I find it quite reasonable to use it in a variety of cases. If the contempt was simply subjective, I cannot i... | What is the problem with reduce()? | 0.158649 | 0 | 0 | 22,140 |
181,543 | 2008-10-08T06:27:00.000 | 9 | 0 | 1 | 0 | python,python-3.x | 181,593 | 5 | false | 0 | 0 | People worry it encourages an obfuscated style of programming, doing something that can be achieved with clearer methods.
I'm not against reduce myself, I also find it a useful tool sometimes. | 3 | 78 | 0 | There seems to be a lot of heated discussion on the net about the changes to the reduce() function in python 3.0 and how it should be removed. I am having a little difficulty understanding why this is the case; I find it quite reasonable to use it in a variety of cases. If the contempt was simply subjective, I cannot i... | What is the problem with reduce()? | 1 | 0 | 0 | 22,140 |
181,724 | 2008-10-08T07:49:00.000 | 2 | 0 | 1 | 0 | python,debugging | 181,761 | 6 | false | 0 | 0 | Any time you want to inspect the contents of variables that may have caused the error. The only way you can do that is to stop execution and take a look at the stack.
pydev in Eclipse is a pretty good IDE if you are looking for one. | 4 | 6 | 0 | Since Python is a dynamic, interpreted language you don't have to compile your code before running it. Hence, it's very easy to simply write your code, run it, see what problems occur, and fix them. Using hotkeys or macros can make this incredibly quick.
So, because it's so easy to immediately see the output of your pr... | When to use the Python debugger | 0.066568 | 0 | 0 | 1,057 |
181,724 | 2008-10-08T07:49:00.000 | 1 | 0 | 1 | 0 | python,debugging | 183,563 | 6 | false | 0 | 0 | I find it very useful to drop into a debugger in a failing test case.
I add import pdb; pdb.set_trace() just before the failure point of the test. The test runs, building up a potentially quite large context (e.g. importing a database fixture or constructing an HTTP request). When the test reaches the pdb.set_trace() l... | 4 | 6 | 0 | Since Python is a dynamic, interpreted language you don't have to compile your code before running it. Hence, it's very easy to simply write your code, run it, see what problems occur, and fix them. Using hotkeys or macros can make this incredibly quick.
So, because it's so easy to immediately see the output of your pr... | When to use the Python debugger | 0.033321 | 0 | 0 | 1,057 |
181,724 | 2008-10-08T07:49:00.000 | 8 | 0 | 1 | 0 | python,debugging | 182,010 | 6 | false | 0 | 0 | In 30 years of programming I've used a debugger exactly 4 times. All four times were to read the core file produced from a C program crashing to locate the traceback information that's buried in there.
I don't think debuggers help much, even in compiled languages. Many people like debuggers, there are some reasons fo... | 4 | 6 | 0 | Since Python is a dynamic, interpreted language you don't have to compile your code before running it. Hence, it's very easy to simply write your code, run it, see what problems occur, and fix them. Using hotkeys or macros can make this incredibly quick.
So, because it's so easy to immediately see the output of your pr... | When to use the Python debugger | 1 | 0 | 0 | 1,057 |
181,724 | 2008-10-08T07:49:00.000 | 7 | 0 | 1 | 0 | python,debugging | 181,767 | 6 | true | 0 | 0 | I use pdb for basic python debugging. Some of the situations I use it are:
When you have a loop iterating over 100,000 entries and want to break at a specific point, it becomes really helpful.(conditional breaks)
Trace the control flow of someone else's code.
Its always better to use a debugger than litter the code wi... | 4 | 6 | 0 | Since Python is a dynamic, interpreted language you don't have to compile your code before running it. Hence, it's very easy to simply write your code, run it, see what problems occur, and fix them. Using hotkeys or macros can make this incredibly quick.
So, because it's so easy to immediately see the output of your pr... | When to use the Python debugger | 1.2 | 0 | 0 | 1,057 |
182,197 | 2008-10-08T11:12:00.000 | -4 | 0 | 0 | 1 | python,windows,file,pywin32,watch | 182,234 | 28 | false | 0 | 0 | I don't know any Windows specific function. You could try getting the MD5 hash of the file every second/minute/hour (depends on how fast you need it) and compare it to the last hash. When it differs you know the file has been changed and you read out the newest lines. | 1 | 383 | 0 | I have a log file being written by another process which I want to watch for changes. Each time a change occurs I'd like to read the new data in to do some processing on it.
What's the best way to do this? I was hoping there'd be some sort of hook from the PyWin32 library. I've found the win32file.FindNextChangeNotific... | How do I watch a file for changes? | -1 | 0 | 0 | 376,572 |
182,229 | 2008-10-08T11:23:00.000 | 1 | 0 | 0 | 0 | python,django | 7,870,288 | 5 | false | 1 | 0 | The cleanest solution is to add django extensions.
(virt1)tsmets@calvin:~/Documents/prive/rugby-club/proposal/kitu$ yolk -l
Django - 1.3.1 - active
Pygments - 1.4 - active
Python - 2.6.5 - active development (/usr/lib/python2.6/lib-dynload)
django-extensions - 0.7.1 ... | 2 | 9 | 0 | I'd like to run a script to populate my database. I'd like to access it through the Django database API.
The only problem is that I don't know what I would need to import to gain access to this.
How can this be achieved? | What do I need to import to gain access to my models? | 0.039979 | 0 | 0 | 1,329 |
182,229 | 2008-10-08T11:23:00.000 | 0 | 0 | 0 | 0 | python,django | 182,275 | 5 | false | 1 | 0 | In addition to your own models files, you need to import your settings module as well. | 2 | 9 | 0 | I'd like to run a script to populate my database. I'd like to access it through the Django database API.
The only problem is that I don't know what I would need to import to gain access to this.
How can this be achieved? | What do I need to import to gain access to my models? | 0 | 0 | 0 | 1,329 |
184,049 | 2008-10-08T18:07:00.000 | 7 | 1 | 0 | 1 | python,ruby-on-rails,django,merb | 188,971 | 13 | false | 1 | 0 | All of them will get the job done.
Use the one that you and your team are most familiar with
This will have a far greater impact on the delivery times and stability of your app than any of the other variables. | 9 | 2 | 0 | I know I'll get a thousand "Depends on what you're trying to do" answers, but seriously, there really is no solid information about this online yet. Here are my assumptions - I think they're similar for alot of people right now:
It is now October 2008. I want to start writing an application for January 2009. I am w... | Framework/Language for new web 2.0 sites (2008 and 2009) | 1 | 0 | 0 | 959 |
184,049 | 2008-10-08T18:07:00.000 | 9 | 1 | 0 | 1 | python,ruby-on-rails,django,merb | 184,278 | 13 | false | 1 | 0 | Sorry, but your question is wrong. People are probably going to vote me down for this one but I want to say it anyway:
I wouldn't expect to get an objective answer! Why? That's simple:
All Ruby advocates will tell to use Ruby.
All Python advocates will tell to use Python.
All PHP advocates will tell to use PHP.
Insert... | 9 | 2 | 0 | I know I'll get a thousand "Depends on what you're trying to do" answers, but seriously, there really is no solid information about this online yet. Here are my assumptions - I think they're similar for alot of people right now:
It is now October 2008. I want to start writing an application for January 2009. I am w... | Framework/Language for new web 2.0 sites (2008 and 2009) | 1 | 0 | 0 | 959 |
184,049 | 2008-10-08T18:07:00.000 | 1 | 1 | 0 | 1 | python,ruby-on-rails,django,merb | 189,236 | 13 | false | 1 | 0 | Don't get stuck in the mindset of server-side page layout. Consider technologies like SproutCore, GWT or ExtJS which put the layouting code fully on the client, making the server responsible only for data marshalling and processing (and easily replaced).
And you really, really need to know which server platform you wan... | 9 | 2 | 0 | I know I'll get a thousand "Depends on what you're trying to do" answers, but seriously, there really is no solid information about this online yet. Here are my assumptions - I think they're similar for alot of people right now:
It is now October 2008. I want to start writing an application for January 2009. I am w... | Framework/Language for new web 2.0 sites (2008 and 2009) | 0.015383 | 0 | 0 | 959 |
184,049 | 2008-10-08T18:07:00.000 | 5 | 1 | 0 | 1 | python,ruby-on-rails,django,merb | 184,376 | 13 | true | 1 | 0 | it depends.
php - symfony is a great framework. downsides: php, wordy and directory heavy. propel gets annoying to use. upsides: php is everywhere and labor is cheap. well done framework, and good support. lots of plugins to make your life easier
python - django is also a great framework. downsides: python progra... | 9 | 2 | 0 | I know I'll get a thousand "Depends on what you're trying to do" answers, but seriously, there really is no solid information about this online yet. Here are my assumptions - I think they're similar for alot of people right now:
It is now October 2008. I want to start writing an application for January 2009. I am w... | Framework/Language for new web 2.0 sites (2008 and 2009) | 1.2 | 0 | 0 | 959 |
184,049 | 2008-10-08T18:07:00.000 | 0 | 1 | 0 | 1 | python,ruby-on-rails,django,merb | 186,765 | 13 | false | 1 | 0 | My experience with various new technologies over the last ten years leads me to recommend that you make stability of the platform a serious criterion. It's all well and good developing with the latest and greatest framework, but when you find it's moved forward a point version and suddenly the way you have done everyth... | 9 | 2 | 0 | I know I'll get a thousand "Depends on what you're trying to do" answers, but seriously, there really is no solid information about this online yet. Here are my assumptions - I think they're similar for alot of people right now:
It is now October 2008. I want to start writing an application for January 2009. I am w... | Framework/Language for new web 2.0 sites (2008 and 2009) | 0 | 0 | 0 | 959 |
184,049 | 2008-10-08T18:07:00.000 | 1 | 1 | 0 | 1 | python,ruby-on-rails,django,merb | 189,012 | 13 | false | 1 | 0 | I have to preface this with my agreeing with Orion Edwards, choose the one your team is most familiar with.
However, I also have to note the curious lack of ASP.NET languages in your list. Not to provoke the great zealot army, but where's the beef? .NET is a stable, rapid development platform and the labor pool is grow... | 9 | 2 | 0 | I know I'll get a thousand "Depends on what you're trying to do" answers, but seriously, there really is no solid information about this online yet. Here are my assumptions - I think they're similar for alot of people right now:
It is now October 2008. I want to start writing an application for January 2009. I am w... | Framework/Language for new web 2.0 sites (2008 and 2009) | 0.015383 | 0 | 0 | 959 |
184,049 | 2008-10-08T18:07:00.000 | 1 | 1 | 0 | 1 | python,ruby-on-rails,django,merb | 208,938 | 13 | false | 1 | 0 | Having built apps in Django, I can attest to its utility. If only all frameworks were as elegant (yes Spring, I'm looking at you).
However in terms of betting the farm on Django, one thing you need to factor in is that Python 3 will be released shortly. Python 3 is not backwards compatible and there's a risk that it wi... | 9 | 2 | 0 | I know I'll get a thousand "Depends on what you're trying to do" answers, but seriously, there really is no solid information about this online yet. Here are my assumptions - I think they're similar for alot of people right now:
It is now October 2008. I want to start writing an application for January 2009. I am w... | Framework/Language for new web 2.0 sites (2008 and 2009) | 0.015383 | 0 | 0 | 959 |
184,049 | 2008-10-08T18:07:00.000 | 4 | 1 | 0 | 1 | python,ruby-on-rails,django,merb | 184,107 | 13 | false | 1 | 0 | I would go with Django, if you are comfortable with a Python solution. It's at version 1.0 now, and is maturing nicely, with a large user base and many contributors. Integrating jQuery is no problem, and I've done it without any issues.
The only thing is, as far as I can tell, Ruby is much more popular for web developm... | 9 | 2 | 0 | I know I'll get a thousand "Depends on what you're trying to do" answers, but seriously, there really is no solid information about this online yet. Here are my assumptions - I think they're similar for alot of people right now:
It is now October 2008. I want to start writing an application for January 2009. I am w... | Framework/Language for new web 2.0 sites (2008 and 2009) | 0.061461 | 0 | 0 | 959 |
184,049 | 2008-10-08T18:07:00.000 | 2 | 1 | 0 | 1 | python,ruby-on-rails,django,merb | 184,157 | 13 | false | 1 | 0 | Based in your reasons, I would go with Ruby. I see that you want some administration tools (scp, ftp client) and Ruby has it (net/sftp and net/ftp libraries).
Also, there are great gems like God for monitoring your system, Vlad the Deployer for deploying, etc. And a lot of alternatives in Merb's field, just use whateve... | 9 | 2 | 0 | I know I'll get a thousand "Depends on what you're trying to do" answers, but seriously, there really is no solid information about this online yet. Here are my assumptions - I think they're similar for alot of people right now:
It is now October 2008. I want to start writing an application for January 2009. I am w... | Framework/Language for new web 2.0 sites (2008 and 2009) | 0.03076 | 0 | 0 | 959 |
184,187 | 2008-10-08T18:33:00.000 | 2 | 1 | 0 | 0 | python,scripting,perforce | 184,238 | 6 | false | 0 | 0 | You may want to check out the P4Python module. It's available on the perforce site and it makes things very simple. | 2 | 15 | 0 | I would like to write some scripts in python that do some automated changes to source code. If the script determines it needs to change the file I would like to first check it out of perforce. I don't care about checking in because I will always want to build and test first. | How do I check out a file from perforce in python? | 0.066568 | 0 | 0 | 19,107 |
184,187 | 2008-10-08T18:33:00.000 | 3 | 1 | 0 | 0 | python,scripting,perforce | 307,908 | 6 | false | 0 | 0 | Building from p4python source requires downloading and extracting the p4 api recommended for that version. For example, if building the Windows XP x86 version of P4Python 2008.2 for activepython 2.5:
download and extract both the p4python and p4api
fixup the setup.cfg for p4python to
point to the p4api directory.
To ... | 2 | 15 | 0 | I would like to write some scripts in python that do some automated changes to source code. If the script determines it needs to change the file I would like to first check it out of perforce. I don't care about checking in because I will always want to build and test first. | How do I check out a file from perforce in python? | 0.099668 | 0 | 0 | 19,107 |
185,389 | 2008-10-08T23:46:00.000 | 7 | 0 | 0 | 0 | python,model-view-controller,model,structure | 185,692 | 3 | true | 1 | 0 | There is an inconsistency in your specification. You say Database.py needs to import all Model classes to do ORM but then you say the User class need access to the Database to do queries.
Think of these as layers of an API. The Database class provides an API (maybe object-oriented) to some physical persistence layer (s... | 3 | 3 | 0 | I'm having problems structuring classes in the Model part of an MVC pattern in my Python app. No matter how I turn things, I keep running into circular imports. Here's what I have:
Model/__init__p.y
should hold all Model class names so
I can do a "from Model import User"
e.g. from a Controller or a unit
test case
Mod... | MVC model structure in Python | 1.2 | 0 | 0 | 3,599 |
185,389 | 2008-10-08T23:46:00.000 | 3 | 0 | 0 | 0 | python,model-view-controller,model,structure | 185,411 | 3 | false | 1 | 0 | Generally, we put it all in one file. This isn't Java or C++.
Start with a single file until you get some more experience with Python. Unless your files are gargantuan, it will work fine.
For example, Django encourages this style, so copy their formula for success. One module for the model. A module for each appli... | 3 | 3 | 0 | I'm having problems structuring classes in the Model part of an MVC pattern in my Python app. No matter how I turn things, I keep running into circular imports. Here's what I have:
Model/__init__p.y
should hold all Model class names so
I can do a "from Model import User"
e.g. from a Controller or a unit
test case
Mod... | MVC model structure in Python | 0.197375 | 0 | 0 | 3,599 |
185,389 | 2008-10-08T23:46:00.000 | 1 | 0 | 0 | 0 | python,model-view-controller,model,structure | 185,480 | 3 | false | 1 | 0 | I think you have one issue that should be straightened. Circular references often result from a failure to achieve separation of concerns. In my opinion, the database and model modules shouldn't know much about each other, working against an API instead. In this case the database shouldn't directly reference any spe... | 3 | 3 | 0 | I'm having problems structuring classes in the Model part of an MVC pattern in my Python app. No matter how I turn things, I keep running into circular imports. Here's what I have:
Model/__init__p.y
should hold all Model class names so
I can do a "from Model import User"
e.g. from a Controller or a unit
test case
Mod... | MVC model structure in Python | 0.066568 | 0 | 0 | 3,599 |
186,916 | 2008-10-09T11:55:00.000 | 4 | 0 | 1 | 0 | python,configuration,serialization | 187,011 | 6 | false | 0 | 0 | If you are the only one that has access to the configuration file, you can use a simple, low-level solution. Keep the "dictionary" in a text file as a list of tuples (regexp, message) exactly as if it was a python expression:
[
("file .* does not exist", "file not found"),
("user .* not authorized", "authorization erro... | 1 | 25 | 0 | I have a python script that analyzes a set of error messages and checks for each message if it matches a certain pattern (regular expression) in order to group these messages. For example "file x does not exist" and "file y does not exist" would match "file .* does not exist" and be accounted as two occurrences of "fil... | Configuration file with list of key-value pairs in python | 0.132549 | 0 | 0 | 38,147 |
187,195 | 2008-10-09T13:15:00.000 | 5 | 1 | 0 | 0 | mod-python,apache | 187,202 | 1 | true | 0 | 0 | No, all the files are parsed at run time, you can include as many as you want. They've just opted to seperate out the configuration for easier management. | 1 | 2 | 0 | I am working with a hosting provider who has installed mod_python for me. I followed the install instructions locally and included it in httpd.conf but they have opted to put it in conf.d/python.conf.
Is there any difference/benefit to doing it either way? | Is there a difference between installing mod_python via httpd.conf and conf.d in apache? | 1.2 | 0 | 0 | 295 |
187,455 | 2008-10-09T14:12:00.000 | 28 | 0 | 1 | 0 | python,arrays | 188,867 | 5 | false | 0 | 0 | len is a built-in function that calls the given container object's __len__ member function to get the number of elements in the object.
Functions encased with double underscores are usually "special methods" implementing one of the standard interfaces in Python (container, number, etc). Special methods are used via ... | 1 | 191 | 0 | How can I count the number of elements in an array, because contrary to logic array.count(string) does not count all the elements in the array, it just searches for the number of occurrences of string. | Counting array elements in Python | 1 | 0 | 0 | 667,065 |
189,943 | 2008-10-10T02:39:00.000 | 5 | 0 | 1 | 0 | python,image-processing,background-subtraction,image-comparison,timelapse | 190,078 | 24 | false | 0 | 0 | Most of the answers given won't deal with lighting levels.
I would first normalize the image to a standard light level before doing the comparison. | 6 | 212 | 0 | Here's what I would like to do:
I'm taking pictures with a webcam at regular intervals. Sort of like a time lapse thing. However, if nothing has really changed, that is, the picture pretty much looks the same, I don't want to store the latest snapshot.
I imagine there's some way of quantifying the difference, and I w... | How can I quantify difference between two images? | 0.041643 | 0 | 0 | 231,920 |
189,943 | 2008-10-10T02:39:00.000 | 1 | 0 | 1 | 0 | python,image-processing,background-subtraction,image-comparison,timelapse | 5,053,648 | 24 | false | 0 | 0 | I have been having a lot of luck with jpg images taken with the same camera on a tripod by
(1) simplifying greatly (like going from 3000 pixels wide to 100 pixels wide or even fewer)
(2) flattening each jpg array into a single vector
(3) pairwise correlating sequential images with a simple correlate algorithm to get co... | 6 | 212 | 0 | Here's what I would like to do:
I'm taking pictures with a webcam at regular intervals. Sort of like a time lapse thing. However, if nothing has really changed, that is, the picture pretty much looks the same, I don't want to store the latest snapshot.
I imagine there's some way of quantifying the difference, and I w... | How can I quantify difference between two images? | 0.008333 | 0 | 0 | 231,920 |
189,943 | 2008-10-10T02:39:00.000 | 0 | 0 | 1 | 0 | python,image-processing,background-subtraction,image-comparison,timelapse | 69,118,422 | 24 | false | 0 | 0 | Use SSIM to measure the Structural Similarity Index Measure between 2 images. | 6 | 212 | 0 | Here's what I would like to do:
I'm taking pictures with a webcam at regular intervals. Sort of like a time lapse thing. However, if nothing has really changed, that is, the picture pretty much looks the same, I don't want to store the latest snapshot.
I imagine there's some way of quantifying the difference, and I w... | How can I quantify difference between two images? | 0 | 0 | 0 | 231,920 |
189,943 | 2008-10-10T02:39:00.000 | 0 | 0 | 1 | 0 | python,image-processing,background-subtraction,image-comparison,timelapse | 189,967 | 24 | false | 0 | 0 | I think you could simply compute the euclidean distance (i.e. sqrt(sum of squares of differences, pixel by pixel)) between the luminance of the two images, and consider them equal if this falls under some empirical threshold. And you would better do it wrapping a C function. | 6 | 212 | 0 | Here's what I would like to do:
I'm taking pictures with a webcam at regular intervals. Sort of like a time lapse thing. However, if nothing has really changed, that is, the picture pretty much looks the same, I don't want to store the latest snapshot.
I imagine there's some way of quantifying the difference, and I w... | How can I quantify difference between two images? | 0 | 0 | 0 | 231,920 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.