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 process has it's own python process, which in turn has it's own internals. So as long as I get served by the same process I logged in to, everything is fine and dandy. But if my request gets served by a different apache process, I am no longer authenticated. I have checked the HTTP headers I send with FireBug, and they are the same each time, ie. same cookie. Is this a known issue and are there workarounds/fixes? Edit: I have a page that displays a lot of generated images. Some off these will not display. This is because they are too behind the authenticating middleware, so they will randomly put up a login image. However, refreshing this page enough times, and it will eventually work, meaning all processes recognize my session.
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 attackers to run arbitrary commands on your machine.
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 to call the Python script. Any better ideas? Thanks in advance!
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 to call the Python script. Any better ideas? Thanks in advance!
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 won't be able to sufficiently scale in terms of performance or capabilities. Requirements are: Cross-platform (Linux, MacOS X, Windows) Low complexity overhead Plays well with wxpython (at least won't step on each other's toes unduly) Interactivity. Detect when objects are clicked on, moused over, etc. Note that high performance isn't on the list, but the ability to handle ~100 bitmap objects on the screen would be good. Your thoughts?
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 inherently less performant. To conclude, I don't think there's place to worry about it. Neither to hope for a major improvement of some kind.
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 app is python really the right language to be using?
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 you can do to improve it's performance, although I imagine stuff like the garbage collection and memory management code will have had some tweaks, but it's not going to be a "wow, my database statistic generation code completes in half the time!" improvement - that's something you get by improving the code, rather than the language! Really, performance of the language is irrelevant - all interpreted languages basically function at the same speed. Why I find Python "faster" is all the built-in moudles, and the nice-to-write syntax - something that has been improved in Python3, so I guess in those terms, yes, python3's performance is better then python2.x..
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 py3k. My understanding is that the py3k beta process was drawn out specifically to give library developers time to move their stuff over. Has this been happening? Examples of the sorts of libraries I am talking about would be PIL, numpy/ scipy, SQLAlchemy, BeautifulSoup, CherryPy...
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 py3k. My understanding is that the py3k beta process was drawn out specifically to give library developers time to move their stuff over. Has this been happening? Examples of the sorts of libraries I am talking about would be PIL, numpy/ scipy, SQLAlchemy, BeautifulSoup, CherryPy...
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 py3k. My understanding is that the py3k beta process was drawn out specifically to give library developers time to move their stuff over. Has this been happening? Examples of the sorts of libraries I am talking about would be PIL, numpy/ scipy, SQLAlchemy, BeautifulSoup, CherryPy...
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 works on python sources, not C modules.. It's hard to generalise - some modules may never be ported, some may take days, others may take years. It could end up being a situation along the lines of "well I'm not porting my library to Python3, no one is using it!"/"Well I'm not porting my project to python3, no libraries have been updated yet!", but I hope not!
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 py3k. My understanding is that the py3k beta process was drawn out specifically to give library developers time to move their stuff over. Has this been happening? Examples of the sorts of libraries I am talking about would be PIL, numpy/ scipy, SQLAlchemy, BeautifulSoup, CherryPy...
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 cPython3 C extensions need to use.
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 py3k. My understanding is that the py3k beta process was drawn out specifically to give library developers time to move their stuff over. Has this been happening? Examples of the sorts of libraries I am talking about would be PIL, numpy/ scipy, SQLAlchemy, BeautifulSoup, CherryPy...
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, though: as a rule of thumb, I typically suggest that important projects (related to work, mainly) should not be ported immediately to new development technologies (Python 3, .Net 3.x, etc) until such answers as yours have already been answered and many of the initial bugs have been solved. For pet or test projects, though, I'm all in for updates and experimentation.
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 py3k. My understanding is that the py3k beta process was drawn out specifically to give library developers time to move their stuff over. Has this been happening? Examples of the sorts of libraries I am talking about would be PIL, numpy/ scipy, SQLAlchemy, BeautifulSoup, CherryPy...
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 SetFont() method to all these text objects without making separate calls each time?
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 generally coordinate library upgrades.
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 downloads or the SVN's in there first. Every Single Time. Do installs from there. The packages that you wrote that are reusable. I have a Projects folder with each project in that folder. If the project is a highly reusable thing, it has a setup.py and I actually run the install as if I downloaded it. I don't have many of these, but a few. Some of them might become open source projects. The final applications you write. I have a folder in Projects with each of these top-level applications. These are usually big, rambling things (like Django sites) and don't have setup.py. Why? They're often pretty complex with only a few server installations to manage, and each of those server installations is unique. These generally rely on PYTHONPATH to identify their parts. Notice the common theme. Either they're Components you downloaded or they're Projects you're working on. Also, I keep this separate (to an extent) from the client. I have a master directory of Client folders, each of which has Projects and each project has Sales and Delivery. Not all projects have both sales and delivery.
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 app. Does such an OpenID dev server exist? Is this the best way to go about it?
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 code without 2to3 for Python 2 and 3 support. We port the ZTK to Python 3 because many other libraries and frameworks depend on it, such as Twisted and the Pyramid framework.
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 already started or plan on starting soon? Or do you plan on waiting until the final version comes out to get into full swing?
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 3.x branches. 2.x will be backwards compatible to 2.4, so I can't use a lot of the fancy syntax or new features in 2.6 / 3.0. In contrast, the 3.x branch will use every one of those features that results in a nicer experience for the user. The test suite will be modified so that 2to3 will work upon it, and I'll maintain the same tests for both branches.
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 already started or plan on starting soon? Or do you plan on waiting until the final version comes out to get into full swing?
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 to migrate everything in one go. At work, we plan to upgrade from 2.5 to 2.6 first. Then we begin enabling 3.0 features slowly one module at a time. At some point a whole subpart of the system will probably be ready for 3.x. The only problem are libraries. If a library is never migrated, we are stuck with the old library. But I am pretty confident that we'll get a fine alternative in due time for that part.
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 already started or plan on starting soon? Or do you plan on waiting until the final version comes out to get into full swing?
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 already started or plan on starting soon? Or do you plan on waiting until the final version comes out to get into full swing?
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 functions and/or modules.
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 good ways to greatly improve performance? For the first question, imagine you are handed a decently written project and you need to improve performance, but you can't seem to get much of a gain through refactoring/optimization. What would you do to speed it up in this case short of rewriting it in something like C?
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 good ways to greatly improve performance? For the first question, imagine you are handed a decently written project and you need to improve performance, but you can't seem to get much of a gain through refactoring/optimization. What would you do to speed it up in this case short of rewriting it in something like C?
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 well and still generate very fast code; at least for the forseeable future (and some of the design works against fast compilation) that will be the case. So, if you really find yourself in this bind, your best bet will be to isolate the parts of your system that are unacceptable slow in (good) python, and design around the idea that you'll rewrite those bits in C. Sorry. Good design can help make this less painful. Prototype it in python first though, then you've easily got a sanity check on your c, as well. This works well enough for things like numpy, after all. I can't emphasize enough how much good design will help you though. If you just iteratively poke at your python bits and replace the slowest ones with C, you may end up with a big mess. Think about exactly where the C bits are needed, and how they can be minimized and encapsulated sensibly.
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 good ways to greatly improve performance? For the first question, imagine you are handed a decently written project and you need to improve performance, but you can't seem to get much of a gain through refactoring/optimization. What would you do to speed it up in this case short of rewriting it in something like C?
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. The latter is preferable Beware of code that first constructs a big data structure followed by its consumation. Think the difference between range and xrange. In general it is often worth thinking about memory usage of the program. Using generators can sometimes bring O(n) memory use down to O(1). Python is generally non-optimizing. Hoist invariant code out of loops, eliminate common subexpressions where possible in tight loops. If something is expensive, then precompute or memoize it. Regular expressions can be compiled for instance. Need to crunch numbers? You might want to check numpy out. Many python programs are slow because they are bound by disk I/O or database access. Make sure you have something worthwhile to do while you wait on the data to arrive rather than just blocking. A weapon could be something like the Twisted framework. Note that many crucial data-processing libraries have C-versions, be it XML, JSON or whatnot. They are often considerably faster than the Python interpreter. If all of the above fails for profiled and measured code, then begin thinking about the C-rewrite path.
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 good ways to greatly improve performance? For the first question, imagine you are handed a decently written project and you need to improve performance, but you can't seem to get much of a gain through refactoring/optimization. What would you do to speed it up in this case short of rewriting it in something like C?
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 containers.
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 good ways to greatly improve performance? For the first question, imagine you are handed a decently written project and you need to improve performance, but you can't seem to get much of a gain through refactoring/optimization. What would you do to speed it up in this case short of rewriting it in something like C?
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 as c functions for python.
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 good ways to greatly improve performance? For the first question, imagine you are handed a decently written project and you need to improve performance, but you can't seem to get much of a gain through refactoring/optimization. What would you do to speed it up in this case short of rewriting it in something like C?
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 [str(x) for x in l] or [x.strip() for x in l] is much, much slower than map(str, x) or map(str.strip, x). After this, if I still need more speed, it's actually really easy to get PyRex up and running. I first copy a section of python code, put it directly in the pyrex code, and see what happens. Then I twiddle with it until it gets faster and faster.
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 good ways to greatly improve performance? For the first question, imagine you are handed a decently written project and you need to improve performance, but you can't seem to get much of a gain through refactoring/optimization. What would you do to speed it up in this case short of rewriting it in something like C?
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 ui applications because the script must contain explicit while loop or semaphore to prevent main thread from exit There function sys.exit() is not available. Again, I'm a newbie to PyS60 so if the issues given above do have nice workarounds don't hesitate to write them as comments. I would be very grateful.
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 developing on Windows Mobile, I have already decided not to do that so will mark those answers down.
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 developing on Windows Mobile, I have already decided not to do that so will mark those answers down.
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 process ID (returned by the os.fork() call) and then use os.kill() to kill it when not needed anymore. Of course, it would probably be cleaner to be able to communicate with the child process explicitly and tell it to shut itself down.
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 after all kids are collected. What is the best way to work it out? Thanks.
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 add it wherever u want....
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 often is the scheduling run - is it run interactively - so potentially someone could be told they can play, only to be told they can't; or is it run in a more batch manner - you put in requests, then get told later if you can have your slot. Or do users set up a number of preferred times, and then the system has to maximise the number of people getting their most highly preferred times? As an aside, you can make it slightly less complex by re-writing the times as integer indexes (so you're dealing with integers rather than times).
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 chosen. I'm thinking about using some optimization algorithms to solve this problem but I'am not sure what would be the best cost function and/or algorithm to use. Any advice? One more thing I would prefer to use Python but some language-agnostic advice would be welcome also. Thanks! edit: some clarifications- the one with better priority wins and loser is moved to nearest slot, rather flexible time slots question yes, maximizing the number of people getting their most highly preffered times
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 chosen. I'm thinking about using some optimization algorithms to solve this problem but I'am not sure what would be the best cost function and/or algorithm to use. Any advice? One more thing I would prefer to use Python but some language-agnostic advice would be welcome also. Thanks! edit: some clarifications- the one with better priority wins and loser is moved to nearest slot, rather flexible time slots question yes, maximizing the number of people getting their most highly preffered times
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 chosen. I'm thinking about using some optimization algorithms to solve this problem but I'am not sure what would be the best cost function and/or algorithm to use. Any advice? One more thing I would prefer to use Python but some language-agnostic advice would be welcome also. Thanks! edit: some clarifications- the one with better priority wins and loser is moved to nearest slot, rather flexible time slots question yes, maximizing the number of people getting their most highly preffered times
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 obvious?
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 of python's syntax so it doesn't need to be declared whereas you have to declare the array before using it. You can store values of different data-types in a list (heterogeneous), whereas in Array you can only store values of only the same data-type (homogeneous). Arrays being rich in functionalities and fast, it is widely used for arithmetic operations and for storing a large amount of data - compared to list. Arrays take less memory compared to lists.
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 obvious?
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 obvious?
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 obvious?
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 obvious?
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 obvious?
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 obvious?
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 targets for each node and a large quantity of data then you may well find that the overhead of adding an ACK/NAK to every packet is sufficient to adversely limit your throughput, particularly when you add retransmissions into the mix. As Frank Szczerba has said multimedia data has the benefit of being able to recover from lost packets. If you have any control over the data that you're sending you should try to design the payloads so that you minimise the susceptibility to dropped packets. If the data that you're sending cannot tolerate dropped packets and you're trying to scale to high utilisation of your network then perhaps udp is not the best protocol to use. Implementing a series of tcp proxies (where each node retransmits, unicast, to all other connected nodes - similar to your flooding idea) would be a more reliable mechanism. With all of that said, have you considered using true multicast for this application? Just saw the "homework" tag... these suggestions might not be appropriate for a homework problem.
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 sequence numbers for the message id's it receives, and sending back and forth ACK's and NACK's. write an inefficient flooding system, where each multicaster simply re-sends each message it receives once (unless it was sent by that particular multicaster.) I'm allowed to use the second option, and am inclined to do so. I'm currently multicasting UDP messages (which seems to be the only option,) but that means that some messages might get lost. That means I have to be able to uniquely identify each sent UDP message, so that it can be re-sent according to #2. Should I really generate unique numbers (e.g. using the sender address and a counter) and pack them into each and every UDP message sent? How would I go about doing that? And how do I receive a single UDP message in Python, and not a stream of data (i.e. socket.recv)?
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 packet is a dropped frame, which won't matter when the next frame gets there anyway. Fixed period data: Recipient node keeps a timer that is reset each time an update is received. If the time expires, it requests the missing update from the master node. Retries can be unicast to the requesting node. If neither of these situations applies (every packet has to be received by every node, and the packet timing is unpredictable, so recipients can't detect missed packets on their own), then your options include: Explicit ACK from every node for each packet. Sender retries (unicast) any packet that is not ACKed. TCP-based grid approach, where each node is manually repeats received packets to neighbor nodes, relying on TCP mechanisms to ensure delivery. You could possibly rely on recipients noticing a missed packet upon reception of one with a later sequence number, but this requires the sender to keep the packet around until at least one additional packet has been sent. Requiring positive ACKs is more reliable (and provable).
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 sequence numbers for the message id's it receives, and sending back and forth ACK's and NACK's. write an inefficient flooding system, where each multicaster simply re-sends each message it receives once (unless it was sent by that particular multicaster.) I'm allowed to use the second option, and am inclined to do so. I'm currently multicasting UDP messages (which seems to be the only option,) but that means that some messages might get lost. That means I have to be able to uniquely identify each sent UDP message, so that it can be re-sent according to #2. Should I really generate unique numbers (e.g. using the sender address and a counter) and pack them into each and every UDP message sent? How would I go about doing that? And how do I receive a single UDP message in Python, and not a stream of data (i.e. socket.recv)?
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 associated with the word, so professor is smart and dog is not smart. Alaska is big, as a proportion of the total value associated with its entries, and the opposite is true of gnat. Is there a good way to get the absolute value of the number farthest from zero, and some token whether absolute value =/= value? Relatedly, how might I calculate whether the results for a given value are proportionately large with respect to the other values? I would write something to format the output to the effect of: "dog: not smart, probably not expensive; professor smart; ferrari: fast, expensive; alaska: big; gnat: probably small." (The formatting is not a question, just an illustration, I am stuck on the underlying queries.) Also, the rest of the program is python, so if there is any python solution with normal dbapi modules or a more abstract module, any help appreciated.
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 are met, I figure that the easiest way to alert the user would be to produce a pop-up, as it needs to be handled immediately, and other options such as just logging, or sending an email are not efficient enough.
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 work!)
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 painful. I'm still at the start, what am I missing? In the "real" world, what should I think to use it for? When should it can do better than Python? For better I mean: easy way to write something performing. UPDATE 1: One of the things I'd like to know the most is "Am I missing something?" :D UPDATE 2: Thank you for your answers. My question is not about buy or not to buy MATLAB. The university has the possibility to give me a copy of an old version of MATLAB (MATLAB 5 I guess) for free, without breaking the license. I'm interested in its capabilities and if it deserves a deeper study (I won't need anything more than basic MATLAB in oder to pass the exam :P ) it will really be better than Python for a specific kind of task in the real world.
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 painful. I'm still at the start, what am I missing? In the "real" world, what should I think to use it for? When should it can do better than Python? For better I mean: easy way to write something performing. UPDATE 1: One of the things I'd like to know the most is "Am I missing something?" :D UPDATE 2: Thank you for your answers. My question is not about buy or not to buy MATLAB. The university has the possibility to give me a copy of an old version of MATLAB (MATLAB 5 I guess) for free, without breaking the license. I'm interested in its capabilities and if it deserves a deeper study (I won't need anything more than basic MATLAB in oder to pass the exam :P ) it will really be better than Python for a specific kind of task in the real world.
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 a lot of programming experience to pick up.
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 painful. I'm still at the start, what am I missing? In the "real" world, what should I think to use it for? When should it can do better than Python? For better I mean: easy way to write something performing. UPDATE 1: One of the things I'd like to know the most is "Am I missing something?" :D UPDATE 2: Thank you for your answers. My question is not about buy or not to buy MATLAB. The university has the possibility to give me a copy of an old version of MATLAB (MATLAB 5 I guess) for free, without breaking the license. I'm interested in its capabilities and if it deserves a deeper study (I won't need anything more than basic MATLAB in oder to pass the exam :P ) it will really be better than Python for a specific kind of task in the real world.
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 painful. I'm still at the start, what am I missing? In the "real" world, what should I think to use it for? When should it can do better than Python? For better I mean: easy way to write something performing. UPDATE 1: One of the things I'd like to know the most is "Am I missing something?" :D UPDATE 2: Thank you for your answers. My question is not about buy or not to buy MATLAB. The university has the possibility to give me a copy of an old version of MATLAB (MATLAB 5 I guess) for free, without breaking the license. I'm interested in its capabilities and if it deserves a deeper study (I won't need anything more than basic MATLAB in oder to pass the exam :P ) it will really be better than Python for a specific kind of task in the real world.
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. Having used Python in grad school, I kind of wish I had the licks to work with MATLAB in that case. It sure would make vector space calculations a breeze.
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 painful. I'm still at the start, what am I missing? In the "real" world, what should I think to use it for? When should it can do better than Python? For better I mean: easy way to write something performing. UPDATE 1: One of the things I'd like to know the most is "Am I missing something?" :D UPDATE 2: Thank you for your answers. My question is not about buy or not to buy MATLAB. The university has the possibility to give me a copy of an old version of MATLAB (MATLAB 5 I guess) for free, without breaking the license. I'm interested in its capabilities and if it deserves a deeper study (I won't need anything more than basic MATLAB in oder to pass the exam :P ) it will really be better than Python for a specific kind of task in the real world.
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, Python is a much nicer general purpose programming language and, with the right libraries can do much of what Matlab does. However, Matlab is always going to have a more concise syntax than Python for vector and matrix manipulation. If much of your programming involves these sorts of manipulations, such as in signal processing and some statistical techniques, then Matlab will be a better choice.
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 painful. I'm still at the start, what am I missing? In the "real" world, what should I think to use it for? When should it can do better than Python? For better I mean: easy way to write something performing. UPDATE 1: One of the things I'd like to know the most is "Am I missing something?" :D UPDATE 2: Thank you for your answers. My question is not about buy or not to buy MATLAB. The university has the possibility to give me a copy of an old version of MATLAB (MATLAB 5 I guess) for free, without breaking the license. I'm interested in its capabilities and if it deserves a deeper study (I won't need anything more than basic MATLAB in oder to pass the exam :P ) it will really be better than Python for a specific kind of task in the real world.
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 Gigabytes of data to crunch and/or plot. Learn just basic stuff, but also don't kill yourself trying to make Python be a graphing calculator. You'll quickly get a feel for when you want to crunch, plot or explore in MATLAB and when you want to have all that Python offers. Lots of engineers turn to pre and post processing in Python or Perl. Occasionally even just calling out to MATLAB for the hard bits. They are such completely different tools that you should learn their basic strengths first without trying to replace one with the other. Granted for saving money I'd either use Octave or skimp on ease and learn to work with sparse matrices in Perl or Python.
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 painful. I'm still at the start, what am I missing? In the "real" world, what should I think to use it for? When should it can do better than Python? For better I mean: easy way to write something performing. UPDATE 1: One of the things I'd like to know the most is "Am I missing something?" :D UPDATE 2: Thank you for your answers. My question is not about buy or not to buy MATLAB. The university has the possibility to give me a copy of an old version of MATLAB (MATLAB 5 I guess) for free, without breaking the license. I'm interested in its capabilities and if it deserves a deeper study (I won't need anything more than basic MATLAB in oder to pass the exam :P ) it will really be better than Python for a specific kind of task in the real world.
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 summer, I had a job where I used Python + numpy instead of Matlab. I enjoyed the change of pace. It's a "real" language (and all that entails), and it has some great numeric features like broadcasting arrays. I also really like the ipython environment. Here are some things that I prefer about Matlab: consistency: MathWorks has spent a lot of effort making the toolboxes look and work like each other. They haven't done a perfect job, but it's one of the best I've seen for a codebase that's decades old. documentation: I find it very frustrating to figure out some things in numpy and/or python because the documentation quality is spotty: some things are documented very well, some not at all. It's often most frustrating when I see things that appear to mimic Matlab, but don't quite work the same. Being able to grab the source is invaluable (to be fair, most of the Matlab toolboxes ship with source too) compactness: for what I do, Matlab's syntax is often more compact (but not always) momentum: I have too much Matlab code to change now If I didn't have such a large existing codebase, I'd seriously consider switching to Python + numpy.
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 painful. I'm still at the start, what am I missing? In the "real" world, what should I think to use it for? When should it can do better than Python? For better I mean: easy way to write something performing. UPDATE 1: One of the things I'd like to know the most is "Am I missing something?" :D UPDATE 2: Thank you for your answers. My question is not about buy or not to buy MATLAB. The university has the possibility to give me a copy of an old version of MATLAB (MATLAB 5 I guess) for free, without breaking the license. I'm interested in its capabilities and if it deserves a deeper study (I won't need anything more than basic MATLAB in oder to pass the exam :P ) it will really be better than Python for a specific kind of task in the real world.
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 matlab. However, matlab does provide a number of other tools - eg. a very broad array of dsp features, a broad array of S and Z domain features. All of these could be hand coded in python (since it's a general purpose language), but if all you're after is the results perhaps spending the money on Matlab is the cheaper option? These features have also been tuned for performance. eg. The documentation for Numpy specifies that their Fourier transform is optimised for power of 2 point data sets. As I understand Matlab has been written to use the most efficient Fourier transform to suit the size of the data set, not just power of 2. edit: Oh, and in Matlab you can produce some sensational looking plots very easily, which is important when you're presenting your data. Again, certainly not impossible using other tools.
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 painful. I'm still at the start, what am I missing? In the "real" world, what should I think to use it for? When should it can do better than Python? For better I mean: easy way to write something performing. UPDATE 1: One of the things I'd like to know the most is "Am I missing something?" :D UPDATE 2: Thank you for your answers. My question is not about buy or not to buy MATLAB. The university has the possibility to give me a copy of an old version of MATLAB (MATLAB 5 I guess) for free, without breaking the license. I'm interested in its capabilities and if it deserves a deeper study (I won't need anything more than basic MATLAB in oder to pass the exam :P ) it will really be better than Python for a specific kind of task in the real world.
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 in it with virtually no actual programming knowledge. The language is, as you point out, extremely frustrating to use for more general-purpose tasks, such as even the simplest string processing. Its syntax is quirky, and it wasn't created with the abstractions necessary for projects of more than 100 lines or so in mind. I think the reason why people try to use Matlab as a serious programming language is that most engineers (there are exceptions; my degree is in biomedical engineering and I like programming) are horrible programmers and hate to program. They're taught Matlab in college mostly for the matrix math, and they learn some rudimentary programming as part of learning Matlab, and just assume that Matlab is good enough. I can't think of anyone I know who knows any language besides Matlab, but still uses Matlab for anything other than a few pure number crunching applications.
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 painful. I'm still at the start, what am I missing? In the "real" world, what should I think to use it for? When should it can do better than Python? For better I mean: easy way to write something performing. UPDATE 1: One of the things I'd like to know the most is "Am I missing something?" :D UPDATE 2: Thank you for your answers. My question is not about buy or not to buy MATLAB. The university has the possibility to give me a copy of an old version of MATLAB (MATLAB 5 I guess) for free, without breaking the license. I'm interested in its capabilities and if it deserves a deeper study (I won't need anything more than basic MATLAB in oder to pass the exam :P ) it will really be better than Python for a specific kind of task in the real world.
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 ears... No-one in the company knew Python although many of us wanted to use it. MatLab has a name, a company, and task force behind it to solve any problems. There were some (but not a lot) of legacy MatLab projects that would need to be re-written. If it's worth £10,000 (??) it's gotta be worth it!! I'm with you here. Python is a very good replacement for MatLab. I should point out that I've been told the company uses maybe 5% to 10% of MatLabs capabilities and that is the basis for my agreement with the original poster
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 painful. I'm still at the start, what am I missing? In the "real" world, what should I think to use it for? When should it can do better than Python? For better I mean: easy way to write something performing. UPDATE 1: One of the things I'd like to know the most is "Am I missing something?" :D UPDATE 2: Thank you for your answers. My question is not about buy or not to buy MATLAB. The university has the possibility to give me a copy of an old version of MATLAB (MATLAB 5 I guess) for free, without breaking the license. I'm interested in its capabilities and if it deserves a deeper study (I won't need anything more than basic MATLAB in oder to pass the exam :P ) it will really be better than Python for a specific kind of task in the real world.
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 painful. I'm still at the start, what am I missing? In the "real" world, what should I think to use it for? When should it can do better than Python? For better I mean: easy way to write something performing. UPDATE 1: One of the things I'd like to know the most is "Am I missing something?" :D UPDATE 2: Thank you for your answers. My question is not about buy or not to buy MATLAB. The university has the possibility to give me a copy of an old version of MATLAB (MATLAB 5 I guess) for free, without breaking the license. I'm interested in its capabilities and if it deserves a deeper study (I won't need anything more than basic MATLAB in oder to pass the exam :P ) it will really be better than Python for a specific kind of task in the real world.
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 flying, how the wind affects those same rockets, and how different engines matter. Beyond rocketry, similar concepts come into play for cars, trucks, aircraft, spacecraft, and even athletics. You can pull in large amounts of data, manipulate all of it, and make sure your results are as they should be. In the event something is off, you can add a line break where an error occurs to debug your program without having to recompile every time you want to run your program. Is it slower than some other programs? Well, technically. I'm sure if you want to do the number crunching it's great for on an NVIDIA graphics processor, it would probably be faster, but it requires a lot more effort with harder debugging. As a general programming language, MATLAB is weak. It's not meant to work against Python, Java, ActionScript, C/C++ or any other general purpose language. It's meant for the engineering and mathematics niche the name implies, and it does so fantastically.
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 painful. I'm still at the start, what am I missing? In the "real" world, what should I think to use it for? When should it can do better than Python? For better I mean: easy way to write something performing. UPDATE 1: One of the things I'd like to know the most is "Am I missing something?" :D UPDATE 2: Thank you for your answers. My question is not about buy or not to buy MATLAB. The university has the possibility to give me a copy of an old version of MATLAB (MATLAB 5 I guess) for free, without breaking the license. I'm interested in its capabilities and if it deserves a deeper study (I won't need anything more than basic MATLAB in oder to pass the exam :P ) it will really be better than Python for a specific kind of task in the real world.
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 imagine that such a large number of people would care about it. What am I missing? What is the problem with reduce()?
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 imagine that such a large number of people would care about it. What am I missing? What is the problem with reduce()?
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 imagine that such a large number of people would care about it. What am I missing? What is the problem with reduce()?
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 program and any errors that may occur, I haven't uses a debugger tool yet. What situations may call for using a real debugger vs. the method I currently use? I'd like to know before I get into a situation and get frustrated because I don't know how to fix the problem.
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() line, it drops into the interactive debugger and I can inspect the context in which the failure occurs with the usual pdb commands looking for clues as to the cause.
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 program and any errors that may occur, I haven't uses a debugger tool yet. What situations may call for using a real debugger vs. the method I currently use? I'd like to know before I get into a situation and get frustrated because I don't know how to fix the problem.
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 for using them, I'm sure, or people wouldn't lavish such love and care on them. Here's the point -- software is knowledge capture. Yes, it does have to run. More importantly, however, software has meaning. This is not an indictment of your use of a debugger. However, I find that the folks who rely on debugging will sometimes produce really odd-looking code and won't have a good justification for what it means. They can only say "it may be a hack, but it works." My suggestion on debuggers is "don't bother". "But, what if I'm totally stumped?" you ask, "should I learn the debugger then?" Totally stumped by what? The language? Python's too simple for utter befuddlement. Some library? Perhaps. Here's what you do -- with or without a debugger. You have the source, read it. You write small tests to exercise the library. Using the interactive shell, if possible. [All the really good libraries seem to show their features using the interactive Python mode -- I strive for this level of tight, clear simplicity.] You have the source, add print functions.
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 program and any errors that may occur, I haven't uses a debugger tool yet. What situations may call for using a real debugger vs. the method I currently use? I'd like to know before I get into a situation and get frustrated because I don't know how to fix the problem.
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 with prints. Normally there can be more than one point of failures resulting in a bug, all are not obvious in the first look. So you look for obvious places, if nothing is wrong there, you move ahead and add some more prints.. debugger can save you time here, you dont need to add the print and run again.
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 program and any errors that may occur, I haven't uses a debugger tool yet. What situations may call for using a real debugger vs. the method I currently use? I'd like to know before I get into a situation and get frustrated because I don't know how to fix the problem.
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.FindNextChangeNotification function but have no idea how to ask it to watch a specific file. If anyone's done anything like this I'd be really grateful to hear how... [Edit] I should have mentioned that I was after a solution that doesn't require polling. [Edit] Curses! It seems this doesn't work over a mapped network drive. I'm guessing windows doesn't 'hear' any updates to the file the way it does on a local disk.
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 - active pip - 1.0.2 - active setuptools - 0.6c11 - active wsgiref - 0.1.2 - active development (/usr/lib/python2.6) yolk - 0.4.1 - active The list of possible commands is then extended with among other things the runscript command.
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 willing to use beta code and such but by January, I'd like a site that doesn't have 'strange' problems. With that said, if a language is simply 10% slower than another, I don't care about those things as long as the issue is linear. My main concern is developer productivity. I'll be using Linux, Apache, MySQL for the application. I want the power to do things like run scp and ftp client functions with stable libraries (I only picked those two because they're not web-related but at the same time represent pretty common network protocols that any larger app might use). Technologies like OpenID and Oauth will be used as well. Experienced web developers are readily available (i.e. I don't have to find people from financial companies and such). Whatever the choice is is common and will be around for a while. Here's a kicker. I'd like to be able to use advanced presentation layer tools/languages similar to HAML, SASS. I definitively want to use JQuery. I will be creating a Facebook app and at some point doing things like dealing with SMS messages, iPhone apps, etc... At this point, the choices for language are PHP (Cake,Symfony,Zend), Python (Django), Ruby (Merb). I'm really between Django and Merb at this point mostly because everybody else seems to be going that way. Please don't put any technologies in here that aren't made for mainstream. I know Merb is untested mostly, but their stated goal is a solid platform and it has alot of momentum behind it so I'm confident that it's workable. Please don't answer with how great Perl is or .Net. For Future References - these choices were already made: Debian (Lenny) - For converting CPU cycles into something useful. Trac 0.11 - For Project Management Gliffy - For wireframes and such Google Docs/Apps - For documentation, hosted email, etc... Amazon ec2/S3 - For hosting, storage. Cheers, Adam
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 additional languages here. Got the idea? I recommend you to try each of the languages you mentioned for yourself. At least a few days each. Afterwards you should have a much better foundation to make your final decision. That said, I would choose Ruby (because I am a Ruby advocate).
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 willing to use beta code and such but by January, I'd like a site that doesn't have 'strange' problems. With that said, if a language is simply 10% slower than another, I don't care about those things as long as the issue is linear. My main concern is developer productivity. I'll be using Linux, Apache, MySQL for the application. I want the power to do things like run scp and ftp client functions with stable libraries (I only picked those two because they're not web-related but at the same time represent pretty common network protocols that any larger app might use). Technologies like OpenID and Oauth will be used as well. Experienced web developers are readily available (i.e. I don't have to find people from financial companies and such). Whatever the choice is is common and will be around for a while. Here's a kicker. I'd like to be able to use advanced presentation layer tools/languages similar to HAML, SASS. I definitively want to use JQuery. I will be creating a Facebook app and at some point doing things like dealing with SMS messages, iPhone apps, etc... At this point, the choices for language are PHP (Cake,Symfony,Zend), Python (Django), Ruby (Merb). I'm really between Django and Merb at this point mostly because everybody else seems to be going that way. Please don't put any technologies in here that aren't made for mainstream. I know Merb is untested mostly, but their stated goal is a solid platform and it has alot of momentum behind it so I'm confident that it's workable. Please don't answer with how great Perl is or .Net. For Future References - these choices were already made: Debian (Lenny) - For converting CPU cycles into something useful. Trac 0.11 - For Project Management Gliffy - For wireframes and such Google Docs/Apps - For documentation, hosted email, etc... Amazon ec2/S3 - For hosting, storage. Cheers, Adam
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 want. Don't pick one because it's the flavor of the month, pick one because you're comfortable with it. Flavors don't last, a solidly built codebase will.
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 willing to use beta code and such but by January, I'd like a site that doesn't have 'strange' problems. With that said, if a language is simply 10% slower than another, I don't care about those things as long as the issue is linear. My main concern is developer productivity. I'll be using Linux, Apache, MySQL for the application. I want the power to do things like run scp and ftp client functions with stable libraries (I only picked those two because they're not web-related but at the same time represent pretty common network protocols that any larger app might use). Technologies like OpenID and Oauth will be used as well. Experienced web developers are readily available (i.e. I don't have to find people from financial companies and such). Whatever the choice is is common and will be around for a while. Here's a kicker. I'd like to be able to use advanced presentation layer tools/languages similar to HAML, SASS. I definitively want to use JQuery. I will be creating a Facebook app and at some point doing things like dealing with SMS messages, iPhone apps, etc... At this point, the choices for language are PHP (Cake,Symfony,Zend), Python (Django), Ruby (Merb). I'm really between Django and Merb at this point mostly because everybody else seems to be going that way. Please don't put any technologies in here that aren't made for mainstream. I know Merb is untested mostly, but their stated goal is a solid platform and it has alot of momentum behind it so I'm confident that it's workable. Please don't answer with how great Perl is or .Net. For Future References - these choices were already made: Debian (Lenny) - For converting CPU cycles into something useful. Trac 0.11 - For Project Management Gliffy - For wireframes and such Google Docs/Apps - For documentation, hosted email, etc... Amazon ec2/S3 - For hosting, storage. Cheers, Adam
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 programmers can be harder to find, django even harder. changing your db schema can be somewhat difficult since there are no official migrations. doesn't quite do mvc like you'd expect. upsides: does everything you need and has the great python std library and community behind it. ruby - i've never used merb, so I'll address rails. upsides: there is a plugin, gem, or recipe for almost anything you could want to do. easy to use. downsides: those plugins, gems, and recipes sometimes fail to work in mysterious ways. monkey patching is often evil. the community is.. vocal. opinionated software, and sometimes those opinions are wrong (lack of foreign keys). rails itself seems like a tower of cards waiting to explode and take hours of your life away. with all of that said, I'm a freelance php/symfony and ruby/rails developer. I've worked on several projects in both languages and frameworks. My latest project is in Rails solely because of ActiveMerchant. I've been looking for a reason to develop a django app for a while. If there were an ActiveMerchant like library for django, I probably would have used it.
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 willing to use beta code and such but by January, I'd like a site that doesn't have 'strange' problems. With that said, if a language is simply 10% slower than another, I don't care about those things as long as the issue is linear. My main concern is developer productivity. I'll be using Linux, Apache, MySQL for the application. I want the power to do things like run scp and ftp client functions with stable libraries (I only picked those two because they're not web-related but at the same time represent pretty common network protocols that any larger app might use). Technologies like OpenID and Oauth will be used as well. Experienced web developers are readily available (i.e. I don't have to find people from financial companies and such). Whatever the choice is is common and will be around for a while. Here's a kicker. I'd like to be able to use advanced presentation layer tools/languages similar to HAML, SASS. I definitively want to use JQuery. I will be creating a Facebook app and at some point doing things like dealing with SMS messages, iPhone apps, etc... At this point, the choices for language are PHP (Cake,Symfony,Zend), Python (Django), Ruby (Merb). I'm really between Django and Merb at this point mostly because everybody else seems to be going that way. Please don't put any technologies in here that aren't made for mainstream. I know Merb is untested mostly, but their stated goal is a solid platform and it has alot of momentum behind it so I'm confident that it's workable. Please don't answer with how great Perl is or .Net. For Future References - these choices were already made: Debian (Lenny) - For converting CPU cycles into something useful. Trac 0.11 - For Project Management Gliffy - For wireframes and such Google Docs/Apps - For documentation, hosted email, etc... Amazon ec2/S3 - For hosting, storage. Cheers, Adam
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 everything is deprecated, that can turn out to result in extra unnecessary work. This was particularly my experience working with rails a little ahead of version 1. For that reason alone I would avoid any platform that wasn't at least at 1.0 when you start work on it. Ruby is great to work with and will keep your developer productivity high, but if Django is the more stable platform I would favour that for sure.
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 willing to use beta code and such but by January, I'd like a site that doesn't have 'strange' problems. With that said, if a language is simply 10% slower than another, I don't care about those things as long as the issue is linear. My main concern is developer productivity. I'll be using Linux, Apache, MySQL for the application. I want the power to do things like run scp and ftp client functions with stable libraries (I only picked those two because they're not web-related but at the same time represent pretty common network protocols that any larger app might use). Technologies like OpenID and Oauth will be used as well. Experienced web developers are readily available (i.e. I don't have to find people from financial companies and such). Whatever the choice is is common and will be around for a while. Here's a kicker. I'd like to be able to use advanced presentation layer tools/languages similar to HAML, SASS. I definitively want to use JQuery. I will be creating a Facebook app and at some point doing things like dealing with SMS messages, iPhone apps, etc... At this point, the choices for language are PHP (Cake,Symfony,Zend), Python (Django), Ruby (Merb). I'm really between Django and Merb at this point mostly because everybody else seems to be going that way. Please don't put any technologies in here that aren't made for mainstream. I know Merb is untested mostly, but their stated goal is a solid platform and it has alot of momentum behind it so I'm confident that it's workable. Please don't answer with how great Perl is or .Net. For Future References - these choices were already made: Debian (Lenny) - For converting CPU cycles into something useful. Trac 0.11 - For Project Management Gliffy - For wireframes and such Google Docs/Apps - For documentation, hosted email, etc... Amazon ec2/S3 - For hosting, storage. Cheers, Adam
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 growing daily. VB.NET and C# are transportable skill sets, and that can mean a lot when you're building a team of developers to work on a diverse set of tasks. .NET also allows you to separate your presentation layer from your backend code, like other languages, but also allows you to expose that backend code as web service for things like your iPhone and Facebook applications. Take every suggestion with a grain of salt, and pick what suits the application best. Do your research, and design for function and not the zealots. Disclaimer: Once a PHP, ColdFusion and Perl developer. Flex zealot, and Adobe lover. Now writing enterprise .NET applications. ;) Don't forget Mono, which will let you run .NET under *nix. Not that I'm saying it will be perfect, just playing devil's advocate.
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 willing to use beta code and such but by January, I'd like a site that doesn't have 'strange' problems. With that said, if a language is simply 10% slower than another, I don't care about those things as long as the issue is linear. My main concern is developer productivity. I'll be using Linux, Apache, MySQL for the application. I want the power to do things like run scp and ftp client functions with stable libraries (I only picked those two because they're not web-related but at the same time represent pretty common network protocols that any larger app might use). Technologies like OpenID and Oauth will be used as well. Experienced web developers are readily available (i.e. I don't have to find people from financial companies and such). Whatever the choice is is common and will be around for a while. Here's a kicker. I'd like to be able to use advanced presentation layer tools/languages similar to HAML, SASS. I definitively want to use JQuery. I will be creating a Facebook app and at some point doing things like dealing with SMS messages, iPhone apps, etc... At this point, the choices for language are PHP (Cake,Symfony,Zend), Python (Django), Ruby (Merb). I'm really between Django and Merb at this point mostly because everybody else seems to be going that way. Please don't put any technologies in here that aren't made for mainstream. I know Merb is untested mostly, but their stated goal is a solid platform and it has alot of momentum behind it so I'm confident that it's workable. Please don't answer with how great Perl is or .Net. For Future References - these choices were already made: Debian (Lenny) - For converting CPU cycles into something useful. Trac 0.11 - For Project Management Gliffy - For wireframes and such Google Docs/Apps - For documentation, hosted email, etc... Amazon ec2/S3 - For hosting, storage. Cheers, Adam
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 will fork the language and end up slowing momentum for all Python projects while they deal with the fallout. To be fair, Ruby 2.0 is due soon too, but I don't think it will be as disruptive.
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 willing to use beta code and such but by January, I'd like a site that doesn't have 'strange' problems. With that said, if a language is simply 10% slower than another, I don't care about those things as long as the issue is linear. My main concern is developer productivity. I'll be using Linux, Apache, MySQL for the application. I want the power to do things like run scp and ftp client functions with stable libraries (I only picked those two because they're not web-related but at the same time represent pretty common network protocols that any larger app might use). Technologies like OpenID and Oauth will be used as well. Experienced web developers are readily available (i.e. I don't have to find people from financial companies and such). Whatever the choice is is common and will be around for a while. Here's a kicker. I'd like to be able to use advanced presentation layer tools/languages similar to HAML, SASS. I definitively want to use JQuery. I will be creating a Facebook app and at some point doing things like dealing with SMS messages, iPhone apps, etc... At this point, the choices for language are PHP (Cake,Symfony,Zend), Python (Django), Ruby (Merb). I'm really between Django and Merb at this point mostly because everybody else seems to be going that way. Please don't put any technologies in here that aren't made for mainstream. I know Merb is untested mostly, but their stated goal is a solid platform and it has alot of momentum behind it so I'm confident that it's workable. Please don't answer with how great Perl is or .Net. For Future References - these choices were already made: Debian (Lenny) - For converting CPU cycles into something useful. Trac 0.11 - For Project Management Gliffy - For wireframes and such Google Docs/Apps - For documentation, hosted email, etc... Amazon ec2/S3 - For hosting, storage. Cheers, Adam
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 development nowadays, so it's easier to find Ruby developers. I get this impression from browsing recent job advertisements - there aren't that many for Python or Django. I don't know much about Merb, so I can't give a fair comparison. I've done enough PHP to not recommend starting a new project with it.
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 willing to use beta code and such but by January, I'd like a site that doesn't have 'strange' problems. With that said, if a language is simply 10% slower than another, I don't care about those things as long as the issue is linear. My main concern is developer productivity. I'll be using Linux, Apache, MySQL for the application. I want the power to do things like run scp and ftp client functions with stable libraries (I only picked those two because they're not web-related but at the same time represent pretty common network protocols that any larger app might use). Technologies like OpenID and Oauth will be used as well. Experienced web developers are readily available (i.e. I don't have to find people from financial companies and such). Whatever the choice is is common and will be around for a while. Here's a kicker. I'd like to be able to use advanced presentation layer tools/languages similar to HAML, SASS. I definitively want to use JQuery. I will be creating a Facebook app and at some point doing things like dealing with SMS messages, iPhone apps, etc... At this point, the choices for language are PHP (Cake,Symfony,Zend), Python (Django), Ruby (Merb). I'm really between Django and Merb at this point mostly because everybody else seems to be going that way. Please don't put any technologies in here that aren't made for mainstream. I know Merb is untested mostly, but their stated goal is a solid platform and it has alot of momentum behind it so I'm confident that it's workable. Please don't answer with how great Perl is or .Net. For Future References - these choices were already made: Debian (Lenny) - For converting CPU cycles into something useful. Trac 0.11 - For Project Management Gliffy - For wireframes and such Google Docs/Apps - For documentation, hosted email, etc... Amazon ec2/S3 - For hosting, storage. Cheers, Adam
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 whatever you find it's better for your needs (Thin, Mongrel, ebb, etc).
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 willing to use beta code and such but by January, I'd like a site that doesn't have 'strange' problems. With that said, if a language is simply 10% slower than another, I don't care about those things as long as the issue is linear. My main concern is developer productivity. I'll be using Linux, Apache, MySQL for the application. I want the power to do things like run scp and ftp client functions with stable libraries (I only picked those two because they're not web-related but at the same time represent pretty common network protocols that any larger app might use). Technologies like OpenID and Oauth will be used as well. Experienced web developers are readily available (i.e. I don't have to find people from financial companies and such). Whatever the choice is is common and will be around for a while. Here's a kicker. I'd like to be able to use advanced presentation layer tools/languages similar to HAML, SASS. I definitively want to use JQuery. I will be creating a Facebook app and at some point doing things like dealing with SMS messages, iPhone apps, etc... At this point, the choices for language are PHP (Cake,Symfony,Zend), Python (Django), Ruby (Merb). I'm really between Django and Merb at this point mostly because everybody else seems to be going that way. Please don't put any technologies in here that aren't made for mainstream. I know Merb is untested mostly, but their stated goal is a solid platform and it has alot of momentum behind it so I'm confident that it's workable. Please don't answer with how great Perl is or .Net. For Future References - these choices were already made: Debian (Lenny) - For converting CPU cycles into something useful. Trac 0.11 - For Project Management Gliffy - For wireframes and such Google Docs/Apps - For documentation, hosted email, etc... Amazon ec2/S3 - For hosting, storage. Cheers, Adam
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 open files for edit (do a checkout), on the command line, see 'p4 help open'. You can check out files without making a changelist if you add the file to the default changelist, but it's a good idea to make a changelist first. P4Python doesn't currently compile for activepython 2.6 without visual studio 2008; the provided libs are built with 2005 or 2003. Forcing p4python to build against mingw is nearly impossible, even with pexports of python26.dll and reimp/reassembly of the provided .lib files into .a files. In that case, you'll probably rather use subprocess, and return p4 results as marshalled python objects. You can write your own command wrapper that takes an arg array, constructs and runs the commands, and returns the results dictionary. You might try changing everything, testing, and on success, opening the files that are different with something equivalent to 'p4 diff -se //...'
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 (such as DB-API 2.0). The Model classes, like User, use the Database layer to load and save their state. There is no reason for the Database.py class to import all the Model classes, and in fact you wouldn't want that because you'd have to modify Database.py each time you created a new Model class - which is a code smell.
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 Model/Database.py holds Database class needs to import all Model classes to do ORM initialization should be performed on first module import, i.e. no extra init calls or instantiations (all methods on Database class are @classmethods) Model/User.py contains User model class needs access to Database class to do queries should inherit from base class common to all Model classes to share functionality (database persistency methods, parameter validation code etc.) I have yet to see a real world Python app employing MVC, so my approach is probably un-Pythonic (and possibly a language-agnostic mess on top of that...) - any suggestions on how to solve this? Thanks, Simon
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 application; each application imports a common model. Your Database and superclass stuff can be in your __init__.py file, since it applies to the entire package. That may reduce some of the circularity.
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 Model/Database.py holds Database class needs to import all Model classes to do ORM initialization should be performed on first module import, i.e. no extra init calls or instantiations (all methods on Database class are @classmethods) Model/User.py contains User model class needs access to Database class to do queries should inherit from base class common to all Model classes to share functionality (database persistency methods, parameter validation code etc.) I have yet to see a real world Python app employing MVC, so my approach is probably un-Pythonic (and possibly a language-agnostic mess on top of that...) - any suggestions on how to solve this? Thanks, Simon
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 specific model classes but instead provide the functionality the model classes will need to function. The model in turn, should get a database reference (injected or requested) that it would use to query and persist itself.
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 Model/Database.py holds Database class needs to import all Model classes to do ORM initialization should be performed on first module import, i.e. no extra init calls or instantiations (all methods on Database class are @classmethods) Model/User.py contains User model class needs access to Database class to do queries should inherit from base class common to all Model classes to share functionality (database persistency methods, parameter validation code etc.) I have yet to see a real world Python app employing MVC, so my approach is probably un-Pythonic (and possibly a language-agnostic mess on top of that...) - any suggestions on how to solve this? Thanks, Simon
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 error") ] In your code, load it, then eval it, and compile the regexps in the result: f = open("messages.py") messages = eval(f.read()) # caution: you must be sure of what's in that file f.close() messages = [(re.compile(r), m) for (r,m) in messages] and you end up with a list of tuples (compiled_regexp, message).
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 "file not found" category. As the number of patterns and categories is growing, I'd like to put these couples "regular expression/display string" in a configuration file, basically a dictionary serialization of some sort. I would like this file to be editable by hand, so I'm discarding any form of binary serialization, and also I'd rather not resort to xml serialization to avoid problems with characters to escape (& <> and so on...). Do you have any idea of what could be a good way of accomplishing this? Update: thanks to Daren Thomas and Federico Ramponi, but I cannot have an external python file with possibly arbitrary code.
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 syntactic sugar (object creation, container indexing and slicing, attribute access, built-in functions, etc.). Using obj.__len__() wouldn't be the correct way of using the special method, but I don't see why the others were modded down so much.
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 would have to empirically determine a threshold. I'm looking for simplicity rather than perfection. I'm using python.
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 correlation coefficient (4) squaring correlation coefficient to get r-square (i.e fraction of variability in one image explained by variation in the next) (5) generally in my application if r-square < 0.9, I say the two images are different and something happened in between. This is robust and fast in my implementation (Mathematica 7) It's worth playing around with the part of the image you are interested in and focussing on that by cropping all images to that little area, otherwise a distant-from-the-camera but important change will be missed. I don't know how to use Python, but am sure it does correlations, too, no?
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 would have to empirically determine a threshold. I'm looking for simplicity rather than perfection. I'm using python.
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 would have to empirically determine a threshold. I'm looking for simplicity rather than perfection. I'm using python.
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 would have to empirically determine a threshold. I'm looking for simplicity rather than perfection. I'm using python.
How can I quantify difference between two images?
0
0
0
231,920