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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1,388,464 | 2009-09-07T09:36:00.000 | 0 | 0 | 1 | 1 | python,linux | 1,391,295 | 3 | false | 0 | 0 | The best solution will be installing python2.6 in the choosen directory - It will you give you access to many great features and better memory handling (infamous python=2.4 memory leak problem).
I have got several pythons installed onto my two computers, I found that the best solution for are two directories:
$HOME/usr-32
$HOME/usr-64
respectively to using operating system (I share $HOME between 32 and 64 bit versions of Linux).
In each I have one directory for every application/program, for example:
ls ~/usr-64/python-2.6.2/
bin include lib share
It leads completetely to avoiding conflicts between version and gives great portability (you can use usb pendrives etc).
Python 2.6.2 in previously example has been installed with option:
./configure --prefix=$HOME/usr-64/python-2.6.2 | 2 | 2 | 0 | I have a linux VPS that uses an older version of python (2.4.3). This version doesn't include the UUID module, but I need it for a project. My options are to upgrade to python2.6 or find a way to make uuid work with the older version. I am a complete linux newbie. I don't know how to upgrade python safely or how I could get the UUID modules working with the already installed version. What is a better option and how would I go about doing it? | Upgrade python in linux | 0 | 0 | 0 | 25,211 |
1,389,082 | 2009-09-07T12:07:00.000 | 7 | 0 | 0 | 0 | java,javascript,c++,python,ipv6 | 1,390,016 | 11 | true | 1 | 0 | On POSIX systems you can use inet_pton and inet_ntop in combination to do canonicalization. You will still have to do your own CIDR parsing. Fortunately, I believe the only valid CIDR syntax for IPv6 is the /number_of_bits notation, so that's fairly easy.
The other issue you will run into is the lack of support for interface specifications. For link-local addresses, you will see things like %eth0 on the end to specify what link they are local too. getaddrinfo will parse that but inet_pton won't.
One strategy you could go for is using getaddrinfo to parse and inet_ntop to canonicalize.
getaddrinfo is available for Windows. inet_pton and inet_ntop aren't. Fortunately, it isn't too hard to write code to produce a canonical form IPv6 address. It will require two passes though because the rule for 0 compression is the biggest string of 0s that occurs first. Also IPv4 form (i.e. ::127.0.0.1) is only used for ::IPv4 or ::ffff:IPv4.
I have no Windows machine to test with, but from the documentation it appears that Python on Windows supports inet_pton and inet_ntop in its socket module.
Writing your own routine for producing a canonical form might not be a bad idea, since even if your canonical form isn't the same as everybody else's, as long as it's valid other people can parse it. But I would under no circumstances write a routine of your own to parse IPv6 addresses.
My advice above is good for Python, C, and C++. I know little or nothing about how to solve this problem in Java or Javascript.
EDIT: I have been examining getaddrinfo and its counterpart, getnameinfo. These are in almost all ways better than inet_pton and inet_ntop. They are thread safe, and you can pass them options (AI_NUMERICHOST in getaddrinfo's case, and NI_NUMERCHOST in getnameinfo's case) to keep them from doing any kind of DNS queries. Their interface is a little complex and reminds me of an ugly Windows interface in some respects, but it's fairly easy to figure out what options to pass to get what you want. I heartily recommend them both. | 1 | 5 | 0 | What libs have you used for that? How compatible are they with one another? Or did you write your own parsing routine?
I'm particularly interested in mutually-compatible implementations for Java, C++, Python, and JavaScript, which support:
zero compression ("::")
IPv4-mapped addresses ("::ffff:123.45.67.89")
canonicalization (including to the short form, for human readability)
CIDR-style netmasks (like "/64" at the end) | IPv6 address validation and canonicalization | 1.2 | 0 | 0 | 17,450 |
1,389,385 | 2009-09-07T13:14:00.000 | 0 | 0 | 0 | 1 | python,google-app-engine,udp | 17,618,253 | 3 | false | 1 | 0 | You could run a separate agent on a cloud host like DigitalOcean or Amazon EC2 that proxies this protocol and makes itself available to Google App Engine via ordinary HTTP or web sockets. | 1 | 1 | 0 | I have a service provider who is transmitting data thro' UDP. I want to establish a connection to them, receive & process data (will be with in the 30 sec limit/request)
Is it possible to get & process UDP data in appengine. I am looking for some simple example. | How to process UDP data in Appengine | 0 | 0 | 0 | 2,113 |
1,389,738 | 2009-09-07T14:49:00.000 | 3 | 0 | 1 | 0 | python,data-structures,save | 1,389,790 | 7 | false | 0 | 0 | You could do something like:
to write
Pickle
Sign pickled file
Done
to read
Check pickled file's signature
Unpickle
Use
I wonder though what makes you think that the data files are going to be tampered but your application is not going to be? | 4 | 15 | 0 | I am working on a program in Python and want users to be able to save data they are working on. I have looked into cPickle; it seems like it would be a fast and easy way to save data, it seems insecure. Since entire functions, classes, etc can be pickled, I am worried that a rogue save file could inject harmful code into the program. Is there a way I can prevent that, or should I look into other methods of saving data, such as directly converting to a string (which also seems insecure,) or creating an XML hierarchy, and putting data in that.
I am new to python, so please bear with me.
Thanks in advance!
EDIT: As for the type of data I am storing, it is mainly dictionaries and lists. Information such as names, speeds, etc. It is fairly simple right now, but may get more complex in the future. | How to save data with Python? | 0.085505 | 0 | 0 | 18,313 |
1,389,738 | 2009-09-07T14:49:00.000 | 1 | 0 | 1 | 0 | python,data-structures,save | 1,389,757 | 7 | false | 0 | 0 | You need to give us more context before we can answer: what type of data are you saving, how much is there, how do you want to access it?
As for pickles: they do not store code. When you pickle a function or class, it is the name that is stored, not the actual code itself. | 4 | 15 | 0 | I am working on a program in Python and want users to be able to save data they are working on. I have looked into cPickle; it seems like it would be a fast and easy way to save data, it seems insecure. Since entire functions, classes, etc can be pickled, I am worried that a rogue save file could inject harmful code into the program. Is there a way I can prevent that, or should I look into other methods of saving data, such as directly converting to a string (which also seems insecure,) or creating an XML hierarchy, and putting data in that.
I am new to python, so please bear with me.
Thanks in advance!
EDIT: As for the type of data I am storing, it is mainly dictionaries and lists. Information such as names, speeds, etc. It is fairly simple right now, but may get more complex in the future. | How to save data with Python? | 0.028564 | 0 | 0 | 18,313 |
1,389,738 | 2009-09-07T14:49:00.000 | 1 | 0 | 1 | 0 | python,data-structures,save | 1,391,437 | 7 | false | 0 | 0 | Who -- specifically -- is the sociopath who's going through the effort to break a program by hacking the pickled file?
It's Python. The sociopath has your source. They don't need to fool around hacking your pickle file. They can just edit your source and do all the "damage" they want.
Don't worry about "insecurity" unless you're involved in litigation with organized crime syndicates.
Don't worry about "a rogue save file could inject harmful code into the program". No one will bother with a rogue save file when they have the source. | 4 | 15 | 0 | I am working on a program in Python and want users to be able to save data they are working on. I have looked into cPickle; it seems like it would be a fast and easy way to save data, it seems insecure. Since entire functions, classes, etc can be pickled, I am worried that a rogue save file could inject harmful code into the program. Is there a way I can prevent that, or should I look into other methods of saving data, such as directly converting to a string (which also seems insecure,) or creating an XML hierarchy, and putting data in that.
I am new to python, so please bear with me.
Thanks in advance!
EDIT: As for the type of data I am storing, it is mainly dictionaries and lists. Information such as names, speeds, etc. It is fairly simple right now, but may get more complex in the future. | How to save data with Python? | 0.028564 | 0 | 0 | 18,313 |
1,389,738 | 2009-09-07T14:49:00.000 | 1 | 0 | 1 | 0 | python,data-structures,save | 1,389,803 | 7 | false | 0 | 0 | *****In this answer, I'm only concerned about accidental corruption of the application's integrity.*****
Pickle is "secure". What might be insecure is accessing code you didn't write, for example in plugins; that is not relevant to pickles though.
When you pickle an object, all its data is saved, but code and implementation is not. This means when unpickled, an updated object might find it has "old-style" data inside (if you update the implementation). This is something you must know and handle, if applicable.
Pickling strings, lists, numbers, dicts is very easy and works perfectly, and comparably to JSON. The Pickle magic is that -- sometimes without adjustment -- even complex python objects can be pickled. But only data is pickled; the instances are reconstructed simply by the saved module name and type name of the object. | 4 | 15 | 0 | I am working on a program in Python and want users to be able to save data they are working on. I have looked into cPickle; it seems like it would be a fast and easy way to save data, it seems insecure. Since entire functions, classes, etc can be pickled, I am worried that a rogue save file could inject harmful code into the program. Is there a way I can prevent that, or should I look into other methods of saving data, such as directly converting to a string (which also seems insecure,) or creating an XML hierarchy, and putting data in that.
I am new to python, so please bear with me.
Thanks in advance!
EDIT: As for the type of data I am storing, it is mainly dictionaries and lists. Information such as names, speeds, etc. It is fairly simple right now, but may get more complex in the future. | How to save data with Python? | 0.028564 | 0 | 0 | 18,313 |
1,390,868 | 2009-09-07T20:33:00.000 | 2 | 1 | 1 | 0 | python,database,open-source,frameworks | 1,390,896 | 6 | false | 0 | 0 | There are many answers to your question because you raise a number of issues:
Agile development is methodology and has very little to do with the language or software platform. It is more a set of principles around which software teams organize themselves. Refer to the works of Kent Beck for a bit more detail.
Do you have an existing Python code base? If you do have an existing Python code base you could get relatively far with pyHed. Otherwise you could look at something like Java Swing or C#.
But really you might want to consider moving the application to a web platform - that seems to be the direction almost all desktop apps are heading. Django is well known Python framework. Or any number of the Java, C#, Ruby platforms if it strikes your fancy.
The jquery JavaScript framework is a good tool to provide rich Web interfaces. | 1 | 2 | 0 | I have been trying to learn a cross platform language with a fast learning curve, and so it seemed obvious Python was the logical choice. I've never programmed before but I have been reading on pragmatic programming and agile development for quite some time. The question comes, "What is the single best choice to create a desktop software that is built heavily in python and can handle flexibilty of SQL injections, along with rich interface reporting?" e.g. SQL Alchemy, ReportLabs.
I have been looking into pyHed found in sourceforge.net. However, it's on early development stage and is still not well documented. I checked out Titanium Desktop from Appcelerator and the concept seems exciting, but it's not in stable condition yet.
Any suggestions, comments or ideas of what is currently being used? or new technologies out there now? | Agile Software Development in Python | 0.066568 | 0 | 0 | 2,206 |
1,391,608 | 2009-09-08T02:02:00.000 | 5 | 0 | 0 | 1 | python,google-app-engine | 1,392,766 | 3 | true | 1 | 0 | Is it possible? Yes. The protocol appcfg uses to update apps is entirely HTTP-based, so there's absolutely no reason you couldn't write an app that's capable of deploying other apps (or redeploying itself - self-modifying code)! You may even be able to reuse large parts of appcfg.py to do it.
Is it easy? Probably not. It's quite likely you'll need to understand a decent chunk of appcfg's internals, and the RPCs it uses to upload new apps - not a trivial undertaking. You'll also need to store your credentials in the app, in all likelihood - though you can use a role account that is and admin only for the apps it's deploying to minimize risk there. | 3 | 3 | 0 | In order to redeploy a GAE application, I currently have to install the GAE deployment tools on the system that I am using for deployment. While this process is relatively straight forward, the deployment process is a manual process that does not work from behind a firewall and the deployment tools must be installed on every machine that will be used for updating GAE apps. A more ideal solution would be if I could update a GAE application from another GAE application that I have deployed previously. This would remove the need to have multiple systems configured to deploy apps.
Since the GAE deployment tools are written in Python and the GAE App Engine supports Python, is it possible to modify appcfg.py to work from within GAE? The use case would be to pull a project from GitHub or some other online repository and update one GAE application from another GAE app. If this is not possible, what is the limiting constraint? | Is it possible to deploy one GAE application from another GAE application? | 1.2 | 0 | 0 | 418 |
1,391,608 | 2009-09-08T02:02:00.000 | 2 | 0 | 0 | 1 | python,google-app-engine | 1,391,649 | 3 | false | 1 | 0 | One limiting constraint could be the protocol that the python sdk uses to communicate with the GAE servers. If it only uses HTTP, you might be OK. but if it's anything else, you might be out of luck because you can't open a socket directly from within GAE. | 3 | 3 | 0 | In order to redeploy a GAE application, I currently have to install the GAE deployment tools on the system that I am using for deployment. While this process is relatively straight forward, the deployment process is a manual process that does not work from behind a firewall and the deployment tools must be installed on every machine that will be used for updating GAE apps. A more ideal solution would be if I could update a GAE application from another GAE application that I have deployed previously. This would remove the need to have multiple systems configured to deploy apps.
Since the GAE deployment tools are written in Python and the GAE App Engine supports Python, is it possible to modify appcfg.py to work from within GAE? The use case would be to pull a project from GitHub or some other online repository and update one GAE application from another GAE app. If this is not possible, what is the limiting constraint? | Is it possible to deploy one GAE application from another GAE application? | 0.132549 | 0 | 0 | 418 |
1,391,608 | 2009-09-08T02:02:00.000 | 0 | 0 | 0 | 1 | python,google-app-engine | 1,391,652 | 3 | false | 1 | 0 | What problem did you have by trying to update behind a firewall?
I've got some, but finally I manage to work around them.
About your question, the constraint is that you cannot write files into a GAE app, so even though you could possibly pull from the VCS you can't write those pulled files.
So you would have to update from outside the GAE in first place.
Anyway every machine that needs to update the GAE should have the SDK anyway just to see if they changes work.
So, If you really want to do this you have two alternatives:
Host your own "updater" site and istall the SDK there, then when you want to update log into your side ( or run a script ) and do the remote update.
Although I don't know Amazon EC2 well, I think you can do pretty much the same thing as op 1 from there.
Finally I think the password to update has to be typed always. ( you could have the SDK of the App engine and modify that, because it is open source ) | 3 | 3 | 0 | In order to redeploy a GAE application, I currently have to install the GAE deployment tools on the system that I am using for deployment. While this process is relatively straight forward, the deployment process is a manual process that does not work from behind a firewall and the deployment tools must be installed on every machine that will be used for updating GAE apps. A more ideal solution would be if I could update a GAE application from another GAE application that I have deployed previously. This would remove the need to have multiple systems configured to deploy apps.
Since the GAE deployment tools are written in Python and the GAE App Engine supports Python, is it possible to modify appcfg.py to work from within GAE? The use case would be to pull a project from GitHub or some other online repository and update one GAE application from another GAE app. If this is not possible, what is the limiting constraint? | Is it possible to deploy one GAE application from another GAE application? | 0 | 0 | 0 | 418 |
1,393,075 | 2009-09-08T09:58:00.000 | 8 | 0 | 1 | 0 | python,vim,syntax-highlighting,vim-syntax-highlighting | 1,410,674 | 6 | true | 0 | 0 | I had below statement in my vimrc file. This made else: be tokenized as one word. After removing that else: syntax highlighting works just fine.
set iskeyword+=: | 1 | 8 | 0 | I'm getting annoyed with the default python syntax highlighting in Vim.
It does not highlight the else: statement correctly.
Vim only highlights the else statement if I have some white space between the else and the colon :, so else : works, but else: does not.
It must be easy to fix.
I'm using Vim 7.2 | Vim syntax highlighting 'else:' for Python | 1.2 | 0 | 0 | 3,440 |
1,393,731 | 2009-09-08T12:28:00.000 | 0 | 0 | 1 | 0 | python,configuration,naming-conventions | 1,393,752 | 5 | false | 0 | 0 | I don't think there's any convention for this. You may just use file with extension like: .ini, .cfg, .conf, .config, .pref or anything you like. | 4 | 4 | 0 | Is there a general naming conventions for configuration files for a simple python program?
Thanks,
Udi | configuration filename convention | 0 | 0 | 0 | 1,765 |
1,393,731 | 2009-09-08T12:28:00.000 | 4 | 0 | 1 | 0 | python,configuration,naming-conventions | 1,393,754 | 5 | true | 0 | 0 | .conf is a nice extension too. But since mostly configuration files are application specific, it does not really matter what extension they have as long as they are consistent (i.e do not use .conf with .cfg in the same application). | 4 | 4 | 0 | Is there a general naming conventions for configuration files for a simple python program?
Thanks,
Udi | configuration filename convention | 1.2 | 0 | 0 | 1,765 |
1,393,731 | 2009-09-08T12:28:00.000 | 1 | 0 | 1 | 0 | python,configuration,naming-conventions | 1,394,828 | 5 | false | 0 | 0 | Django uses settings.py I like that a lot. It's very clear. | 4 | 4 | 0 | Is there a general naming conventions for configuration files for a simple python program?
Thanks,
Udi | configuration filename convention | 0.039979 | 0 | 0 | 1,765 |
1,393,731 | 2009-09-08T12:28:00.000 | 4 | 0 | 1 | 0 | python,configuration,naming-conventions | 1,393,736 | 5 | false | 0 | 0 | A convention? Mine would be, if my program was called "Bob", simply "bob.cfg".
I have to admit, I didn't really suffer any angst in coming up with that convention. Maybe I've been here too long :-)
Of course, if your configuration information is of a specific format (e.g., XML), you could consider "bob.xml". But, really, I think ".cfg" just about sums up the intent as much as any convention could.
And, just to state the bleeding obvious, don't call your file "bob.cfg" if your program is actually called "George".
Please don't take offense, I'm not really taking the mickey, just answering an interesting question in the tone of my strange sense of humor. You wouldn't be the first to misunderstand my brand of humor (my wife, for instance, despairs of it most days). | 4 | 4 | 0 | Is there a general naming conventions for configuration files for a simple python program?
Thanks,
Udi | configuration filename convention | 0.158649 | 0 | 0 | 1,765 |
1,395,356 | 2009-09-08T17:53:00.000 | 1 | 0 | 1 | 0 | python | 44,833,943 | 7 | false | 0 | 0 | python 2.7
print "{0:b}".format(30)
python 3.x
print ('{0:b}'.format(30)) | 1 | 48 | 0 | What does the "b" stand for in the output of bin(30): "0b11110"? Is there any way I can get rid of this "b"? How can I get the output of bin() to always return a standard 8 digit output? | How can I make `bin(30)` return `00011110` instead of `0b11110`? | 0.028564 | 0 | 0 | 72,777 |
1,396,668 | 2009-09-08T22:26:00.000 | 36 | 0 | 1 | 0 | python | 1,396,696 | 7 | false | 0 | 0 | Short answer, you can't.
Long answer, you can maintain a dict for mapping IDs to objects, or look the ID up by exhaustive search of gc.get_objects(), but this will create one of two problems: either the dict's reference will keep the object alive and prevent GC, or (if it's a WeakValue dict or you use gc.get_objects()) the ID may be deallocated and reused for a completely different object.
Basically, if you're trying to do this, you probably need to do something differently. | 1 | 148 | 0 | Let's say I have an id of a Python object, which I retrieved by doing id(thing). How do I find thing again by the id number I was given? | Get object by id()? | 1 | 0 | 0 | 93,777 |
1,397,553 | 2009-09-09T04:40:00.000 | 1 | 0 | 0 | 0 | python,user-interface,qt | 1,414,819 | 2 | false | 0 | 1 | I contacted maintainer of VPython and he confirmed, that he is not aware of any working solution where Visual is embedded into QT window.
That turned me to try VTK and so far I'm pretty happy, no problem with using VTK within PyQT framework. | 1 | 2 | 0 | How do you embed a vpython plot (animated) within your Qt GUI? so that it has its own display area and would not need to created a new window anymore. | embedding plot within Qt gui | 0.099668 | 0 | 0 | 1,265 |
1,397,572 | 2009-09-09T04:47:00.000 | 2 | 0 | 1 | 0 | python,open-source | 1,397,650 | 8 | false | 0 | 0 | I have had to do a lot of this in my job. What works for me may be different to what works for you, but I'll share my experience.
I start by trying to identify the data structures being used and draw diagrams showing the relationships between them. Not necessarily something formal like UML, but a sketch on paper which you understand which allows you to see the overall structure of the data being manipulated by the program. Only once I have some view of the data structures being used do I start to try to understand how the data is being manipulated.
Secondly, for a large body of software, sometimes you need to just attack bite sized pieces at first. You won't get an overall understanding straight away, but if you understand small parts in detail and keep chipping away, eventually all the pieces fall together.
I combine these two approaches, switching between them when I am getting overly frustrated or bored. Regular walks around the block are recommended :) I find this gets me good results in the end.
Good luck! | 3 | 7 | 0 | I have a source of python program which doesn't have any documentation or comments.
I did tried twice to understand it but most of the times I am losing my track, because there are many files.
What should be the steps to understand that program fully and quickly. | How to reverse engineer a program which has no documentation | 0.049958 | 0 | 0 | 9,658 |
1,397,572 | 2009-09-09T04:47:00.000 | 1 | 0 | 1 | 0 | python,open-source | 6,623,248 | 8 | false | 0 | 0 | pyreverse from Logilab and PyNSource from Andy Bulka are helpful too for UML diagram generation. | 3 | 7 | 0 | I have a source of python program which doesn't have any documentation or comments.
I did tried twice to understand it but most of the times I am losing my track, because there are many files.
What should be the steps to understand that program fully and quickly. | How to reverse engineer a program which has no documentation | 0.024995 | 0 | 0 | 9,658 |
1,397,572 | 2009-09-09T04:47:00.000 | 3 | 0 | 1 | 0 | python,open-source | 1,397,654 | 8 | false | 0 | 0 | You are lucky it's in Python which is easy to read. But it is of course possible to write tricky hard to understand code in Python as well.
The steps are:
Run the software and learn to use it, and understand it's features at least a little bit.
Read though the tests, if any.
Read through the code.
When you encounter code you don't understand, put a debug break there, and step through the code, looking at what it does.
If there aren't any tests, or the test coverage is low, write tests to increase the test coverage. It's a good way to learn the system.
Repeat until you feel you have a vague grip on the code. A vague grip is all you need if you are going to manage the code. You'll get a good grip once you start actually working with the code. For a big system that can take years, so don't try to understand it all first.
There are tools that can help you. As Stephen C says, an IDE is a good idea. I'll explain why:
Many editors analyses the code. This typically gives you code completion, but more importantly in this case, it makes it possible to just just ctrl-click on a variable to see where it comes from. This really speeds things up when you want to understand otehr peoples code.
Also, you need to learn a debugger. You will, in tricky parts of the code, have to step through them in a debugger to see what the code actually do. Pythons pdb works, but many IDE's have integrated debuggers, which make debugging easier.
That's it. Good luck. | 3 | 7 | 0 | I have a source of python program which doesn't have any documentation or comments.
I did tried twice to understand it but most of the times I am losing my track, because there are many files.
What should be the steps to understand that program fully and quickly. | How to reverse engineer a program which has no documentation | 0.07486 | 0 | 0 | 9,658 |
1,397,977 | 2009-09-09T07:04:00.000 | 2 | 0 | 1 | 0 | python,thread-safety,cython,pyrex | 1,399,771 | 2 | false | 0 | 0 | Python's global interpreter lock means that only one thread can be active in the interpreter at any one time. However, once control is passed out to a C extension another thread can be active within the interpreter. Multiple threads can be created, and nothing prevents a thread from being interrupted within the middle of a critical section. N
on thread-safe code can be implemented within the interpreter, so nothing about code running within the interpreter is inherently thread safe. Code in C or Pyrex modules can still modify data structures that are visible to python code. Native code can, of course, also have threading issues with native data structures.
You can't guarantee thread safety beyond using appropriate design and synchronisation - the GIL on the python interpreter doesn't materially change this. | 1 | 4 | 0 | If not, is there a way I can guarantee thread safety by programming a certain way?
To clarify, when talking about "threadsafe,' I mean Python threads, not OS-level threads. | Are Python extensions produced by Cython/Pyrex threadsafe? | 0.197375 | 0 | 0 | 1,771 |
1,399,717 | 2009-09-09T13:33:00.000 | 1 | 0 | 1 | 0 | python | 1,399,804 | 2 | false | 0 | 0 | I think you answered the question yourself. You need to subclass a dict. And you also of course needs to have a list of the keys, so when the list gets too long you can purge the oldest one.
I would however possibly look into memcached or similar. | 1 | 1 | 0 | I'm searching for the a datatype for a cache, basically I need the functionality of a dict, i.e. random access based on a key, which has a limited number of entries so that when the limit is reached the oldest item gets automatically removed.
Furthermore I need to be able to store it via shelve or pickle and rely on Python 2.4.
Should I subclass dict and add a list to it? Any suggestions?
Edit:
I have not mentioned the scale, I need to keep track of already read items which consist of a signature by which they are identified and I only want to keep track of about a few hundred of them.
collections.deque seem nice but that's a list and I need random access. So dict would seem suitable, however somehow I need to expire items if the limit is hit which means I need to keep track the order in which they have been added. | Python datatype suitable for my cache | 0.099668 | 0 | 0 | 166 |
1,399,746 | 2009-09-09T13:40:00.000 | 7 | 0 | 0 | 0 | python,django,monkeypatching | 1,399,813 | 5 | true | 1 | 0 | When you add a field to any model, even if you do it the 'official' way, you need to migrate the database - Django doesn't do it for you. Drop the table and run ./manage.py syncdb again.
You might want to investigate one of the migrations frameworks, such as south, which will manage this sort of thing for you. | 1 | 4 | 0 | I have recently started experimenting with Django for some web applications in my spare time. While designing the data model for one, I came across the dilemma of using inheritance to define a user of the website or using a technique known as monkey patching with the User class already supplied by the framework.
I tried to add a field by means of (after having defined all my models etc. without errors, according to python manage.py validate):
User.add_to_class('location', models.CharField(max_length=250,blank=True))
and executed the syncdb command. However, I keep getting this error
OperationalError: no such column:
auth_user.location
whether I am in the admin view of the site or the manage.py shell. There must be an extra step I'm missing, but there seems to be limited documentation on the whole monkey patching technique. So I'm asking you for assistance before I resort to inheritance. Any code, tips, or pointers to additional documentation are of course welcome.
Thanks in advance.
PS. I'm aware this technique is ugly, and probably ill-advised. ;) | Django and monkey patching issue | 1.2 | 0 | 0 | 1,938 |
1,400,012 | 2009-09-09T14:20:00.000 | 2 | 0 | 1 | 0 | python,integer,endianness | 1,400,075 | 4 | false | 0 | 0 | Check when?
When doing bitwise operations, the int in will have the same endianess as the ints you put in. You don't need to check that. You only need to care about this when converting to/from sequences of bytes, in both languages, afaik.
In Python you use the struct module for this, most commonly struct.pack() and struct.unpack(). | 1 | 21 | 0 | I'm working on a program where I store some data in an integer and process it bitwise. For example, I might receive the number 48, which I will process bit-by-bit. In general the endianness of integers depends on the machine representation of integers, but does Python do anything to guarantee that the ints will always be little-endian? Or do I need to check endianness like I would in C and then write separate code for the two cases?
I ask because my code runs on a Sun machine and, although the one it's running on now uses Intel processors, I might have to switch to a machine with Sun processors in the future, which I know is big-endian. | Endianness of integers in Python | 0.099668 | 0 | 0 | 41,057 |
1,400,179 | 2009-09-09T14:45:00.000 | 0 | 0 | 0 | 0 | python,wxpython | 1,579,014 | 4 | false | 1 | 1 | Usually, click events are trigged by MouseUp events. If you track the mouse position by capturing any MouseDown events, you will know where the last click (MouseUp) happened, and that should allow you to reconstruct things.
For this particular problem, you might have to do a bit more work in MouseDown like checking if they are within the wxHtmlWindow control and if so, then saving something like a line number. | 1 | 2 | 0 | I am using a wxPython wx.html.HtmlWindow to display part of my interface. The user can scroll down a list of links in a window smaller than the list. When they click on a link, I need to repaint the web page, but I want to return the page position back to where they clicked it.
I've tried MouseEvent.GetLogicalPosition() on the event, but it wants a DC and the best I've been able to do is get the same information as GetPosition(), so I must not be feeding it the right one.
I also tried HtmlWindow.CalcScrolledPosition(), but apparently that isn't available in HtmlWindow because I get a NotImplementedError...
What I would like is a scroll position that can be derived from the MouseEvent, or the OnLinkClicked information.
I know about HtmlWindow.ScrollToAnchor(), but it's flaky and unaesthetic -- I would prefer to bypass it if possible so that I can scroll back exactly to where the user clicked.
Thanks! | How do I scroll a wxPython wx.html.HtmlWindow back down to where it was when the user clicked a link? | 0 | 0 | 0 | 1,216 |
1,400,295 | 2009-09-09T15:05:00.000 | 0 | 0 | 1 | 0 | python,persistence,pickle | 1,401,887 | 3 | false | 0 | 0 | you could use simply a dictionnary with the key and the values the same in the receiver. And to avoid a memory leak use a WeakKeyDictionary. | 1 | 5 | 0 | I'm trying to write a class for a read-only object which will not be really copied with the copy module, and when it will be pickled to be transferred between processes each process will maintain no more than one copy of it, no matter how many times it will be passed around as a "new" object. Is there already something like that? | Class for pickle- and copy-persistent object? | 0 | 0 | 0 | 3,512 |
1,401,102 | 2009-09-09T17:57:00.000 | 0 | 0 | 1 | 0 | python,matplotlib,figures | 14,591,411 | 3 | false | 0 | 0 | The best way to show multiple figures is use matplotlib or pylab. (for windows)
with matplotlib you can prepare the figures and then when you finish the process with them you can show with the comand "matplotlib.show()" and all figures should be shown.
(on linux) you don´t have problems adding changes to figures because the interactive mode is enable (on windows the interactive mode don't work OK). | 1 | 32 | 1 | I have functions that contribute to small parts of a figure generation. I'm trying to use these functions to generate multiple figures? So something like this:
work with Figure 1
do something else
work with Figure 2
do something else
work with Figure 1
do something else
work with Figure 2
If anyone could help, that'd be great! | Python with matplotlib - drawing multiple figures in parallel | 0 | 0 | 0 | 43,360 |
1,401,218 | 2009-09-09T18:16:00.000 | 7 | 1 | 0 | 0 | c#,python,url,crc32,short-url | 1,401,231 | 6 | true | 0 | 0 | There is no such number as the "maximum number of urls can be used so that we can avoid duplicates" for CRC32.
The problem is that CRC32 can produce duplicates, and it's not a function of how many values you throw at it, it's a function of what those values look like.
So you might have a collision on the second url, if you're unlucky.
You should not base your algorithm on producing a unique hash, instead produce a unique value for each url manually. | 5 | 5 | 0 | I am trying to understand crc32 to generate the unique url for web page.
If we use the crc32, what is the maximum number of urls can be used so that we can avoid duplicates?
What could be the approximative string length to keep the checksum to be 2^32?
When I tried UUID for an url and convert the uuid bytes to base 64, I could reduce to 22 chars long. I wonder I can reduce still further.
Mostly I want to convert the url (maximum 1024 chars) to shorted id. | CRC32 to make short URL for web | 1.2 | 0 | 1 | 3,162 |
1,401,218 | 2009-09-09T18:16:00.000 | 4 | 1 | 0 | 0 | c#,python,url,crc32,short-url | 1,401,237 | 6 | false | 0 | 0 | If you're already storing the full URL in a database table, an integer ID is pretty short, and can be made shorter by converting it to base 16, 64, or 85. If you can use a UUID, you can use an integer, and you may as well, since it's shorter and I don't see what benefit a UUID would provide in your lookup table. | 5 | 5 | 0 | I am trying to understand crc32 to generate the unique url for web page.
If we use the crc32, what is the maximum number of urls can be used so that we can avoid duplicates?
What could be the approximative string length to keep the checksum to be 2^32?
When I tried UUID for an url and convert the uuid bytes to base 64, I could reduce to 22 chars long. I wonder I can reduce still further.
Mostly I want to convert the url (maximum 1024 chars) to shorted id. | CRC32 to make short URL for web | 0.132549 | 0 | 1 | 3,162 |
1,401,218 | 2009-09-09T18:16:00.000 | 1 | 1 | 0 | 0 | c#,python,url,crc32,short-url | 1,401,243 | 6 | false | 0 | 0 | CRC32 means cyclic redundancy check with 32 bits where any arbitrary amount of bits is summed up to a 32 bit check sum. And check sum functions are surjective, that means multiple input values have the same output value. So you cannot inverse the function. | 5 | 5 | 0 | I am trying to understand crc32 to generate the unique url for web page.
If we use the crc32, what is the maximum number of urls can be used so that we can avoid duplicates?
What could be the approximative string length to keep the checksum to be 2^32?
When I tried UUID for an url and convert the uuid bytes to base 64, I could reduce to 22 chars long. I wonder I can reduce still further.
Mostly I want to convert the url (maximum 1024 chars) to shorted id. | CRC32 to make short URL for web | 0.033321 | 0 | 1 | 3,162 |
1,401,218 | 2009-09-09T18:16:00.000 | 0 | 1 | 0 | 0 | c#,python,url,crc32,short-url | 1,401,286 | 6 | false | 0 | 0 | No, even you use md5, or any other check sum, the URL CAN BE duplicate, it all depends on your luck.
So don't make an unique url base on those check sum | 5 | 5 | 0 | I am trying to understand crc32 to generate the unique url for web page.
If we use the crc32, what is the maximum number of urls can be used so that we can avoid duplicates?
What could be the approximative string length to keep the checksum to be 2^32?
When I tried UUID for an url and convert the uuid bytes to base 64, I could reduce to 22 chars long. I wonder I can reduce still further.
Mostly I want to convert the url (maximum 1024 chars) to shorted id. | CRC32 to make short URL for web | 0 | 0 | 1 | 3,162 |
1,401,218 | 2009-09-09T18:16:00.000 | 2 | 1 | 0 | 0 | c#,python,url,crc32,short-url | 1,401,331 | 6 | false | 0 | 0 | The right way to make a short URL is to store the full one in the database and publish something that maps to the row index. A compact way is to use the Base64 of the row ID, for example. Or you could use a UID for the primary key and show that.
Do not use a checksum, because it's too small and very likely to conflict. A cryptographic hash is larger and less likely, but it's still not the right way to go. | 5 | 5 | 0 | I am trying to understand crc32 to generate the unique url for web page.
If we use the crc32, what is the maximum number of urls can be used so that we can avoid duplicates?
What could be the approximative string length to keep the checksum to be 2^32?
When I tried UUID for an url and convert the uuid bytes to base 64, I could reduce to 22 chars long. I wonder I can reduce still further.
Mostly I want to convert the url (maximum 1024 chars) to shorted id. | CRC32 to make short URL for web | 0.066568 | 0 | 1 | 3,162 |
1,401,527 | 2009-09-09T19:15:00.000 | 3 | 1 | 0 | 0 | php,python,image | 1,401,566 | 5 | false | 0 | 0 | If your exact requirements are that it show correctly in FireFox you may have a difficult time - the only way to be sure would be to link to the exact same image loading source code as FireFox.
Basic image corruption (file is incomplete) can be detected simply by trying to open the file using any number of image libraries.
However many images can fail to display simply because they stretch a part of the file format that the particular viewer you are using can't handle (GIF in particular has a lot of these edge cases, but you can find JPEG and the rare PNG file that can only be displayed in specific viewers). There are also some ugly JPEG edge cases where the file appears to be uncorrupted in viewer X, but in reality the file has been cut short and is only displaying correctly because very little information has been lost (FireFox can show some cut off JPEGs correctly [you get a grey bottom], but others result in FireFox seeming the load them half way and then display the error message instead of the partial image) | 1 | 20 | 0 | Okay. So I have about 250,000 high resolution images. What I want to do is go through all of them and find ones that are corrupted. If you know what 4scrape is, then you know the nature of the images I.
Corrupted, to me, is the image is loaded into Firefox and it says
The image “such and such image” cannot be displayed, because it contains errors.
Now, I could select all of my 250,000 images (~150gb) and drag-n-drop them into Firefox. That would be bad though, because I don't think Mozilla designed Firefox to open 250,000 tabs. No, I need a way to programmatically check whether an image is corrupted.
Does anyone know a PHP or Python library which can do something along these lines? Or an existing piece of software for Windows?
I have already removed obviously corrupted images (such as ones that are 0 bytes) but I'm about 99.9% sure that there are more diseased images floating around in my throng of a collection. | How do I programmatically check whether an image (PNG, JPEG, or GIF) is corrupted? | 0.119427 | 0 | 1 | 23,397 |
1,403,103 | 2009-09-10T02:30:00.000 | 18 | 0 | 0 | 0 | python,excel,vba,ironpython,python.net | 1,403,134 | 5 | false | 0 | 1 | 1) IronPython and CPython share nearly identical language syntax. There is very little difference between them. Transitioning should be trivial.
2) The libraries in IronPython are very different than CPython. The Python libraries are a fair bit behind - quite a few of the CPython-accessible libraries will not work (currently) under IronPython. However, IronPython has clean, direct access to the entire .NET Framework, which means that it has one of the most extensive libraries natively accessible to it, so in many ways, it's far ahead of CPython. Some of the numpy/scipy libraries do not work in IronPython, but due to the .NET implementation, some of the functionality is not necessary, since the perf. characteristics are different.
3) Accessing Excel VBA is going to be easier using IronPython, if you're doing it from VBA. If you're trying to automate excel, IronPython is still easier, since you have access to the Execl Primary Interop Assemblies, and can directly automate it using the same libraries as C# and VB.NET. | 2 | 15 | 0 | I'm starting to study Python, and for now I like it very much. But, if you could just answer a few questions for me, which have been troubling me, and I can't find any definite answers to them:
What is the relationship between Python's C implementation (main version from python.org) and IronPython, in terms of language compatibility ? Is it the same language, and do I by learning one, will be able to smoothly cross to another, or is it Java to JavaScript ?
What is the current status to IronPython's libraries ? How much does it lags behind CPython libraries ? I'm mostly interested in numpy/scipy and f2py. Are they available to IronPython ?
What would be the best way to access VB from Python and the other way back (connecting some python libraries to Excel's VBA, to be exact) ? | Python - IronPython dilemma | 1 | 0 | 0 | 3,658 |
1,403,103 | 2009-09-10T02:30:00.000 | 1 | 0 | 0 | 0 | python,excel,vba,ironpython,python.net | 1,403,118 | 5 | false | 0 | 1 | 1) The language implemented by CPython and IronPython are the same, or at most a version or two apart. This is nothing like the situation with Java and Javascript, which are two completely different languages given similar names by some bone-headed marketing decision.
2) 3rd-party libraries implemented in C (such as numpy) will have to be evaluated carefully. IronPython has a facility to execute C extensions (I forget the name), but there are many pitfalls, so you need to check with each library's maintainer
3) I have no idea. | 2 | 15 | 0 | I'm starting to study Python, and for now I like it very much. But, if you could just answer a few questions for me, which have been troubling me, and I can't find any definite answers to them:
What is the relationship between Python's C implementation (main version from python.org) and IronPython, in terms of language compatibility ? Is it the same language, and do I by learning one, will be able to smoothly cross to another, or is it Java to JavaScript ?
What is the current status to IronPython's libraries ? How much does it lags behind CPython libraries ? I'm mostly interested in numpy/scipy and f2py. Are they available to IronPython ?
What would be the best way to access VB from Python and the other way back (connecting some python libraries to Excel's VBA, to be exact) ? | Python - IronPython dilemma | 0.039979 | 0 | 0 | 3,658 |
1,403,674 | 2009-09-10T06:32:00.000 | 69 | 0 | 1 | 0 | list,python | 1,404,229 | 9 | false | 0 | 0 | source_list[::10] is the most obvious, but this doesn't work for any iterable and is not memory efficient for large lists.
itertools.islice(source_sequence, 0, None, 10) works for any iterable and is memory-efficient, but probably is not the fastest solution for large list and big step.
(source_list[i] for i in xrange(0, len(source_list), 10)) | 1 | 210 | 0 | Say we have a list of numbers from 0 to 1000. Is there a pythonic/efficient way to produce a list of the first and every subsequent 10th item, i.e. [0, 10, 20, 30, ... ]?
Yes, I can do this using a for loop, but I'm wondering if there is a neater way to do this, perhaps even in one line? | Pythonic way to return list of every nth item in a larger list | 1 | 0 | 0 | 278,755 |
1,404,515 | 2009-09-10T10:34:00.000 | 25 | 0 | 1 | 0 | python,perl,editor,vim | 1,404,570 | 4 | false | 0 | 0 | In your $HOME, make .vim/ directory (or vimfiles/ on Windows), in it make ftplugin/ directory, and in it keep files named "perl.vim" or "python.vim" or "html.vim" or ...
These should be loaded automatically when you open/create new file of given filetype as long as you don't forget to add :filetype plugin on in your .vimrc (or _vimrc under windows)
Then, vim options should be defined with :setlocal (and not :set, otherwise their definition will override the default global setting).
Mappings are defined with :n/i/v(nore)map <buffer>, as well as the abbreviations. Commands are defined with the -b option. Menus can't be made local without the help of a plugin.
local, <buffer>, and -b are important to prevent side effects. | 1 | 15 | 0 | My day job involves coding with Perl. At home I play around with Python and Erlang. For Perl I want to indent my code with two spaces. Whereas for Python the standard is 4. Also I have some key bindings to open function declarations which I would like to use with all programming languages. How can this be achieved in gVim?
As in, is there a way to maintain a configuration file for each programming language or something of that sort? | gVim and multiple programming languages | 1 | 0 | 0 | 3,389 |
1,406,213 | 2009-09-10T16:07:00.000 | 3 | 0 | 0 | 0 | python,emacs,pyflakes | 1,408,670 | 3 | true | 0 | 0 | latest pyflakes in development mode fixed this problem for me. Thanks all
sudo easy_install -U pyflakes | 1 | 0 | 0 | My Emacs hangs (Ubuntu 9 + Emacs 23 + Pyflakes) when I type """ quotes for string blocks.
Anybody experienced the same problem? I think, it may not be an Emacs problem but some Python mode or Pyflakes which I use it for error checking.
Anybody got around the issue? It is a really frustrating experience. | Emacs 23 hangs on python mode when typing string block """ | 1.2 | 0 | 0 | 846 |
1,406,636 | 2009-09-10T17:32:00.000 | 3 | 0 | 0 | 1 | python,google-app-engine | 1,406,768 | 2 | false | 1 | 0 | The ways to reliable keep state between requests are memcache, the datastore or through the user (cookies or post/get).
You can use the runtime cache too, but this is very unreliable as you don't know if a request will end up in the same runtime or the runtime can drop it's entire cache if it feels like it.
I really wouldn't use the runtime cache except for very specific situations, for example I use it to cache the serialization of objects to json as that is pretty slow and if the caching is gone I can regenerate the result easily. | 1 | 1 | 0 | I'm writing a simple app with AppEngine, using Python. After a successful insert by a user and redirect, I'd like to display a flash confirmation message on the next page.
What's the best way to keep state between one request and the next? Or is this not possible because AppEngine is distributed? I guess, the underlying question is whether AppEngine provides a persistent session object.
Thanks
Hannes | How do I keep state between requests in AppEngine (Python)? | 0.291313 | 0 | 0 | 564 |
1,407,016 | 2009-09-10T18:45:00.000 | 0 | 0 | 0 | 0 | python,database,desktop,crud | 1,407,116 | 3 | false | 0 | 0 | If it were me, I would consider borrowing django's ORM, but then again, I'm already familiar with it.
Having said that, I like working with it, it's usable outside the framework, and it will give you mysql, postgres, or sqlite support. You could also hook up the django admin site to your models and have a web-based editor.
There are surely other ORMs and code generators out there too (I hope some python gurus will point some out, I'm kind of curious). | 1 | 2 | 0 | I want to develop a desktop application using python with basic crud operation. Is there any library in python that can generate a code for CRUD functionality and user interface given a database table. | How to generate basic CRUD functionality in python given a database tables | 0 | 0 | 0 | 6,272 |
1,407,248 | 2009-09-10T19:31:00.000 | 0 | 0 | 0 | 0 | python,database,sqlite,ado | 1,407,345 | 9 | false | 0 | 0 | Django is perfect for this but the poster is not clear if he needs to actually make a compiled EXE or a web app. Django is only for web apps.
I'm not sure where you really get "heavy" from. Django is grossly smaller in terms of lines of code than any other major web app framework. | 1 | 7 | 0 | What is the best way to use an embedded database, say sqlite in Python:
Should be small footprint. I'm only needing few thousands records per table. And just a handful of tables per database.
If it's one provided by Python default installation, then great. Must be open-source, available on Windows and Linus.
Better if SQL is not written directly, but no ORM is fully needed. Something that will shield me from the actual database, but not that huge of a library. Something similar to ADO will be great.
Mostly will be used through code, but if there is a GUI front end, then that is great
Need just a few pages to get started with. I don't want to go through pages reading what a table is and how a Select statement works. I know all of that.
Support for Python 3 is preferred, but 2.x is okay too.
The usage is not a web app. It's a small database to hold at most 5 tables. The data in each table is just a few string columns. Think something just larger than a pickled dictionary
Update: Many thanks for the great suggestions.
The use-case I'm talking about is fairly simple. One you'd probably do in a day or two.
It's a 100ish line Python script that gathers data about a relatively large number of files (say 10k), and creates metadata files about them, and then one large metadata file about the whole files tree. I just need to avoid re-processing the files already processed, and create the metadata for the updated files, and update the main metadata file. In a way, cache the processed data, and only update it on file updates.
If the cache is corrupt / unavailable, then simply process the whole tree. It might take 20 minutes, but that's okay.
Note that all processing is done in-memory.
I would like to avoid any external dependencies, so that the script can easily be put on any system with just a Python installation on it. Being Windows, it is sometimes hard to get all the components installed.
So, In my opinion, even a database might be an overkill.
You probably wouldn't fire up an Office Word/Writer to write a small post it type note, similarly I am reluctant on using something like Django for this use-case.
Where to start? | python database / sql programming - where to start | 0 | 1 | 0 | 5,927 |
1,407,364 | 2009-09-10T19:52:00.000 | 5 | 1 | 1 | 0 | python,gettext | 1,408,109 | 3 | false | 0 | 0 | Reading just quickly about .mo files, it is clear that:
It is a machine-readable representation
It is a hash table
Given gettext's function, to lookup strings by keys at runtime, it is reasonable for this lookup to be implemented efficiently.
Also, it is needed for gettext's performance impact to be negligible; else interest to play nice with the international community would be even lower for english-speaking hackers (from all countries, we all speak english, programming languages are in english).
Making the .mo file an already processed representation is good since
The format is well suited for quick lookup (hash table)
The format needs little processing at application launch (custom-representation binary) | 2 | 0 | 0 | I don't see that the compilation step is adding any value. | Why does the Python gettext module require a compilation step (.po -> .mo)? | 0.321513 | 0 | 0 | 626 |
1,407,364 | 2009-09-10T19:52:00.000 | 1 | 1 | 1 | 0 | python,gettext | 2,021,653 | 3 | false | 0 | 0 | Because gettext module in Python follows GNU gettext standards which required to use PO files for do translations by people, and MO files for using by application in runtime. When you're using gettext module you're actually using GNUTranslations class, which name suggests it's implementation of GNU gettext.
But you can provide your own Translations class and load translations from PO files, there is nothing special about it. There is even some implementation of PO files reader in standard Python distribution, see script msgfmt.py in Tools directory. | 2 | 0 | 0 | I don't see that the compilation step is adding any value. | Why does the Python gettext module require a compilation step (.po -> .mo)? | 0.066568 | 0 | 0 | 626 |
1,407,474 | 2009-09-10T20:14:00.000 | 0 | 0 | 0 | 1 | python,logging,python-logging | 67,012,969 | 8 | false | 0 | 0 | I think what described here is an anti-pattern - different processes should not write data into the same file.
And non of the solutions above worked for me, causing different permissions issues in different scenarios.
As a temp workaround I've added a random suffix into the log filename so each process will get a unique filename on a startup.
The proper way to solve this issue - have a centralized log handler (log server), e.g. rsyslog. | 1 | 38 | 0 | I'm using the standard python (2.5.2) logging module, specifically the RotatingFileHandler, on a linux system. My application supports both a command-line interface and a web-service interface. I would like to have both write to the same log file. However, when the log file gets rotated, the new file has 644 permissions and is owned by the web server user which prevents the command-line user from writing to it. Can I specify that new log files should be group-writable in the logging configuration or during logging initialization?
I have looked into the mode setting (r/w/a), but it doesn't seem to support any file permissions. | Does python logging.handlers.RotatingFileHandler allow creation of a group writable log file? | 0 | 0 | 0 | 14,631 |
1,408,272 | 2009-09-10T23:35:00.000 | -1 | 1 | 0 | 1 | python,linux | 48,969,869 | 7 | false | 0 | 0 | What do you mean it can't be done [1]? The function, os.stat(path).st_birthtime, works great.
[1]:
Somebody said that it couldn’t be done
But he with a chuckle replied
That “maybe it couldn’t,” but he would be one
Who wouldn’t say so till he’d tried.
So he buckled right in with the trace of a grin
On his face. If he worried he hid it.
He started to sing as he tackled the thing
That couldn’t be done, and he did it!
-- Edgar Albert Guest | 1 | 21 | 0 | os.stat returns st_mtime and st_ctime attributes, the modification time is st_mtime and st_ctime "change time" on POSIX.
is there any function that return the creation time of a file using python and under Linux? | Get file creation time with Python on linux | -0.028564 | 0 | 0 | 11,846 |
1,408,326 | 2009-09-10T23:48:00.000 | 1 | 0 | 1 | 1 | python,executable | 1,408,428 | 4 | false | 0 | 0 | Avoid concatenating all arguments into one string using that string.
It's a lot simpler and better and safer to just pass a sequence (list or tuple) of arguments. This is specially true if any argument contains a space character (which is quite common for filenames). | 1 | 2 | 0 | p = subprocess.Popen(args = "myprog.exe" + " " +
str(input1) + " " +
str(input2) + " " +
str(input3) + " " +
strpoints, stdout = subprocess.PIPE)
in the code above, input1, input2, and input3 are all integers that get converted to strings. the variable "strpoints" is a list of arbitrary length of strings. input1 tells myprog the length of strpoints. of course, when i try to run the above code, i get the following error message:
TypeError: Can't convert 'list' object to str implicitly
how do i pass all the elements of strpoints to myprog.exe? am i doomed to having to do str(strpoints) and then have myprog.exe parse this for commas, apostrophes, etc.? e.g.,
`>>> x = ['a', 'b']
`>>> str(x)
"['a', 'b']"
or should i create a huge string in advance? e.g.,
'>>> x = ['a', 'b']
'>>> stringify(x)
' a b'
where stringify would be something like
def stringify(strlist):
rlist = ""
for i in strlist:
rlist = rlist + i + " "
return rlist | send an arbitrary number of inputs from python to a .exe | 0.049958 | 0 | 0 | 656 |
1,408,627 | 2009-09-11T01:47:00.000 | 1 | 0 | 0 | 1 | python,process,crash,subprocess | 1,408,646 | 2 | false | 0 | 0 | Yes to all. | 1 | 3 | 0 | I want to start a number of subprocesses in my Python script and then track when they complete or crash.
subprocess.Popen.poll() seems to return None when the process is still running, 0 on success, and non-zero on failure. Can that be expected on all OS's?
Unfortunately the standard library documentation is lacking for these methods...
Is the subprocess module the most suitable to achieve this goal?
thanks | Track process status with Python | 0.099668 | 0 | 0 | 4,015 |
1,408,726 | 2009-09-11T02:42:00.000 | 6 | 0 | 1 | 0 | python | 1,408,735 | 3 | false | 0 | 0 | One trick I've learned while trimming down .py files to ship: Delete all the .pyc files in the standard library, then run your application throughly (that is, enough to be sure all the Python modules it needs will be loaded). If you examine the standard library directories, there will be .pyc files for all the modules that were actually used. .py files without .pyc are ones that you don't need. | 1 | 6 | 0 | We've got a (Windows) application, with which we distribute an entire Python installation (including several 3rd-party modules that we use), so we have consistency and so we don't need to install everything separately. This works pretty well, but the application is pretty huge.
Obviously, we don't use everything available in the runtime. I'd like to trim down the runtime to only include what we really need.
I plan on trying out py2exe, but I'd like to try and find another solution that will just help me remove the unneeded parts of the Python runtime. | Trimming Python Runtime | 1 | 0 | 0 | 1,175 |
1,410,444 | 2009-09-11T11:56:00.000 | 3 | 0 | 1 | 0 | python,compiler-construction,correctness | 1,410,452 | 10 | false | 0 | 0 | use editor / IDE that supports code highlighting. E.g., Notepad++ has word-highlighting feature that I find very useful.
use unit tests
stupid errors will be weeded out first, so I wouldn't worry to much about this type of errors. it's "smart" error you should be afraid of. | 2 | 6 | 0 | In C++ I have compiler that tell me if something wrong with my code after refactoring. How to make sure that Python code is at least correct after changes? There may be some stupid error like wrong function name etc. that pretty easy to find in compile time.
Thanks | Checking Python code correctness | 0.059928 | 0 | 0 | 2,794 |
1,410,444 | 2009-09-11T11:56:00.000 | 2 | 0 | 1 | 0 | python,compiler-construction,correctness | 1,411,292 | 10 | false | 0 | 0 | Static analysis (as from the IDE, or from tools like pyLint and pyChecker) is a very quick and effective way to check simple errors, and enforce a common style.
Unit tests are a great way to ensure the code stands for its contract.
Code reviews and pair programming are one of the best ways to find errors of all sorts, and to spread knowledge in a team.
All of the options require some time, to setup and to execute. However, the gains are tremendous, and far higher than the investment. | 2 | 6 | 0 | In C++ I have compiler that tell me if something wrong with my code after refactoring. How to make sure that Python code is at least correct after changes? There may be some stupid error like wrong function name etc. that pretty easy to find in compile time.
Thanks | Checking Python code correctness | 0.039979 | 0 | 0 | 2,794 |
1,410,967 | 2009-09-11T13:46:00.000 | 11 | 0 | 0 | 1 | python,apache,twisted | 1,411,038 | 4 | true | 0 | 0 | Twisted is a platform for developing internet applications, for handling the underlying communications and such. It doesn't "do" anything out of the box--you've got to program it.
Apache is an internet application, of sorts. Upon install, you have a working web server which can serve up static and dynamic web pages. Beyond that, it can be extended to do more than that, if you wish. | 3 | 6 | 0 | I know Twisted is a framework that allows you to do asynchronous non-blocking i/o but I still do not understand how that is different from what Apache server does. If anyone could explain the need for twisted, I would appreciate it.. | Apache vs Twisted | 1.2 | 0 | 0 | 4,183 |
1,410,967 | 2009-09-11T13:46:00.000 | 2 | 0 | 0 | 1 | python,apache,twisted | 1,456,513 | 4 | false | 0 | 0 | @alphazero You read that Twisted vs. Tornado benchmark wrong (or you didn't read it at all). Quote from the article: " Lower mean response time is better." Twisted is lower. People want their webservers to respond with lower (faster) times.
Twisted leaves Tornado in the dust... or, in reality, they differ by a nearly trivial constant factor. | 3 | 6 | 0 | I know Twisted is a framework that allows you to do asynchronous non-blocking i/o but I still do not understand how that is different from what Apache server does. If anyone could explain the need for twisted, I would appreciate it.. | Apache vs Twisted | 0.099668 | 0 | 0 | 4,183 |
1,410,967 | 2009-09-11T13:46:00.000 | 2 | 0 | 0 | 1 | python,apache,twisted | 1,411,014 | 4 | false | 0 | 0 | They are two different things, one is a pure WEB server and one is a WEB framework with a builtin event driven servers.
Twisted is good for constructing high-end ad-hoc network services. | 3 | 6 | 0 | I know Twisted is a framework that allows you to do asynchronous non-blocking i/o but I still do not understand how that is different from what Apache server does. If anyone could explain the need for twisted, I would appreciate it.. | Apache vs Twisted | 0.099668 | 0 | 0 | 4,183 |
1,412,169 | 2009-09-11T17:09:00.000 | 5 | 0 | 0 | 1 | python,django,asynchronous,twisted,real-time | 1,468,718 | 6 | false | 1 | 0 | The biggest advantage for me is that Twisted gives me an application that has state, and can communicate with many different clients using many protocols.
For me, my Twisted server communicates with a number of sensors installed in houses and businesses that monitor power usage. It stores the data and keeps recent data and state in handy-dandy python classes in memory. Requests via xmlrpc from django get this state and can present recent data to the user. My Gridspy stuff is still in development so the actual site at your.gridspy.co.nz is a bit pre-alpha.
The best part is that you need surprisingly little code to make an effective server. An amazing amount of the work is done for you. | 4 | 15 | 0 | I need help understanding what the advantage of using an asynch framework is. Suppose I want to develop a simple chat web app. Why cant I write python code in the Django framework that does long polling where I dont send a response back the server until someone enters a new msg. What does Twisted provide that gives it an advantage for real-time apps like the chat app?
Sorry I am obviously little confused about the need for an asynchronous framework. | Twisted(asynch server) vs Django(or any other framework) | 0.16514 | 0 | 0 | 11,799 |
1,412,169 | 2009-09-11T17:09:00.000 | 3 | 0 | 0 | 1 | python,django,asynchronous,twisted,real-time | 1,417,358 | 6 | false | 1 | 0 | In twisted you can implement protocols of your own. Django certainly can't do this. | 4 | 15 | 0 | I need help understanding what the advantage of using an asynch framework is. Suppose I want to develop a simple chat web app. Why cant I write python code in the Django framework that does long polling where I dont send a response back the server until someone enters a new msg. What does Twisted provide that gives it an advantage for real-time apps like the chat app?
Sorry I am obviously little confused about the need for an asynchronous framework. | Twisted(asynch server) vs Django(or any other framework) | 0.099668 | 0 | 0 | 11,799 |
1,412,169 | 2009-09-11T17:09:00.000 | 16 | 0 | 0 | 1 | python,django,asynchronous,twisted,real-time | 1,412,226 | 6 | true | 1 | 0 | Asynchronous servers support much larger numbers of simultaneous client connections. More conventional servers come up against thread and process limits when servicing large number of concurrent clients, particularly those with long-lived connections. Async servers can also provide better performance as they avoid the overheads of e.g. thread context switching.
As well as the Twisted framework, there are also asynchronous server building blocks in Python's standard library: previously asyncore and asynchat, but now also asyncio. | 4 | 15 | 0 | I need help understanding what the advantage of using an asynch framework is. Suppose I want to develop a simple chat web app. Why cant I write python code in the Django framework that does long polling where I dont send a response back the server until someone enters a new msg. What does Twisted provide that gives it an advantage for real-time apps like the chat app?
Sorry I am obviously little confused about the need for an asynchronous framework. | Twisted(asynch server) vs Django(or any other framework) | 1.2 | 0 | 0 | 11,799 |
1,412,169 | 2009-09-11T17:09:00.000 | 19 | 0 | 0 | 1 | python,django,asynchronous,twisted,real-time | 1,412,372 | 6 | false | 1 | 0 | First off Django is a framework for writing web apps so it provides ORM, html templating, it requires running an http server etc. Twisted helps to write much lower level code than that. You could use twisted to write the http server Django runs on. If you use Django you are limited to http model, with twisted it could be communicating in any protocol you like including push protocols. So for your chat example you get a server that scales better since it can push comments to people who have logged in VS with django every client having to poll repeatedly.
edited to reflect comments by: sos-skyl | 4 | 15 | 0 | I need help understanding what the advantage of using an asynch framework is. Suppose I want to develop a simple chat web app. Why cant I write python code in the Django framework that does long polling where I dont send a response back the server until someone enters a new msg. What does Twisted provide that gives it an advantage for real-time apps like the chat app?
Sorry I am obviously little confused about the need for an asynchronous framework. | Twisted(asynch server) vs Django(or any other framework) | 1 | 0 | 0 | 11,799 |
1,413,540 | 2009-09-11T22:22:00.000 | 5 | 0 | 1 | 0 | python,image | 1,413,561 | 14 | false | 0 | 0 | You cannot display images in a console window.
You need a graphical toolkit such as Tkinter, PyGTK, PyQt, PyKDE, wxPython, PyObjC, or PyFLTK.
There are plenty of tutorials on how to create simple windows and loading images in python. | 2 | 41 | 0 | What is the easiest way to show a .jpg or .gif image from Python console?
I've got a Python console program that is checking a data set which contains links to images stored locally. How should I write the script so that it would display images pop-up graphical windows? | Showing an image from console in Python | 0.071307 | 0 | 0 | 190,850 |
1,413,540 | 2009-09-11T22:22:00.000 | 6 | 0 | 1 | 0 | python,image | 1,413,575 | 14 | false | 0 | 0 | Why not just display it in the user's web browser? | 2 | 41 | 0 | What is the easiest way to show a .jpg or .gif image from Python console?
I've got a Python console program that is checking a data set which contains links to images stored locally. How should I write the script so that it would display images pop-up graphical windows? | Showing an image from console in Python | 1 | 0 | 0 | 190,850 |
1,414,258 | 2009-09-12T04:16:00.000 | 1 | 0 | 0 | 0 | python,python-3.x,pygame | 1,416,509 | 4 | true | 0 | 1 | Just stick with Python 2.6. | 1 | 3 | 0 | I'm using pygame with python 2.6 right now, But I want to use python 3.1.1 instead. The normal pygame only works with 2.x, but the subversion ones work with 3.x I think. But what about pgreloaded? Is that useable yet? The normal pygame actually works with 3.1 too, but not for os x (at least there isn't a download). Does anyone actually use pgreloaded or subversion pygames? So anyway, should I use pygame subversion, pgreloaded, or stick with the current pygame? I don't really care about being compatible with other things or distribution.
Thanks!
EDIT: Ok, I got rid of python 2.6, installed 3.1, used svn command to get pygame, tried running python3 setup.py, didn't work, changed raw_input in setup.py to input(), worked, now my pygames (that were so simple that they work the same under 2.6 and 3.1) run with python 3.1. :) I didn't get pgreloaded because there's no documentation for it. | Should I use pgreloaded? Or subversion of pygame? | 1.2 | 0 | 0 | 1,917 |
1,415,208 | 2009-09-12T14:07:00.000 | 3 | 0 | 0 | 1 | python,google-app-engine,user-controls,controls | 1,415,236 | 3 | false | 1 | 0 | The google app engine "Getting Started" tutorial is very good. The django documentation is also really detailed.
Take a look at GoogleIO on youtube and watch some of the tutorials. | 2 | 2 | 0 | I would like to ask about some sources for developing applications with Python and Google App Engine.
For example, some controls to generate automatically pages with the insert/update/delete of a database table, or any other useful resources are welcome.
Thank you! | Resources for developing Python and Google App Engine | 0.197375 | 0 | 0 | 471 |
1,415,208 | 2009-09-12T14:07:00.000 | 7 | 0 | 0 | 1 | python,google-app-engine,user-controls,controls | 1,419,518 | 3 | true | 1 | 0 | The Python community tends to look askance at code generation; so, @Hoang, if you think code generation is THE way to go, I suggest you try just about any other language BUT Python.
@Dominic has already suggested some excellent resources, I could point you to more (App Engine Fan, App Engine Utilities, etc, etc) but they're all based on the Pythonic mindset: understand what you need and what you could be doing, wrap as much of it as feasible into reusable components, reuse those components from your own sources.
You want magic, wizards and code generation that basically excused you (in theory) from STUDYING and UNDERSTANDING: give up on Python, it's SO not the language for that, | 2 | 2 | 0 | I would like to ask about some sources for developing applications with Python and Google App Engine.
For example, some controls to generate automatically pages with the insert/update/delete of a database table, or any other useful resources are welcome.
Thank you! | Resources for developing Python and Google App Engine | 1.2 | 0 | 0 | 471 |
1,416,005 | 2009-09-12T20:10:00.000 | 3 | 0 | 1 | 0 | python,macos,python-3.x,pygame,virtualenv | 1,416,162 | 5 | true | 0 | 0 | Your use case doesn't actually need virtualenv. You just need to install several different Python versions. | 2 | 9 | 0 | Seems everyone recommends virtualenv for multiple python versions (on osx), but does it even work with python 3.0? I downloaded it, and it doesn't seem to.. And I don't really understand how it works, Can you 'turn on' on env at a time or something? What I want is to leave the system python 2.5 (obviously), and to have python 3.1.1 with subversion pygame to write my own stuff, and python 2.6 with normal stable pygame to use to run other things, like pygame games downloaded from pygame.org. Any help on how to accomplish that? Thanks.
OK I realized virtualenv is not what I'm looking for. | Python - Virtualenv , python 3? | 1.2 | 0 | 0 | 10,930 |
1,416,005 | 2009-09-12T20:10:00.000 | 0 | 0 | 1 | 0 | python,macos,python-3.x,pygame,virtualenv | 1,416,051 | 5 | false | 0 | 0 | Not sure if I understood you correctly, but here goes :)
I don't know about OS X, but in Linux you can install both 2.6 and 3. Then you can either specify to use python25 or python3, or change the /usr/bin/python symlink to the version you want to use by default. | 2 | 9 | 0 | Seems everyone recommends virtualenv for multiple python versions (on osx), but does it even work with python 3.0? I downloaded it, and it doesn't seem to.. And I don't really understand how it works, Can you 'turn on' on env at a time or something? What I want is to leave the system python 2.5 (obviously), and to have python 3.1.1 with subversion pygame to write my own stuff, and python 2.6 with normal stable pygame to use to run other things, like pygame games downloaded from pygame.org. Any help on how to accomplish that? Thanks.
OK I realized virtualenv is not what I'm looking for. | Python - Virtualenv , python 3? | 0 | 0 | 0 | 10,930 |
1,416,570 | 2009-09-13T00:59:00.000 | 0 | 1 | 0 | 0 | python,ruby | 25,123,266 | 6 | false | 1 | 0 | Using Ruby für two years now , i find it powerful, easy to learn, having good libraries, good community.
But how should we know if it fits your needs? Try it an you will find out. | 5 | 1 | 0 | I know that this is a difficult question to answer, but I thought I would try anwyays....
I am just starting at a new company where they have a minimal existing code base. It probably has a month of man effort invested at this point. It is currently written in Ruby.
It is also currently using Ruby on Rails -- but mostly just for the sake of testing out the Ruby code.
The ultimate goal of the code is actually to drive a backend to a site that will be written in php (could be a backend to Drupal, Echo, etc...).
I have no experience with Ruby, so I would tend to want to go with a language I know better (like Python), but am not willing to rule Ruby out for no reason.
If you are not going to use Ruby for a Rails project, is it still worth it? Will I be better off going with Python or some other language?
How do the libraries stack up?
Thanks!!! | To Ruby or not to Ruby | 0 | 0 | 0 | 567 |
1,416,570 | 2009-09-13T00:59:00.000 | 4 | 1 | 0 | 0 | python,ruby | 1,416,827 | 6 | false | 1 | 0 | Ruby Madness. Sure, it seems cool, but it might lead to the hard stuff: Lisp
My predictions:
It's pretty clear that you are OK with either Ruby or Python, and obviously php can be made to work.
You will really like Ruby.
I'm a little bit worried that after Ruby the only place left to go will be Lisp, and that I will become one of those raving lisp maniacs with bad haircuts waving my arms and muttering about The One True Macro Processor.
Slightly more seriously, though Lisp and Smalltalk are still in tiny niche spaces after 60 and 40 years, it turns out that the child of the two bore fruit. Various Lisp and Smalltalk hackers are starting to show up speaking about their child Ruby at Ruby and Rails cons. As it happens, Ruby (timeframe 15 years) has quite a bit of the Lisp and Smalltalk magic.
And, to this party, Ruby brings about every single bit of the day-to-day and 3-line-script usefulness of Perl. Ruby is an explosion on the language scene that combines the scripting superpower of Perl with the object-orient superpower of an exotic language like Smalltalk.
Ruby is an awesome and groundbreaking language with or without Rails. I say, drink the kool-aid. | 5 | 1 | 0 | I know that this is a difficult question to answer, but I thought I would try anwyays....
I am just starting at a new company where they have a minimal existing code base. It probably has a month of man effort invested at this point. It is currently written in Ruby.
It is also currently using Ruby on Rails -- but mostly just for the sake of testing out the Ruby code.
The ultimate goal of the code is actually to drive a backend to a site that will be written in php (could be a backend to Drupal, Echo, etc...).
I have no experience with Ruby, so I would tend to want to go with a language I know better (like Python), but am not willing to rule Ruby out for no reason.
If you are not going to use Ruby for a Rails project, is it still worth it? Will I be better off going with Python or some other language?
How do the libraries stack up?
Thanks!!! | To Ruby or not to Ruby | 0.132549 | 0 | 0 | 567 |
1,416,570 | 2009-09-13T00:59:00.000 | 1 | 1 | 0 | 0 | python,ruby | 1,416,574 | 6 | false | 1 | 0 | Rails apps can potentially make a great REST backend for a php based system.
The REST stuff is made for it. You want xml? ok. You want json? ok.
If you and the staff aren't comfy with it, use something you are more comfy in to write a REST interface. :) | 5 | 1 | 0 | I know that this is a difficult question to answer, but I thought I would try anwyays....
I am just starting at a new company where they have a minimal existing code base. It probably has a month of man effort invested at this point. It is currently written in Ruby.
It is also currently using Ruby on Rails -- but mostly just for the sake of testing out the Ruby code.
The ultimate goal of the code is actually to drive a backend to a site that will be written in php (could be a backend to Drupal, Echo, etc...).
I have no experience with Ruby, so I would tend to want to go with a language I know better (like Python), but am not willing to rule Ruby out for no reason.
If you are not going to use Ruby for a Rails project, is it still worth it? Will I be better off going with Python or some other language?
How do the libraries stack up?
Thanks!!! | To Ruby or not to Ruby | 0.033321 | 0 | 0 | 567 |
1,416,570 | 2009-09-13T00:59:00.000 | 0 | 1 | 0 | 0 | python,ruby | 1,416,583 | 6 | false | 1 | 0 | Why wouldn't you just keep it consistent and use PHP? | 5 | 1 | 0 | I know that this is a difficult question to answer, but I thought I would try anwyays....
I am just starting at a new company where they have a minimal existing code base. It probably has a month of man effort invested at this point. It is currently written in Ruby.
It is also currently using Ruby on Rails -- but mostly just for the sake of testing out the Ruby code.
The ultimate goal of the code is actually to drive a backend to a site that will be written in php (could be a backend to Drupal, Echo, etc...).
I have no experience with Ruby, so I would tend to want to go with a language I know better (like Python), but am not willing to rule Ruby out for no reason.
If you are not going to use Ruby for a Rails project, is it still worth it? Will I be better off going with Python or some other language?
How do the libraries stack up?
Thanks!!! | To Ruby or not to Ruby | 0 | 0 | 0 | 567 |
1,416,570 | 2009-09-13T00:59:00.000 | 0 | 1 | 0 | 0 | python,ruby | 1,416,625 | 6 | false | 1 | 0 | IMO, if you're comfortable with Python then you shouldn't have too much trouble picking up Ruby. This doesn't mean Ruby is the best choice - you should still evaluate the options. | 5 | 1 | 0 | I know that this is a difficult question to answer, but I thought I would try anwyays....
I am just starting at a new company where they have a minimal existing code base. It probably has a month of man effort invested at this point. It is currently written in Ruby.
It is also currently using Ruby on Rails -- but mostly just for the sake of testing out the Ruby code.
The ultimate goal of the code is actually to drive a backend to a site that will be written in php (could be a backend to Drupal, Echo, etc...).
I have no experience with Ruby, so I would tend to want to go with a language I know better (like Python), but am not willing to rule Ruby out for no reason.
If you are not going to use Ruby for a Rails project, is it still worth it? Will I be better off going with Python or some other language?
How do the libraries stack up?
Thanks!!! | To Ruby or not to Ruby | 0 | 0 | 0 | 567 |
1,416,921 | 2009-09-13T05:23:00.000 | 1 | 0 | 0 | 1 | python,google-app-engine | 1,416,947 | 2 | false | 1 | 0 | Apart from the argument-less .fetch() call in your code, which I believe can't possibly work (you ALWAYS have to pass fetch an argument -- the max number of entities you're willing to fetch!), I can't reproduce your problem -- assigning a new attribute (including one obtained by processing existing ones) to each item just works fine in my tests.
Can you please reproduce your observed problem in as tiny as compass as possible and edit your question to include all relevant files pls? Seems to be the only way we could help you with your weird observed bug!
BTW, select name,LEFT( description, 50 ) or whatever OF COURSE won't work in GQL -- GQL, very very explicitly, ONLY supports select * to get whole entities, or select __key__ to get just the entities' keys -- that's all; NO selectivity of columns in the select, much less any OPERATIONS on them!-) | 1 | 0 | 0 | I'm using google appengine (python, of course :) ) and I'd like to do a string.replace on a string from the template file.
{% for item in items %}
<p>{{ item.code.replace( '_', ' ' ) }}</p>
{% endfor %}
But that isn't working. So we cannot execute anything other than basic checks in the app engine templates. Is that Correct ?
Another related problem is I'm trying to shorten a string and make it available to the template.
Each furniture object has a name and a longer description field. In this view I'm rendering, I want only the first 50 characters of the description field.
So I tried something like
items = db.GqlQuery( 'select * from furniture' )
# edit: if you change the above line to
# items = db.GqlQuery( 'select * from furniture' ).fetch( 1000 )
# the .fetch() command makes the addition of dynamic properties work!
for item in items :
item.shortdescr = item.description[ 0:50 ]
# pass data off to template for rendering
self.response.out.write(
template.render( 'furnitureAll.html', { 'items' : items } )
)
Template goes
{% for item in items %}
<p>{{ item.name }}</p>
<p>{{ item.shortdescr }}</p>
<!-- items.shortdescr does not exist here,
probably because I did not .put() it previously. -->
{% endfor %}
Since that didn't work, I tried changing the Gql Query to shorten the string instead. But I'm quickly realizing Gql isn't like SQL. I'm trying to write queries like
select name,LEFT( description, 50 ) from furniture
With little success | Google appengine string replacement in template file | 0.099668 | 0 | 0 | 600 |
1,417,715 | 2009-09-13T13:12:00.000 | 0 | 1 | 0 | 0 | python,http,httpwebrequest,cgi | 1,420,886 | 3 | false | 0 | 0 | Why do you need to distinguish between GET and HEAD?
Normally you shouldn't distinguish and should treat a HEAD request just like a GET. This is because a HEAD request is meant to return the exact same headers as a GET. The only difference is there will be no response content. Just because there is no response content though doesn't mean you no longer have to return a valid Content-Length header, or other headers, which are dependent on the response content.
In mod_wsgi, which various people are pointing you at, it will actually deliberately change the request method from HEAD to GET in certain cases to guard against people who wrongly treat HEAD differently. The specific case where this is done is where an Apache output filter is registered. The reason that it is done in this case is because the output filter may expect to see the response content and from that generate additional response headers. If you were to decide not to bother to generate any response content for a HEAD request, you will deprive the output filter of the content and the headers they add may then not agree with what would be returned from a GET request. The end result of this is that you can stuff up caches and the operation of the browser.
The same can apply equally for CGI scripts behind Apache as output filters can still be added in that case as well. For CGI scripts there is nothing in place though to protect against users being stupid and doing things differently for a HEAD request. | 1 | 12 | 0 | How can I find out the http request my python cgi received? I need different behaviors for HEAD and GET.
Thanks! | Detecting the http request type (GET, HEAD, etc) from a python cgi | 0 | 0 | 1 | 6,773 |
1,417,902 | 2009-09-13T14:44:00.000 | 4 | 0 | 0 | 0 | python,soap,cookies,suds | 1,417,916 | 1 | true | 0 | 0 | Set a "Cookie" HTTP Request Header having the required name/value pairs. This is how Cookie values are usually transmitted in HTTP Based systems. You can add multiple key/value pairs in the same http header.
Single Cookie
Cookie: name1=value1
Multiple Cookies (seperated by semicolons)
Cookie: name1=value1; name2=value2 | 1 | 2 | 0 | I'm trying to access a SOAP API using Suds. The SOAP API documentation states that I have to provide three cookies with some login data. How can I accomplish this? | Sending cookies in a SOAP request using Suds | 1.2 | 0 | 1 | 1,581 |
1,418,082 | 2009-09-13T16:07:00.000 | 4 | 0 | 0 | 0 | python,selenium,selenium-rc | 1,750,751 | 12 | false | 0 | 0 | If you're on Windows, one option is to run the tests under a different user account. This means the browser and java server will not be visible to your own account. | 4 | 93 | 0 | I am using Selenium RC to automate some browser operations but I want the browser to be invisible. Is this possible? How? What about Selenium Grid? Can I hide the Selenium RC window also? | Is it possible to hide the browser in Selenium RC? | 0.066568 | 0 | 1 | 90,474 |
1,418,082 | 2009-09-13T16:07:00.000 | 3 | 0 | 0 | 0 | python,selenium,selenium-rc | 11,261,393 | 12 | false | 0 | 0 | This is how I run my tests with maven on a linux desktop (Ubuntu). I got fed up not being able to work with the firefox webdriver always taking focus.
I installed xvfb
xvfb-run -a mvn clean install
Thats it | 4 | 93 | 0 | I am using Selenium RC to automate some browser operations but I want the browser to be invisible. Is this possible? How? What about Selenium Grid? Can I hide the Selenium RC window also? | Is it possible to hide the browser in Selenium RC? | 0.049958 | 0 | 1 | 90,474 |
1,418,082 | 2009-09-13T16:07:00.000 | 0 | 0 | 0 | 0 | python,selenium,selenium-rc | 24,662,478 | 12 | false | 0 | 0 | On MacOSX, I haven't been able to hide the browser window, but at least I figured out how to move it to a different display so it doesn't disrupt my workflow so much. While Firefox is running tests, just control-click its icon in the dock, select Options, and Assign to Display 2. | 4 | 93 | 0 | I am using Selenium RC to automate some browser operations but I want the browser to be invisible. Is this possible? How? What about Selenium Grid? Can I hide the Selenium RC window also? | Is it possible to hide the browser in Selenium RC? | 0 | 0 | 1 | 90,474 |
1,418,082 | 2009-09-13T16:07:00.000 | 0 | 0 | 0 | 0 | python,selenium,selenium-rc | 55,484,939 | 12 | false | 0 | 0 | Using headless Chrome would be your best bet, or you could post directly to the site to interact with it, which would save a lot of compute power for other things/processes. I use this when testing out web automation bots that search for shoes on multiple sites using cpu heavy elements, the more power you save, and the simpler your program is, the easier it is to run multiple processes at a time with muhc greater speed and reliability. | 4 | 93 | 0 | I am using Selenium RC to automate some browser operations but I want the browser to be invisible. Is this possible? How? What about Selenium Grid? Can I hide the Selenium RC window also? | Is it possible to hide the browser in Selenium RC? | 0 | 0 | 1 | 90,474 |
1,418,266 | 2009-09-13T17:15:00.000 | 3 | 1 | 1 | 0 | python | 1,418,321 | 5 | false | 0 | 0 | Speed depends on the ratio of hits to misses. To be pythonic choose the clearer method.
Personally I think way#1 is clearer (It takes less lines to have an 'if' block rather than an exception block and also uses less brain space). It will also be faster when there are more hits than misses (an exception is more expensive than skipping a if block). | 3 | 2 | 1 | I'm removing an item from an array if it exists.
Two ways I can think of to do this
Way #1
# x array, r item to remove
if r in x :
x.remove( r )
Way #2
try :
x.remove( r )
except :
pass
Timing it shows the try/except way can be faster
(some times i'm getting:)
1.16225508968e-06
8.80804972547e-07
1.14314196588e-06
8.73752536492e-07
import timeit
runs = 10000
x = [ '101', '102', '103', '104', '105', 'a', 'b', 'c',
'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', '111', '112', '113',
'x', 'y', 'z', 'w', 'wwwwwww', 'aeiojwaef', 'iweojfoigj', 'oiowow',
'oiweoiwioeiowe', 'oiwjaoigjoaigjaowig',
]
r = 'a'
code1 ="""
x = [ '101', '102', '103', '104', '105', 'a', 'b', 'c',
'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', '111', '112', '113',
'x', 'y', 'z', 'w', 'wwwwwww', 'aeiojwaef', 'iweojfoigj', 'oiowow',
'oiweoiwioeiowe', 'oiwjaoigjoaigjaowig',
]
r = 'a'
if r in x :
x.remove(r)
"""
print timeit.Timer( code1 ).timeit( runs ) / runs
code2 ="""
x = [ '101', '102', '103', '104', '105', 'a', 'b', 'c',
'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', '111', '112', '113',
'x', 'y', 'z', 'w', 'wwwwwww', 'aeiojwaef', 'iweojfoigj', 'oiowow',
'oiweoiwioeiowe', 'oiwjaoigjoaigjaowig',
]
r = 'a'
try :
x.remove( r )
except :
pass
"""
print timeit.Timer( code2 ).timeit( runs ) / runs
Which is more pythonic? | Which is more pythonic for array removal? | 0.119427 | 0 | 0 | 267 |
1,418,266 | 2009-09-13T17:15:00.000 | 2 | 1 | 1 | 0 | python | 1,418,275 | 5 | false | 0 | 0 | The try/except way | 3 | 2 | 1 | I'm removing an item from an array if it exists.
Two ways I can think of to do this
Way #1
# x array, r item to remove
if r in x :
x.remove( r )
Way #2
try :
x.remove( r )
except :
pass
Timing it shows the try/except way can be faster
(some times i'm getting:)
1.16225508968e-06
8.80804972547e-07
1.14314196588e-06
8.73752536492e-07
import timeit
runs = 10000
x = [ '101', '102', '103', '104', '105', 'a', 'b', 'c',
'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', '111', '112', '113',
'x', 'y', 'z', 'w', 'wwwwwww', 'aeiojwaef', 'iweojfoigj', 'oiowow',
'oiweoiwioeiowe', 'oiwjaoigjoaigjaowig',
]
r = 'a'
code1 ="""
x = [ '101', '102', '103', '104', '105', 'a', 'b', 'c',
'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', '111', '112', '113',
'x', 'y', 'z', 'w', 'wwwwwww', 'aeiojwaef', 'iweojfoigj', 'oiowow',
'oiweoiwioeiowe', 'oiwjaoigjoaigjaowig',
]
r = 'a'
if r in x :
x.remove(r)
"""
print timeit.Timer( code1 ).timeit( runs ) / runs
code2 ="""
x = [ '101', '102', '103', '104', '105', 'a', 'b', 'c',
'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', '111', '112', '113',
'x', 'y', 'z', 'w', 'wwwwwww', 'aeiojwaef', 'iweojfoigj', 'oiowow',
'oiweoiwioeiowe', 'oiwjaoigjoaigjaowig',
]
r = 'a'
try :
x.remove( r )
except :
pass
"""
print timeit.Timer( code2 ).timeit( runs ) / runs
Which is more pythonic? | Which is more pythonic for array removal? | 0.07983 | 0 | 0 | 267 |
1,418,266 | 2009-09-13T17:15:00.000 | 6 | 1 | 1 | 0 | python | 1,418,310 | 5 | true | 0 | 0 | I've always gone with the first method. if in reads far more clearly than exception handling does. | 3 | 2 | 1 | I'm removing an item from an array if it exists.
Two ways I can think of to do this
Way #1
# x array, r item to remove
if r in x :
x.remove( r )
Way #2
try :
x.remove( r )
except :
pass
Timing it shows the try/except way can be faster
(some times i'm getting:)
1.16225508968e-06
8.80804972547e-07
1.14314196588e-06
8.73752536492e-07
import timeit
runs = 10000
x = [ '101', '102', '103', '104', '105', 'a', 'b', 'c',
'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', '111', '112', '113',
'x', 'y', 'z', 'w', 'wwwwwww', 'aeiojwaef', 'iweojfoigj', 'oiowow',
'oiweoiwioeiowe', 'oiwjaoigjoaigjaowig',
]
r = 'a'
code1 ="""
x = [ '101', '102', '103', '104', '105', 'a', 'b', 'c',
'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', '111', '112', '113',
'x', 'y', 'z', 'w', 'wwwwwww', 'aeiojwaef', 'iweojfoigj', 'oiowow',
'oiweoiwioeiowe', 'oiwjaoigjoaigjaowig',
]
r = 'a'
if r in x :
x.remove(r)
"""
print timeit.Timer( code1 ).timeit( runs ) / runs
code2 ="""
x = [ '101', '102', '103', '104', '105', 'a', 'b', 'c',
'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', '111', '112', '113',
'x', 'y', 'z', 'w', 'wwwwwww', 'aeiojwaef', 'iweojfoigj', 'oiowow',
'oiweoiwioeiowe', 'oiwjaoigjoaigjaowig',
]
r = 'a'
try :
x.remove( r )
except :
pass
"""
print timeit.Timer( code2 ).timeit( runs ) / runs
Which is more pythonic? | Which is more pythonic for array removal? | 1.2 | 0 | 0 | 267 |
1,418,553 | 2009-09-13T18:53:00.000 | 3 | 1 | 0 | 1 | python,linux | 1,419,455 | 6 | true | 0 | 0 | First, pick a file extension you want for files you want to have this behavior. pyw is probably a good choice.
Name your file that, and in your file browser associate that file type with python. In GNOME, you'd open its Properties window, go to the Open With tab, and enter python as a custom command.
Now here's the important part: That little dialog you've been getting asking you what you'd like to do with the file is because it is marked as executable. Remove the executable bit with chmod -x. Now when you double click it, it will simply be opened with the associated program.
Of course, if you want to run it from the command line, you'll now have to start it with python explicitly since it isn't marked executable. The shebang line doesn't matter anymore, but I'd leave it in anyway in case someone else marks it executable and expects it to work. | 1 | 3 | 0 | Sorry if this is on the wrong site ( maybe superuser ) but I'm trying to make my python.py file executable so I can click on it and it automatically does its thing, without me specifying it to open in the terminal by that default prompt, and I already have 'chmod +x' for its permissions.
Clarification:
I want to run it by clicking on it, not through the terminal ( I meant that when I said 'can click on it and it automatically does its thing ' )
Already have a shebang line
When I click it right now, it prompts me with do you want to open it in a text file, terminal - can I make it always default to opening in the terminal or is this just an oddball request? | Auto executable python file without opening from terminal? | 1.2 | 0 | 0 | 9,279 |
1,418,588 | 2009-09-13T19:03:00.000 | 16 | 0 | 1 | 0 | python,performance,data-structures,dictionary | 1,418,591 | 2 | false | 0 | 0 | Dictionaries are one of the more heavily tuned parts of Python, since they underlie so much of the language. For example, members of a class, and variables in a stack frame are both stored internally in dictionaries. They will be a good choice if they are the right data structure.
Choosing between lists and dicts based on performance seems odd: they do different things. Maybe you can tell us more about the problem you are trying to solve. | 1 | 35 | 0 | As the title states, how expensive are Python dictionaries to handle? Creation, insertion, updating, deletion, all of it.
Asymptotic time complexities are interesting themselves, but also how they compare to e.g. tuples or normal lists. | How expensive are Python dictionaries to handle? | 1 | 0 | 0 | 30,446 |
1,418,825 | 2009-09-13T21:02:00.000 | 5 | 0 | 1 | 0 | python,class,magic-methods | 37,850,243 | 10 | false | 0 | 0 | Do this if you prefer reading documentation from a CLI instead of the browser.
$ pydoc SPECIALMETHODS | 2 | 52 | 0 | Where is a complete list of the special double-underscore/dunder methods that can be used in classes? (e.g., __init__, __new__, __len__, __add__) | Where is the Python documentation for the special methods? (__init__, __new__, __len__, ...) | 0.099668 | 0 | 0 | 25,147 |
1,418,825 | 2009-09-13T21:02:00.000 | -3 | 0 | 1 | 0 | python,class,magic-methods | 1,418,931 | 10 | false | 0 | 0 | Familiarize yourself with the dir function. | 2 | 52 | 0 | Where is a complete list of the special double-underscore/dunder methods that can be used in classes? (e.g., __init__, __new__, __len__, __add__) | Where is the Python documentation for the special methods? (__init__, __new__, __len__, ...) | -0.059928 | 0 | 0 | 25,147 |
1,419,039 | 2009-09-13T22:48:00.000 | 3 | 0 | 1 | 0 | python,file,naming-conventions,explicit,variable-names | 1,420,921 | 6 | false | 0 | 0 | Generally if the scope of a file object is only a few lines, f is perfectly readable - the variable name for the filename in the open call is probably descriptive enough. otherwise something_file is probably a good idea. | 4 | 16 | 0 | A pretty silly trivial question. The canonical example is f = open('filename'), but
f is not very descriptive. After not looking at code in a while,
you can forget whether it means
"file" or "function f(x)" or "fourier
transform results" or something else. EIBTI.
In Python, file is already taken by a function.
What else do you use? | What variable name do you use for file descriptors? | 0.099668 | 0 | 0 | 5,842 |
1,419,039 | 2009-09-13T22:48:00.000 | 0 | 0 | 1 | 0 | python,file,naming-conventions,explicit,variable-names | 1,420,872 | 6 | false | 0 | 0 | I rather use one of: f, fp, fd.
Sometimes inf / outf for input and output file. | 4 | 16 | 0 | A pretty silly trivial question. The canonical example is f = open('filename'), but
f is not very descriptive. After not looking at code in a while,
you can forget whether it means
"file" or "function f(x)" or "fourier
transform results" or something else. EIBTI.
In Python, file is already taken by a function.
What else do you use? | What variable name do you use for file descriptors? | 0 | 0 | 0 | 5,842 |
1,419,039 | 2009-09-13T22:48:00.000 | 4 | 0 | 1 | 0 | python,file,naming-conventions,explicit,variable-names | 1,419,303 | 6 | false | 0 | 0 | I'm happy to use f (for either a function OR a file;-) if that identifier's scope is constrained to a pretty small compass (such as with open('zap') as f: would normally portend, say). In general, identifiers with large lexical scopes should be longer and more explicit, ones with lexically small/short scopes/lifespans can be shorter and less explicit, and this applies to open file object just about as much as to any other kind of object!-) | 4 | 16 | 0 | A pretty silly trivial question. The canonical example is f = open('filename'), but
f is not very descriptive. After not looking at code in a while,
you can forget whether it means
"file" or "function f(x)" or "fourier
transform results" or something else. EIBTI.
In Python, file is already taken by a function.
What else do you use? | What variable name do you use for file descriptors? | 0.132549 | 0 | 0 | 5,842 |
1,419,039 | 2009-09-13T22:48:00.000 | 2 | 0 | 1 | 0 | python,file,naming-conventions,explicit,variable-names | 1,419,050 | 6 | false | 0 | 0 | generally I'll use "fp" for a short-lifetime file pointer.
for a longer-lived descriptor, I'll be more descriptive. "fpDebugLog", for example. | 4 | 16 | 0 | A pretty silly trivial question. The canonical example is f = open('filename'), but
f is not very descriptive. After not looking at code in a while,
you can forget whether it means
"file" or "function f(x)" or "fourier
transform results" or something else. EIBTI.
In Python, file is already taken by a function.
What else do you use? | What variable name do you use for file descriptors? | 0.066568 | 0 | 0 | 5,842 |
1,419,046 | 2009-09-13T22:54:00.000 | 26 | 0 | 1 | 0 | python,arguments,keyword,optional-parameters,named-parameters | 1,419,098 | 10 | false | 0 | 0 | There are two ways to assign argument values to function parameters, both are used.
By Position. Positional arguments do not have keywords and are assigned first.
By Keyword. Keyword arguments have keywords and are assigned second, after positional arguments.
Note that you have the option to use positional arguments.
If you don't use positional arguments, then -- yes -- everything you wrote turns out to be a keyword argument.
When you call a function you make a decision to use position or keyword or a mixture. You can choose to do all keywords if you want. Some of us do not make this choice and use positional arguments. | 1 | 317 | 0 | How are "keyword arguments" different from regular arguments? Can't all arguments be passed as name=value instead of using positional syntax? | Normal arguments vs. keyword arguments | 1 | 0 | 0 | 279,057 |
1,419,442 | 2009-09-14T02:24:00.000 | 0 | 0 | 0 | 0 | python,django,django-models | 1,419,548 | 6 | false | 1 | 0 | Probably you need to use the content types app to link to a model. You might then arrange for your app to check the settings to do some additional checking to limit which content types it will accept or suggest. | 1 | 17 | 0 | In my django site I have two apps, blog and links. blog has a model blogpost, and links has a model link. There should be a one to many relationship between these two things. There are many links per blogpost, but each link has one and only one blog post. The simple answer is to put a ForeignKey to blogpost in the link model.
That's all well and good, however there is a problem. I want to make the links app reusable. I don't want it to depend upon the blog app. I want to be able to use it again in other sites and perhaps associate links with other non-blogpost apps and models.
A generic foreign key seems like it might be the answer, but not really. I don't want links to be able to associate with any model in my site. Just the one that I explicitly specify. And I know from prior experience that there can be issues using generic foreign keys in terms of database usage because you can't do a select_related over a generic foreign key the way you can with a regular foreign key.
What is the "correct" way to model this relationship? | How to Model a Foreign Key in a Reusable Django App? | 0 | 0 | 0 | 3,459 |
1,422,368 | 2009-09-14T15:43:00.000 | 95 | 1 | 0 | 1 | python,windows,linux | 1,422,436 | 3 | true | 0 | 0 | The substitute of fcntl on windows are win32api calls. The usage is completely different. It is not some switch you can just flip.
In other words, porting a fcntl-heavy-user module to windows is not trivial. It requires you to analyze what exactly each fcntl call does and then find the equivalent win32api code, if any.
There's also the possibility that some code using fcntl has no windows equivalent, which would require you to change the module api and maybe the structure/paradigm of the program using the module you're porting.
If you provide more details about the fcntl calls people can find windows equivalents. | 1 | 86 | 0 | I received a Python project (which happens to be a Django project, if that matters,) that uses the fcntl module from the standard library, which seems to be available only on Linux. When I try to run it on my Windows machine, it stops with an ImportError, because this module does not exist here.
Is there any way for me to make a small change in the program to make it work on Windows? | fcntl substitute on Windows | 1.2 | 0 | 0 | 122,994 |
1,422,969 | 2009-09-14T17:45:00.000 | 10 | 0 | 1 | 0 | python | 1,423,016 | 1 | true | 0 | 0 | heapq uses the intrinsic comparisons on queue items (__le__ and friends). The general way to work around this limit is the good old approach known as "decorate/undecorate" -- that's what we used to do in sorting, before the key= parameter was introduced there.
To put it simply, you enqueue and dequeue, not just the items you care about ("payload"), but rather the items "decorated" into tuples that start with the "keys" you need heapq to consider. So for example it would be normal to enqueue a tuple like (foo.x, time.time(), foo) if you want prioritization by the x attribute with ties broken by time of insertion in the queue -- of course when you de-queue you "undecorate", there by taking the [-1]th item of the tuple you get by de-queueing.
So, just put the "secondary keys" you need to be considered for "tie-breaking" in the "decorated" tuple you enqueue, AFTER the ones whose "ties" you want to break that way. | 1 | 3 | 0 | At the moment, I am trying to write a priority queue in Python using the built in heapq library. However, I am stuck trying to get a handle on what Python does with the tie-breaking, I want to have a specific condition where I can dictate what happens with the tie-breaking instead of the heapq library that seems to almost pick something off the queue at random. Does anybody know of a way of rewriting the tie-breaking condition or would it be easier to build the priority queue from the ground up? | Python and the built-in heap | 1.2 | 0 | 0 | 489 |
1,423,000 | 2009-09-14T17:56:00.000 | 0 | 0 | 0 | 0 | python,web-applications,python-3.x,wsgi | 1,934,744 | 4 | false | 1 | 0 | Even though it's not officially released yet, I am currently 'playing around' with CherryPy 3.2.0rc1 with Python 3.1.1 and have had no problems yet. Haven't used it with py-postgresql, but I don't see why it shouldn't work.
Hope this helps,
Alan | 1 | 1 | 0 | I have started learning Python by writing a small application using Python 3.1 and py-PostgreSQL. Now I want to turn it into a web application.
But it seems that most frameworks such as web-py, Django, zope are still based on Python 2.x. Unfortunately, py-PostgreSQL is incompatible with Python 2.x.
Do I have to rewrite all my classes and replace py-PostgreSQL with something supported by web-py etc., or is there a framework compatible with Python 3.1?
Or maybe py-PostgreSQL is compatible with 2.x but I did not figure it out? | web framework compatible with python 3.1 and py-postgresql | 0 | 1 | 0 | 1,695 |
1,423,041 | 2009-09-14T18:03:00.000 | 0 | 0 | 0 | 0 | python,frameworks,cgi,nearlyfreespeech | 1,423,084 | 4 | false | 1 | 0 | By the things they reject. I think that twisted.web is still an option there, but I don't have any experience with nearlyfreespeech.net | 1 | 6 | 0 | From nearlyfreespeech's website, they state that the following don't work well:
mod_python Web application
frameworks that depend on persistent processes, including: Ruby On Rails, Django, Zope, and others (some of these will run under CGI, but will run slowly and are suitable only for development purposes)
Are there any Python web frameworks that work well on NearlyFreeSpeech? | What python web frameworks work well with CGI (e.g. on nearlyfreespeech.net)? | 0 | 0 | 0 | 1,934 |
1,423,308 | 2009-09-14T18:59:00.000 | 0 | 1 | 0 | 0 | python,modem,gsm,at-command | 1,424,253 | 2 | false | 0 | 0 | I find I can't remember much of the AT command set related to SMS. Andre Miller's answer seems to ring a few bells. Anyway you should read the documentation very carefully, I'm sure there were a few gotchas.
My recommentation for polling is at least every 5 seconds - this is just for robustness and responsiveness in the face of disconnection.
I used a state machine to navigate between initialisation, reading and deleting messages. | 1 | 8 | 0 | I have a GSM modem connected to my computer, i want to receive text messages sent to it using a python program i have written, am just wondering what is the best technique to poll for data.
Should i write a program that has a infinite loop that continuously checks for incoming sms's i.e within the loop the program sends the AT commands and reads the input data. or do modems have a way of signaling an application of an incoming data(sms).
Am trying to imagine a cellphone is just a GSM modem, and when an sms is received, the phone alerts you of the event, or does the phone software have an infinite loop that polls for incoming data. | What is the best design for polling a modem for incoming data? | 0 | 0 | 0 | 3,845 |
1,424,392 | 2009-09-14T23:26:00.000 | 8 | 0 | 0 | 0 | python,django,ide,code-completion,komodo | 1,424,443 | 3 | false | 1 | 0 | o to Edit > Preferences. Expand the
"Languages" group by clicking the [+]
symbol. Click "Python". Click the
little "Add..." button under
"Additional Python Import
Directories". Add the directory ABOVE
your project and you should have
intellisense enabled.
This has always worked for me for both Django and my individual projects. | 3 | 2 | 0 | I've been using Komodo Edit for a small project in Django.
The code completion features seem to work pretty well for standard python modules, however, it doesn't know anything about Django modules. Is there any way to configure Komodo Edit to use Django modules for autocomplete as well? | Komodo Edit - code-completion for Django? | 1 | 0 | 0 | 6,602 |
1,424,392 | 2009-09-14T23:26:00.000 | 4 | 0 | 0 | 0 | python,django,ide,code-completion,komodo | 1,424,422 | 3 | true | 1 | 0 | By sure Django is on your python path and Komodo should pick it up. Alternatively you can add the location of Django to where Komodo looks for its autocomplete. | 3 | 2 | 0 | I've been using Komodo Edit for a small project in Django.
The code completion features seem to work pretty well for standard python modules, however, it doesn't know anything about Django modules. Is there any way to configure Komodo Edit to use Django modules for autocomplete as well? | Komodo Edit - code-completion for Django? | 1.2 | 0 | 0 | 6,602 |
1,424,392 | 2009-09-14T23:26:00.000 | 2 | 0 | 0 | 0 | python,django,ide,code-completion,komodo | 1,424,499 | 3 | false | 1 | 0 | Hmmm. It's installed by default so my answer probably isn't the right solution. :-)
But here goes...
You can install a Django extension in Komodo edit. I haven't tested it myself but you can test it.
Tools -> Add-ons -> Extensions
It's name is "Django Language".
Check if it works. | 3 | 2 | 0 | I've been using Komodo Edit for a small project in Django.
The code completion features seem to work pretty well for standard python modules, however, it doesn't know anything about Django modules. Is there any way to configure Komodo Edit to use Django modules for autocomplete as well? | Komodo Edit - code-completion for Django? | 0.132549 | 0 | 0 | 6,602 |
1,424,398 | 2009-09-14T23:28:00.000 | 4 | 1 | 0 | 1 | python,python-idle | 20,500,218 | 11 | false | 0 | 0 | I actually just discovered the easiest answer, if you use the shortcut link labeled "IDLE (Python GUI)". This is in Windows Vista, so I don't know if it'll work in other OS's.
1) Right-click "Properties".
2) Select "Shortcut" tab.
3) In "Start In", write file path (e.g. "C:\Users...").
Let me know if this works! | 8 | 9 | 0 | Does anyone know where or how to set the default path/directory on saving python scripts prior to running?
On a Mac it wants to save them in the top level ~/Documents directory. I would like to specify a real location. Any ideas? | Default save path for Python IDLE? | 0.072599 | 0 | 0 | 28,611 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.