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
6,908,827
2011-08-02T07:52:00.000
1
0
0
0
python,google-app-engine
6,909,612
3
false
1
0
I don't really understand your question. If you want an automatically-generated key name, just leave out the key when you instantiate the object - one will be automatically assigned when you call put().
1
0
0
I want to insert new entities programatically as well as manually. For this I was thinking about using key_name to uniquely identify an entity. The problem is that I don't know how to get the model to generate a new unique key name when I create the entity. On the other hand, I cannot create the ID (which is unique acr...
Fun with GAE: using key_name as PK?
0.066568
0
0
178
6,909,143
2011-08-02T08:23:00.000
0
0
0
0
django,apache,media,mod-python
6,909,236
2
false
1
0
It is surely a pro since the django serves the requests faster without having to deal with the media. A con is that, if and when you edit the media, you need to also restart the apache, for the media to refresh. update based on your comment: You can of-course easily do it. One simple way I practice this is, by using th...
2
0
0
For some reason i can't figure out, other than the 'stupid' errors that keep creeping up when I try to access media files (files uploaded by the user) in my Django app, why I just can't server media files! In this particular case, all I want for example is to be able to serve up images to the front that have been uploa...
Serve Media Files Via Apache on a Django Development Server?
0
0
0
859
6,909,143
2011-08-02T08:23:00.000
0
0
0
0
django,apache,media,mod-python
6,909,511
2
false
1
0
First, mod_python is not recommended. In fact, it's specifically recommended against. Use mod_wsgi instead. Secondly, we have no possible way of telling what you're doing wrong when serving static media via the dev server, because you have provided no code or details of your setup. Finally, there is no reason why you c...
2
0
0
For some reason i can't figure out, other than the 'stupid' errors that keep creeping up when I try to access media files (files uploaded by the user) in my Django app, why I just can't server media files! In this particular case, all I want for example is to be able to serve up images to the front that have been uploa...
Serve Media Files Via Apache on a Django Development Server?
0
0
0
859
6,912,241
2011-08-02T12:42:00.000
3
1
0
0
python,dhtml,zope
6,913,162
2
true
0
0
Currently this is not supported out-of-the-box. Object identifiers (getId) are only indexed as field values and thus can only be looked up as whole strings. You'd need to add separate index to the catalog to support your use-case. You could add a new TextIndexNG2 index with a new name indexing just the getId method. In...
1
3
0
I want to Search for an Object name. If i have this Structure: /de/myspace/media/justAnotherPdf.pdf Then i want to Search for the name "justAnotherPdf" to find it or something like "justAnot" I have Indexed the pdf files. But i cant search it with TextIndexNG2 or PathIndex.
How to search for ZCatalog object names
1.2
0
0
171
6,915,191
2011-08-02T16:17:00.000
1
1
0
0
c++,python,cross-platform,ipc
6,915,320
7
false
0
1
How complex is your data? If it is simple I would serialize it as a string. If it was moderately complex I would use JSON. TCP is a good cross-platform IPC transport. Since you say that this IPC is rare the performance isn't very important, and TCP+JSON will be fine.
2
43
0
I have a C++ process running in the background that will be generating 'events' infrequently that a Python process running on the same box will need to pick up. The code on the C side needs to be as lightweight as possible. The Python side is read-only. The implementation must be cross-platform. The data being sent ...
Simple IPC between C++ and Python (cross platform)
0.028564
0
0
40,430
6,915,191
2011-08-02T16:17:00.000
-3
1
0
0
c++,python,cross-platform,ipc
6,915,884
7
false
0
1
I will say you create a DLL that will manage the communication between the two. The python will load DLL and call method like getData() and the DLL will in turn communicate with process and get the data. That should not be hard. Also you can use XML file or SQLite database or any database to query data. The daemon will...
2
43
0
I have a C++ process running in the background that will be generating 'events' infrequently that a Python process running on the same box will need to pick up. The code on the C side needs to be as lightweight as possible. The Python side is read-only. The implementation must be cross-platform. The data being sent ...
Simple IPC between C++ and Python (cross platform)
-0.085505
0
0
40,430
6,915,473
2011-08-02T16:39:00.000
0
0
1
1
python,compression,py2app
6,916,667
1
false
0
0
I have more experience with Pyinstaller, but do you have to put the executable through Py2App? Might it be possible to package it with your executable in the same directory so it will be found and run? Is producing a single file very important, or could you include it in a directory with other dependencies?
1
0
0
At the moment, I'm using py2app to convert python scripts to a standalone application. However, my scripts require a 2GB unix executable. Py2App isn't able to process a file that large as an included file or resource, as it produces an error in the creation of the standalone file. Is there anyway I can include this fil...
Py2App: File Needs to Be Included, but it is Too Large
0
0
0
259
6,916,033
2011-08-02T17:29:00.000
3
0
1
1
python,python-2.6,file-descriptor
6,916,070
2
false
0
0
How about trying to os.write to fd=3 once at the start (inside a try-except block), and change all subsequent behaviour based on the success of that? This way you won't have to wrap every call in try-except. Of course, this will break down if fd=3 stops being valid in the middle of your problem (e.g. if it's a pipe tha...
1
12
0
How do I check to see if a given file descriptor is valid? I want to write to fd=3 if it's available; otherwise, I want to write to stdout. I'm aware that I could wrap every os.write call with try-except statement, but I would like to know ahead of time if fd=3 is writable or not.
Check if file descriptor is valid
0.291313
0
0
9,398
6,916,753
2011-08-02T18:26:00.000
1
0
1
0
python,exec,eval
6,916,771
6
false
0
0
2 choices: You take his input and put it in a file, then you execute it. You use exec()
2
2
0
I'm developing a system that operates on (arbitrary) data from databases. The data may need some preprocessing before the system can work with it. To allow the user the specify possibly complex rules I though of giving the user the possibility to input Python code which is used to do this task. The system is pure Pytho...
Use user provided python code during runtime
0.033321
0
0
1,291
6,916,753
2011-08-02T18:26:00.000
0
0
1
0
python,exec,eval
6,916,891
6
false
0
0
What you actually want is exec, since eval is limited to taking an expression and returning a value. With exec, you can have code blocks (statements) and work on arbitrarily complex data, passed in as the globals and locals of the code. The result is then returned by the code via some convention (like binding it to res...
2
2
0
I'm developing a system that operates on (arbitrary) data from databases. The data may need some preprocessing before the system can work with it. To allow the user the specify possibly complex rules I though of giving the user the possibility to input Python code which is used to do this task. The system is pure Pytho...
Use user provided python code during runtime
0
0
0
1,291
6,916,976
2011-08-02T18:45:00.000
1
0
0
0
python,multithreading
6,917,498
4
false
0
0
Similar to Spike Gronim's answer, but even more heavy handed. Consider rewriting this in twisted. You probably would want to subclass twisted.web.http.HTTPClient, in particular implementing handleResponsePart to do your client interaction (or handleResponseEnd if you don't need to see it before the response ends). To...
1
4
0
I'm porting one of my projects from C# and am having trouble solving a multithreading issue in Python. The problem relates to a long-lived HTTP request, which is expected (the request will respond when a certain event occurs on the server). Here's the summary: I send the request using urllib2 on a separate thread. W...
Aborting HTTP request cross-thread
0.049958
0
1
799
6,917,330
2011-08-02T19:16:00.000
4
0
0
0
python,byte,hex,checksum,crc
6,922,436
1
false
1
0
Thanks !!! the following two solutions worked; checksum = sum(map(ord, b)) or checksum = sum(bytearray(b)) / J
1
0
0
I am creating a Hex file using python and at the end I need to add a checksum that consists of sum of all hex values so that checksum = Byte 0x000000 + Byte 0x000001 +…+ Byte 0x27DAFF (not including this 4 bytes). This checksum shall then be written to buffer at position 0x27DB00-0x27DB03 as unsigned long. Any good ide...
How to generate checksum from hex byte using python
0.664037
0
0
7,142
6,917,456
2011-08-02T19:25:00.000
2
0
1
0
python,wxpython,packaging
6,921,159
3
false
0
1
Unfortunately, there's just no one stop solution so that a single installable executable will work across all operating systems. The right solution is really to provide a different installer or executable for each OS; For windows, use py2exe, for mac, py2app is a good choice, and for linux you should just provide a t...
1
2
0
I hope my title was clear. I'm using wxpython for making a GUI and I want it to be able to be opened, extracted, and have it work on all operating systems. I was able to include twill by finding a folder called twill inside the twill archive, which worked fine. However, I'm unable to figure out how to correctly package...
How can I package my python application with external python libraries?
0.132549
0
0
697
6,918,291
2011-08-02T20:37:00.000
1
0
1
0
python,word,byte,file-read
6,918,375
6
false
0
0
There is no concept of 'word' in Python, when you read binary data from a file, you can state explicitly, how many bytes should be read at a time. In terms of compiler and/or platform, 'WORD' generally determines a size of a basic data unit. And Python is independent from that kind of stuff :)
3
4
0
I need to know the number of bytes in a 'word' in Python. The reason I need this is I have the number of words I need to read from a file; if I knew the number of bytes in a word, I can use the file.read(num_bytes) function to read the appropriate amount from the file. How can I determine the number of bytes in a word?
How to determine 'word' size in Python
0.033321
0
0
12,095
6,918,291
2011-08-02T20:37:00.000
0
0
1
0
python,word,byte,file-read
44,102,543
6
false
0
0
Perhaps the following might be relevant and helpful: Suppose you checking for 32-bits. See if (-1)<<31 comes back as long or not. For 32-bit, it does not, while (-1)<<32 and 1<<31 do.
3
4
0
I need to know the number of bytes in a 'word' in Python. The reason I need this is I have the number of words I need to read from a file; if I knew the number of bytes in a word, I can use the file.read(num_bytes) function to read the appropriate amount from the file. How can I determine the number of bytes in a word?
How to determine 'word' size in Python
0
0
0
12,095
6,918,291
2011-08-02T20:37:00.000
0
0
1
0
python,word,byte,file-read
6,920,189
6
false
0
0
I need to know the number of bytes in a 'word' in Python. The reason I need this is I have the number of words I need to read from a file Then you need to ask the person who wrote the file. It has nothing to do with Python and everything to do with what the actual file format is. It's pretty odd for a file to be def...
3
4
0
I need to know the number of bytes in a 'word' in Python. The reason I need this is I have the number of words I need to read from a file; if I knew the number of bytes in a word, I can use the file.read(num_bytes) function to read the appropriate amount from the file. How can I determine the number of bytes in a word?
How to determine 'word' size in Python
0
0
0
12,095
6,918,493
2011-08-02T20:54:00.000
5
0
1
0
python,logging,printing
6,918,531
7
false
0
0
If you use logging then the person responsible for deployment can configure the logger to send it to a custom location, with custom information. If you only print, then that's all they get.
5
140
0
For simple debugging in a complex project is there a reason to use the python logger instead of print? What about other use-cases? Is there an accepted best use-case for each (especially when you're only looking for stdout)? I've always heard that this is a "best practice" but I haven't been able to figure out why.
In python, why use logging instead of print?
0.141893
0
0
50,731
6,918,493
2011-08-02T20:54:00.000
0
0
1
0
python,logging,printing
71,648,091
7
false
0
0
I would add to all other mentionned advantages that the print function in standard configuration is buffered. The flush may occure only at the end of the current block (the one where the print is). This is true for any program launched in a non interactive shell (codebuild, gitlab-ci for instance) or whose output is re...
5
140
0
For simple debugging in a complex project is there a reason to use the python logger instead of print? What about other use-cases? Is there an accepted best use-case for each (especially when you're only looking for stdout)? I've always heard that this is a "best practice" but I haven't been able to figure out why.
In python, why use logging instead of print?
0
0
0
50,731
6,918,493
2011-08-02T20:54:00.000
30
0
1
0
python,logging,printing
6,918,525
7
false
0
0
One of the biggest advantages of proper logging is that you can categorize messages and turn them on or off depending on what you need. For example, it might be useful to turn on debugging level messages for a certain part of the project, but tone it down for other parts, so as not to be taken over by information overl...
5
140
0
For simple debugging in a complex project is there a reason to use the python logger instead of print? What about other use-cases? Is there an accepted best use-case for each (especially when you're only looking for stdout)? I've always heard that this is a "best practice" but I haven't been able to figure out why.
In python, why use logging instead of print?
1
0
0
50,731
6,918,493
2011-08-02T20:54:00.000
154
0
1
0
python,logging,printing
6,918,596
7
true
0
0
The logging package has a lot of useful features: Easy to see where and when (even what line no.) a logging call is being made from. You can log to files, sockets, pretty much anything, all at the same time. You can differentiate your logging based on severity. Print doesn't have any of these. Also, if your project i...
5
140
0
For simple debugging in a complex project is there a reason to use the python logger instead of print? What about other use-cases? Is there an accepted best use-case for each (especially when you're only looking for stdout)? I've always heard that this is a "best practice" but I haven't been able to figure out why.
In python, why use logging instead of print?
1.2
0
0
50,731
6,918,493
2011-08-02T20:54:00.000
18
0
1
0
python,logging,printing
6,918,829
7
false
0
0
Print statements are sort of the worst of both worlds, combining the negative aspects of an online debugger with diagnostic instrumentation. You have to modify the program but you don't get more, useful code from it. An online debugger allows you to inspect the state of a running program; But the nice thing about a r...
5
140
0
For simple debugging in a complex project is there a reason to use the python logger instead of print? What about other use-cases? Is there an accepted best use-case for each (especially when you're only looking for stdout)? I've always heard that this is a "best practice" but I haven't been able to figure out why.
In python, why use logging instead of print?
1
0
0
50,731
6,920,403
2011-08-03T00:34:00.000
-1
0
1
0
python,datetime,date
6,920,479
3
false
1
0
datetime is a the same as the types date and time. The only thing better is that it takes less space than date does.
2
2
0
Doesn't datetime cover all that date can do? I haven't read all the documentation, but so far I always find myself using datetime. Even in Django - datetime model fields are always more useful (at least for me). You don't have to use the hours if you don't want to, but if you decide that you do, you can. Javascript s...
Why is there a date class in python
-0.066568
0
0
307
6,920,403
2011-08-03T00:34:00.000
4
0
1
0
python,datetime,date
6,920,665
3
false
1
0
Certain concepts may be easier to understand as dates rather than datetimes. For example, birthdays, paydays, and due dates all could potentially be datetimes, but they may be far better expressed as simple dates. Expressing these as datetimes could lead to confusion/ambiguity down the road. First of all, future mainta...
2
2
0
Doesn't datetime cover all that date can do? I haven't read all the documentation, but so far I always find myself using datetime. Even in Django - datetime model fields are always more useful (at least for me). You don't have to use the hours if you don't want to, but if you decide that you do, you can. Javascript s...
Why is there a date class in python
0.26052
0
0
307
6,921,699
2011-08-03T04:38:00.000
5
0
1
0
python,json,load,ordereddictionary
28,688,923
6
false
0
0
In addition to dumping the ordered list of keys alongside the dictionary, another low-tech solution, which has the advantage of being explicit, is to dump the (ordered) list of key-value pairs ordered_dict.items(); loading is a simple OrderedDict(<list of key-value pairs>). This handles an ordered dictionary despite th...
2
457
0
Ok so I can use an OrderedDict in json.dump. That is, an OrderedDict can be used as an input to JSON. But can it be used as an output? If so how? In my case I'd like to load into an OrderedDict so I can keep the order of the keys in the file. If not, is there some kind of workaround?
Can I get JSON to load into an OrderedDict?
0.16514
0
0
162,110
6,921,699
2011-08-03T04:38:00.000
7
0
1
0
python,json,load,ordereddictionary
6,921,719
6
false
0
0
You could always write out the list of keys in addition to dumping the dict, and then reconstruct the OrderedDict by iterating through the list?
2
457
0
Ok so I can use an OrderedDict in json.dump. That is, an OrderedDict can be used as an input to JSON. But can it be used as an output? If so how? In my case I'd like to load into an OrderedDict so I can keep the order of the keys in the file. If not, is there some kind of workaround?
Can I get JSON to load into an OrderedDict?
1
0
0
162,110
6,922,245
2011-08-03T05:55:00.000
2
1
1
0
php,javascript,python,perl
6,922,286
4
false
0
0
They use it when parsing so that variables can easily be distinguished from other stuffs.
1
6
0
Does anyone know, what is the actual reason behind "dollar variable notation" in some of the scripting languages, i.e. PHP or Perl? Python creators did not find $variable useful, neither do I. Why does PHP and Perl force me to press shift-4 so often? (OK, in Perl you can somehow explain it with distinguishing $scalar, ...
Dollar notation in script languages - why?
0.099668
0
0
656
6,925,079
2011-08-03T10:31:00.000
0
0
1
0
python
6,925,162
5
false
0
0
You can't (without hacks) and shouldn't. Use a dictionary values = {"mandy": []} instead. Why would you want a local variable whose name you don't know?! If you know its name at coding-time, use it in a garden-variety assignment. If not, it shouldn't be a local variable.
1
1
0
May it's very simple question, but I'm stuck here. I have variable val as val="mandy", now i want to create a list whose name is the content of val. i.e. "mandy". so how to define mandy=[] in python. It's like "$$" equivalent of PHP.
How to create a new variable from the contents of another variable in python?
0
0
0
187
6,925,122
2011-08-03T10:35:00.000
5
0
0
0
python,ssl,tcp,twisted
6,925,249
2
true
0
0
Use a different port number for SSL connections. This is how HTTP / HTTPS are used. Or Define a command in your protocol to transform the connection into SSL e.g. STARTTLS, based on a capability negotiation. This is one way the same thing is achieved in SMTP.
2
1
0
I've wrote a simple client and a server. They both can configured to use SSL or not. You can set it up in the client and in the server. My problem is, if I try to connect without SSL to a server setup with SSL, the connection is made but stuck. (of course... it is normal). How my client can know that he is trying to co...
How to know if my server is using SSL or not (with Twisted)
1.2
0
1
623
6,925,122
2011-08-03T10:35:00.000
0
0
0
0
python,ssl,tcp,twisted
6,925,332
2
false
0
0
The best solution will be that my client autodetect if server use SSL or not and do the proper connect(TCP or SSL). Not possible. The first event in an SSL connection is a message from the client, not from the server.
2
1
0
I've wrote a simple client and a server. They both can configured to use SSL or not. You can set it up in the client and in the server. My problem is, if I try to connect without SSL to a server setup with SSL, the connection is made but stuck. (of course... it is normal). How my client can know that he is trying to co...
How to know if my server is using SSL or not (with Twisted)
0
0
1
623
6,925,150
2011-08-03T10:37:00.000
6
0
0
0
python,django,templates,variables
6,925,195
3
false
1
0
Because '0' (string) is not 0 (integer). '0' is non-zero-length string, which means it's True in a boolean context. If you store integers, you should be using IntegerField or PositiveIntegerField, not CharField.
2
0
0
I have template variables that correctly can be displayed with {{ myclass.myvariable }} as either 1 or 0. But when I use them in the if statement {% if myclass.myvariable %} they always are considered to be True, even when the value is 0. The variables are 1-character charfield choices in my model, stored as 0 or 1, ...
django template boolean variable shows as 0 but is considred True. Why?
1
0
0
2,159
6,925,150
2011-08-03T10:37:00.000
0
0
0
0
python,django,templates,variables
6,925,199
3
false
1
0
They are treated as strings ('0' string and '1' string, not 0 integer and 1 integer). If you go to your command-line Python and call bool(0) or bool(False), you will get False, but if you call bool('0'), you will get True.
2
0
0
I have template variables that correctly can be displayed with {{ myclass.myvariable }} as either 1 or 0. But when I use them in the if statement {% if myclass.myvariable %} they always are considered to be True, even when the value is 0. The variables are 1-character charfield choices in my model, stored as 0 or 1, ...
django template boolean variable shows as 0 but is considred True. Why?
0
0
0
2,159
6,928,110
2011-08-03T14:28:00.000
4
0
0
1
python,gcc,setuptools,setup.py,distutils
60,766,834
3
false
0
0
I ran into this problem when I needed to fully remove a flag (-pipe) so I could compile SciPy on a low-memory system. I found that, as a hack, I could remove unwanted flags by editing /usr/lib/pythonN.N/_sysconfigdata.py to remove every instance of that flag, where N.N is your Python version. There are a lot of duplica...
1
67
0
I understand that setup.py uses the same CFLAGS that were used to build Python. I have a single C extension of ours that is segfaulting. I need to build it without -O2 because -O2 is optimizing out some values and code so that the core files are not sufficient to pin down the problem. I just need to modify setup.py so ...
How may I override the compiler (GCC) flags that setup.py uses by default?
0.26052
0
0
35,921
6,928,566
2011-08-03T14:59:00.000
3
1
0
1
python,udev
6,930,448
2
false
0
0
With pyudev, each device object provides a dictionary-like interface for its attributes. You can list them all with device.keys(), e.g. UUID is for block devices is dev['ID_FS_UUID'].
1
0
0
I want get the mount node of an usb mass-storage device, like /media/its-uuid in pyudev, class Device has some general attributes, but not uuid or mount node. how to do it thanks help
how to get uuid of a device using udev
0.291313
0
0
2,348
6,929,517
2011-08-03T16:03:00.000
0
0
0
0
python,django,ria,openlaszlo
12,061,571
2
false
1
0
The OpenLaszlo platform supports communicating with any server that can receive HTTP POSTS (aka REST) from OpenLaszlo datasets and return an XML response. If your server meets those requirements then yes, you can use OpenLaszlo to create an OpenLaszlo front-end to communicate with your server back-end.
1
1
0
I am a medical professional not a developer.. so go easy guys.. :) I am trying to build a EMR (Electronic Medical Record) with Django. In fact I am already well into the project. I have done reasonable AJAX and jQuery integration with it. I was trying to improve the front end and came across OpenLaszlo as a Open Sour...
Can we intergrate an OpenLaszlo front end to a Django back end ?
0
0
0
259
6,930,144
2011-08-03T16:52:00.000
125
0
1
0
python
6,930,196
3
false
0
0
A single leading underscore is simply a convention that means, "You probably shouldn't use this." It doesn't do anything to stop someone from using the attribute. A double leading underscore actually changes the name of the attribute so that two classes in an inheritance hierarchy can use the same attribute name, and ...
2
144
0
Somebody was nice enough to explain to me that __method() mangles but instead of bothering him further since there are a lot of other people who need help I was wondering if somebody could elaborate the differences further. For example I don't need mangling but does _ stay private so somebody couldn't do instance._meth...
Underscore vs Double underscore with variables and methods
1
0
0
98,986
6,930,144
2011-08-03T16:52:00.000
11
0
1
0
python
6,930,197
3
false
0
0
There is no access control in Python. You can access all attributes of a class, and that includes mangled names (as _class__variable). Concentrate on your code and API instead of trying to protect developers from themselves.
2
144
0
Somebody was nice enough to explain to me that __method() mangles but instead of bothering him further since there are a lot of other people who need help I was wondering if somebody could elaborate the differences further. For example I don't need mangling but does _ stay private so somebody couldn't do instance._meth...
Underscore vs Double underscore with variables and methods
1
0
0
98,986
6,931,209
2011-08-03T18:16:00.000
16
0
0
0
python,scipy,kdtree
15,331,547
3
false
0
0
In a use case (5D nearest neighbor look ups in a KDTree with approximately 100K points) cKDTree is around 12x faster than KDTree.
1
42
1
What is the difference between these two algorithms?
Difference between scipy.spatial.KDTree and scipy.spatial.cKDTree
1
0
0
11,234
6,932,925
2011-08-03T20:32:00.000
0
0
1
1
python,linux,interpreter
6,932,977
4
false
0
0
The optimal solution to this dilemma is using distutils (setup.py, which creates correct stubs for you automatically, for a number of given "console entry points") and virtualenv (handling the "isolated multiple installations" part).
1
1
0
I have a problem which is caused by our encapsulated design. Up till now lots of our scripts were written in bash and as a result the #!/bin/bash was always simple. However now that we are rewriting our scripts in python that is a bit more difficult. We deliver a specific version of python (to avoid version differenc...
How to Identify the Python version in #! using environment variables
0
0
0
935
6,933,058
2011-08-03T20:44:00.000
0
1
1
0
c++,python,boost,boost-python
6,933,233
2
false
0
0
I have two unconventional recommendations for you: 1) Don't check. The Python culture is to simply use objects as you need to, and if it doesn't work, then an exception will occur. Checking ahead of time adds overhead, and potentially limits how people can use your code because you're checking more strictly than you ...
2
2
0
I'd like some advice on how to check for the correctness of the parameters I receive. The checking is going to be done in C++, so if there's a good solution using Boost.Python (preferably) or the C API, please tell me about that. Otherwise, tell me what attributes the object should have to ensure that it meets the crit...
Python: How to check that...?
0
0
0
400
6,933,058
2011-08-03T20:44:00.000
3
1
1
0
c++,python,boost,boost-python
6,933,216
2
true
0
0
When in doubt just work out how you would get the required effect by calling the usual Python builtins and translate it to C/C++. I'll just answer for Python, for C you would look up the global such as 'callable' and then call it like any other Python function. Why would you care about it being a function rather than ...
2
2
0
I'd like some advice on how to check for the correctness of the parameters I receive. The checking is going to be done in C++, so if there's a good solution using Boost.Python (preferably) or the C API, please tell me about that. Otherwise, tell me what attributes the object should have to ensure that it meets the crit...
Python: How to check that...?
1.2
0
0
400
6,934,202
2011-08-03T22:44:00.000
14
0
1
0
python,language-features
6,936,919
3
true
0
0
The purpose of interning things is to be able to compare them by comparing their memory address; you ensure that you never create two objects with the same value (when the program requests the creation of a second object with the same value as an existing object, it instead receives a reference to the pre-existing obje...
2
8
0
Why is Python's intern built-in only for strings? It should be possible to extend intern to classes that are hashable and comparable, right?
Python intern for non-strings
1.2
0
0
1,765
6,934,202
2011-08-03T22:44:00.000
1
0
1
0
python,language-features
6,934,368
3
false
0
0
There is no technical reason that, say, a tuple could not be interned, though I would imagine that in the real world this is of little value compared to string literals, and it would be of even less real-world value with user-defined types. Making it work is probably not considered worth the effort.
2
8
0
Why is Python's intern built-in only for strings? It should be possible to extend intern to classes that are hashable and comparable, right?
Python intern for non-strings
0.066568
0
0
1,765
6,934,681
2011-08-03T23:52:00.000
5
0
0
1
python,google-app-engine,database-cursor
6,935,512
5
true
1
0
If you mean "has this cursor hit the end of the search results", then no, not without picking the cursor up and trying it again. If more entities are added that match the original search criteria, such that they logically land "after" the cursor (e.g., a query that sorts by an ascending timestamp), then reusing that sa...
1
10
0
I apologize if I am missing something really obvious. I'm making successive calls to app engine using cursors. How do I tell if the I'm on the last cursor? The current way I'm doing it now is to save the last cursor and then testing to see if that cursor equals the currently returned cursor. This requires an extra c...
How do I tell if the returned cursor is the last cursor in App Engine
1.2
0
0
4,861
6,934,692
2011-08-03T23:54:00.000
1
0
1
0
python,macos,utf-8,utf-16
6,946,587
1
true
0
0
OK, when reading lines from a file, it's advisable to always strip() or rstrip() them. :)
1
1
0
I have a Localized.strings (UTF-16) file that contains some strings that I use to generate filenames for. I open the file in python with codecs.open("Localized.strings", "r", "utf-16") The files are created successfully but with a '?' tacked onto the end of the filename, for example: MainMenu.strings? - where the "?" ...
How can I convert a UTF-16 encoded string to an encoding suitable for a Mac OS X filename?
1.2
0
0
359
6,935,094
2011-08-04T01:05:00.000
0
1
0
0
php,python,django,web-frameworks,web2py
6,935,676
5
false
1
0
I've been using Django as part of my work for a couple years now and truly enjoy it when I can make it work. Unfortunately, and maybe it's just me, but I end up spending hours working on configuration every time I start a new server, or try to make it work in a development IDE. It's relatively simple to start a new pr...
3
4
0
I'm deciding on a web framework for an upcoming project, and I'd appreciate any advice. We've decided to use jQuery for the JavaScript, and are heavily leaning toward Python or PHP (more Python) for our server-side logic. I'm especially interested in web2py because of its jQuery integration. About our project Our proj...
What are the relative advantages of various Python/PHP web frameworks (particularly for my project)?
0
0
0
1,845
6,935,094
2011-08-04T01:05:00.000
1
1
0
0
php,python,django,web-frameworks,web2py
6,961,688
5
false
1
0
Python vs PHP: Python With python, you can always write wrappers for C code so you won't have to mess with starting other processes and passing args to them. That might be useful for your security functions. Web2py will allow you to easily write a webservice for this too, to more easily integrate the C portions with t...
3
4
0
I'm deciding on a web framework for an upcoming project, and I'd appreciate any advice. We've decided to use jQuery for the JavaScript, and are heavily leaning toward Python or PHP (more Python) for our server-side logic. I'm especially interested in web2py because of its jQuery integration. About our project Our proj...
What are the relative advantages of various Python/PHP web frameworks (particularly for my project)?
0.039979
0
0
1,845
6,935,094
2011-08-04T01:05:00.000
2
1
0
0
php,python,django,web-frameworks,web2py
6,935,412
5
true
1
0
Before deciding on a framework, you should first decide if you want to commit to a language you are unfamiliar with. You said you've both got minimal PHP experience, so you have to weigh up the advantages here; Will the pros for going PHP (if any) out weigh the amount of time the developers will need to spend to retrai...
3
4
0
I'm deciding on a web framework for an upcoming project, and I'd appreciate any advice. We've decided to use jQuery for the JavaScript, and are heavily leaning toward Python or PHP (more Python) for our server-side logic. I'm especially interested in web2py because of its jQuery integration. About our project Our proj...
What are the relative advantages of various Python/PHP web frameworks (particularly for my project)?
1.2
0
0
1,845
6,935,796
2011-08-04T03:14:00.000
0
0
0
0
python,windows,proxy
6,935,860
2
false
0
0
Cannot you set the HTTP_PROXY environment variable in Windows (either manually or within your program) for your application before sending the request? That should take care that any request you send it via urllib2 goes via Proxy.
1
3
0
I am new to Python and would like to write a script to change Windows proxy settings based on the network I am connected to. Is there any existing python module I can use? Appreciate your help. Thanks, Sethu
Which Python module to use to access the Proxy setting of Windows 7?
0
0
1
1,602
6,936,158
2011-08-04T04:24:00.000
2
0
1
0
python,multithreading,multiprocessing
6,936,355
1
true
0
0
Why would you use any module at all? This is simple to do by having two separate processes that start at the same time. The dataChecker would list all files in a directory, count them, and sleep for a short time (several seconds or more). Then it would do it again and if the number of files changes, it opens the new on...
1
3
0
Trying to think of the best way to code 2 processes that have to run in parallel. I not even sure if multiprocessing is the preferred module. I am generating a lot of data for a long period of time with a dataCollector, but I would like to check the data periodically with a dataChecker while the dataCollector keeps ru...
Python multiprocessing question
1.2
0
0
153
6,936,252
2011-08-04T04:37:00.000
1
1
0
0
python,django,email
6,937,662
3
false
1
0
You have no other way than generate confirm url in your message like most sites registrations do. If person would be glad to register on your website, he will certainly click confirm at his email client of any sort. Otherwise it's a spam/scam email. There is no way you can do it and know it's a live e-mail for sure... ...
2
1
0
I have a simple mail sending application which runs in python using Django. After sending an email is there a way to see if the recipient has opened it or is it still un-opened? if so how can i do it?
Checking the status of a sent email in django
0.066568
0
0
2,684
6,936,252
2011-08-04T04:37:00.000
3
1
0
0
python,django,email
6,936,289
3
false
1
0
You can try setting require return receipt flag on the email you are sending. But, a lot of people (I know I do) ignore that return receipt so you will never find out in those cases. If you are asking for a 100% certain method of finding out if the recipient read his/her email, then the straight answer is: NO, you can'...
2
1
0
I have a simple mail sending application which runs in python using Django. After sending an email is there a way to see if the recipient has opened it or is it still un-opened? if so how can i do it?
Checking the status of a sent email in django
0.197375
0
0
2,684
6,938,377
2011-08-04T08:32:00.000
1
0
0
0
python,arrays,numpy,scipy,rotation
6,938,587
2
false
0
0
Take a look at the command numpy.shape I used it once to transpose an array, but I don't know if it might fit your needs. Cheers!
2
1
1
I have some numpy/scipy issue. I have a 3D array that represent an ellipsoid in a binary way [ 0 out of the ellipsoid]. The thing is I would like to rotate my shape of a certain degree. Do you think it's possible ? Or is there an efficient way to write directly the ellipsoid equation with the rotation ?
How to rotate a numpy array?
0.099668
0
0
2,379
6,938,377
2011-08-04T08:32:00.000
2
0
0
0
python,arrays,numpy,scipy,rotation
6,941,191
2
false
0
0
Just a short answer. If you need more informations or you don't know how to do it, then I will edit this post and add a small example. The right way to rotate your matrix of data points is to do a matrix multiplication. Your rotation matrix would be probably an n*n-matrix and you have to multiply it with every point. ...
2
1
1
I have some numpy/scipy issue. I have a 3D array that represent an ellipsoid in a binary way [ 0 out of the ellipsoid]. The thing is I would like to rotate my shape of a certain degree. Do you think it's possible ? Or is there an efficient way to write directly the ellipsoid equation with the rotation ?
How to rotate a numpy array?
0.197375
0
0
2,379
6,939,351
2011-08-04T09:54:00.000
5
1
1
0
python,virtualenv,setuptools
6,939,437
1
true
0
0
You can use pip instead of easy_install, it supports a number of possible ways to specify where to get the package from, one being git, you could then install your package like this: pip install git://my.git-repo.com/my_project.git
1
1
0
I'm currently researching deployment techniques for our Python products. We manage our code with multiple git repositories already but want to improve the process of setting up and updating our servers. It seems that easy_install, .egg files and virtualenv are the best tools for doing this nowadays. Here's the catch: W...
Create Python .egg that installs from git repository
1.2
0
0
1,234
6,940,257
2011-08-04T11:03:00.000
0
0
0
1
python,django,eclipse,google-app-engine,pydev
6,940,884
2
false
1
0
As @MatToufotu suggested you start with the django integration document in the appengine documentation. I would say you should stick with eclipse and pydev, as django-nonrel project created are nothing but pure django project with support for appengine, pydev can handle both of them with ease........
1
3
0
We are new to the python world and would like to get started a s soon a possible and develop a little web app for app engine. We are using Eclipse + Google plugin + Pydev. We also would like to start using Django framework and we have two questions: 1. We are looking for a good tutorial which will put us on the right t...
Using Django with app engine and eclipse
0
0
0
1,025
6,941,231
2011-08-04T12:15:00.000
1
0
1
0
python,pdf,pypdf
6,941,309
1
false
0
0
Have a look at pdftk. It is a toolbox for working with pdf files. You can integrate it into python with the subprocess module.
1
2
0
I have one pdf file. I want to split that file into multiple pdf files by some specific word from that file. how can i do that in python ?
how to split pdf file into multiple pdf files by specific word?
0.197375
0
0
457
6,941,528
2011-08-04T12:37:00.000
3
0
0
1
java,python,google-app-engine,3d
6,978,267
1
true
1
0
App Engine doesn't currently support C modules on the Python runtime. As a result, any rendering code would have to be written entirely in Python, and would be very, very slow. You couldn't take advantage of a GPU, either, since the runtime doesn't supply one. Your best option, if you care at all about efficiency, is t...
1
2
0
Is it possible to render any kind of 3D images in Google App Engine (with Backends)? I'm looking for a Python solution, but I will learn Java if needed.
3D Rendering in Google App Engine
1.2
0
0
527
6,942,105
2011-08-04T13:16:00.000
0
0
0
0
python
7,056,331
2
true
0
0
I will go for the in memory solution and let the OS swap. I can still replace the storage component if this will be really a problem. Thanks agf.
1
0
0
I have lots of data to operate on (write, sort, read). This data can potentially be larger than the main memory and doesn't need to be stored permanently. Is there any kind of library/database that can store these data for me in memory and that does have and automagically fallback to disk if system runs in a OOM situat...
In memory database with fallback to disk on OOM
1.2
1
0
105
6,943,534
2011-08-04T14:47:00.000
0
0
1
0
python,xvfb,spynner
6,944,350
1
false
0
0
Have you tried setting the display as an environment variable? os.environ["DISPLAY"] = ":99"
1
0
0
I am developing an application on one of the servers of webfaction. I have a python class with two functions defined in it. Each function uses a spynner.Browser() object, which requires an X server running. I am running Xvfb for this purpose. Both functions run as expected on their owns. The problem arises when I try t...
Xvfb instance for multiple processes
0
0
0
1,717
6,943,593
2011-08-04T14:50:00.000
6
0
1
1
python
7,062,499
5
false
0
0
I have built several cross platform applications (Windows / OS X) with wxPython. Practically all of the code translates flawlessly across the two platforms. To put into context, I usually develop the applications on Mac OS side, and if I spend let's say one week hammering out an application, I spend something like a fe...
3
3
0
Can you make a universal python application that will run on both OSX and Windows? With the same menu system, etc? Or would you need to make different versions for each OS?
How to make a universal Python application
1
0
0
860
6,943,593
2011-08-04T14:50:00.000
0
0
1
1
python
7,902,377
5
false
0
0
I'm currently developing an app on my Ubuntu Linux machine. I real life it runs on a windows xp machine with touchpad. I'm using wxPython as the gui toolkit. In the past I've used .net predominantly but I wanted cross platform. It really runs without any checks about which os it is running on. (save one check where i r...
3
3
0
Can you make a universal python application that will run on both OSX and Windows? With the same menu system, etc? Or would you need to make different versions for each OS?
How to make a universal Python application
0
0
0
860
6,943,593
2011-08-04T14:50:00.000
3
0
1
1
python
6,943,765
5
false
0
0
Yes. You could build it with Qt for its interface and then you'll have to make judicious use of the os library to make sure that everything plays nicely no matter what operating system it's running on. However when it comes to packaging it for distribution, you'll have to do them separately. For Windows you can use py2...
3
3
0
Can you make a universal python application that will run on both OSX and Windows? With the same menu system, etc? Or would you need to make different versions for each OS?
How to make a universal Python application
0.119427
0
0
860
6,944,940
2011-08-04T16:19:00.000
0
0
1
0
python,multithreading,queue,non-volatile
7,006,094
5
false
0
0
The easy way to do this is to use AMQP for the message queues and let the message broker take care of the messages for you. I implemented a similar system using RabbitMQ as the message broker with durable persistent queues. The messages have even survived a crash of the RabbitMQ server software when I was using an outd...
2
2
0
I am using the Python Queue cclass to manage a list of tasks that are shared between multiple worker threads. The actual code is humungous and I'm still in the process of making it entirely bug free. Time to time, the worker threads will crash and I have to restart the whole routine. In the process I lose all the tasks...
Save python queue to a file
0
0
0
4,824
6,944,940
2011-08-04T16:19:00.000
0
0
1
0
python,multithreading,queue,non-volatile
7,326,560
5
false
0
0
Implement a handshaking mechanism between the worker and the master. The master has a list of tasks, before putting them inside a Queue, pickle the list to a file. Then insert the task into the Queue. When the worker is done, he sends back an ACK message. Only at that point unpickle the task list and delete the corresp...
2
2
0
I am using the Python Queue cclass to manage a list of tasks that are shared between multiple worker threads. The actual code is humungous and I'm still in the process of making it entirely bug free. Time to time, the worker threads will crash and I have to restart the whole routine. In the process I lose all the tasks...
Save python queue to a file
0
0
0
4,824
6,945,398
2011-08-04T16:52:00.000
5
0
1
0
python,search,repeat
6,945,426
5
false
0
0
Rather than searching your output file, keep a set of the numbers you've written, and only write numbers that are not in the set.
1
0
0
There's a text file that I'm reading line by line. It looks something like this: 3 3 67 46 67 3 46 Each time the program encounters a new number, it writes it to a text file. The way I'm thinking of doing this is writing the first number to the file, then looking at the second number and checking if it's already in the...
PYTHON how to search a text file for a number
0.197375
0
0
11,528
6,945,595
2011-08-04T17:07:00.000
0
0
0
1
python,google-app-engine,backend
7,364,170
2
false
1
0
If you configure your backend as a Dynamic backend, then the backend will stop automatically 15 minutes after your "trigger" request is processed. If you don't send that "trigger-to-start" request again in the next 15 minutes, the backend will shutdown automatically. Unfortunately, you'll still have to pay for a mini...
2
4
0
I have a backend that consumes a queue in its start handler. When the queue is exhausted the start handler will stop. I want the backend to stop when the start handler finishes. I have other code that will send a request to the backend if it adds an item to this queue. These requests merely serve to have GAE start ...
How to explicitly stop a Google App Engine dynamic backend when the start handler finishes?
0
0
0
1,017
6,945,595
2011-08-04T17:07:00.000
1
0
0
1
python,google-app-engine,backend
6,978,199
2
false
1
0
Backends can't (currently) be started and stopped programmatically. It sounds like what you want, though, is a regular task queue task, which behaves exactly as described.
2
4
0
I have a backend that consumes a queue in its start handler. When the queue is exhausted the start handler will stop. I want the backend to stop when the start handler finishes. I have other code that will send a request to the backend if it adds an item to this queue. These requests merely serve to have GAE start ...
How to explicitly stop a Google App Engine dynamic backend when the start handler finishes?
0.099668
0
0
1,017
6,945,953
2011-08-04T17:33:00.000
0
0
0
0
python,postgresql
15,492,291
1
false
0
0
The answer is "as well as one could possibly expect." Without seeing your tables, data, and queries, and the stats of your machine it is hard to be too specific. However in general updates basically doing three steps. This is a bit of an oversimplification but it allows you to estimate performance. First it selects t...
1
0
0
I have a database and csv file that gets updated once a day. I managed to updated my table1 from this file by creating a separate log file with the record of the last insert. No, I have to create a new table table2 where I keep calculations from the table1. My issue is that those calculations are based on 10, 20 and 9...
Table updates using daily data from other tables Postgres/Python
0
1
0
778
6,946,503
2011-08-04T18:16:00.000
1
0
0
1
python,wxpython,osx-lion
8,763,927
4
false
0
1
This may not work for python versions below 2.9. Running 'python' did not work for me...I am using 2.7 for compatibility. But figured out that 'python' may be an alias for a 64 bit mode and for some reason the arch command does not work. So, here is what I have to use under Lion to get wx to work (this works for 2.6 o...
1
8
0
I've just bought a new computer with Lion on it. I've downloaded and installed both Python 2.7 and wxPython 2.8 (for 2.7). I know Python comes with the system, but I rather go with the official one. Anyway, upon typing "import wx" on the IDLE, I get the following message: Traceback (most recent call last): File ""...
Run wxPython on Lion
0.049958
0
0
5,631
6,947,065
2011-08-04T18:59:00.000
2
0
1
1
python,windows,multithreading,timeout
6,948,842
9
false
0
0
For "normal" Python code, that doesn't linger prolongued times in C extensions or I/O waits, you can achieve your goal by setting a trace function with sys.settrace() that aborts the running code when the timeout is reached. Whether that is sufficient or not depends on how co-operating or malicious the code you run is....
3
32
0
I looked online and found some SO discussing and ActiveState recipes for running some code with a timeout. It looks there are some common approaches: Use thread that run the code, and join it with timeout. If timeout elapsed - kill the thread. This is not directly supported in Python (used private _Thread__stop functi...
right way to run some code with timeout in Python
0.044415
0
0
18,777
6,947,065
2011-08-04T18:59:00.000
0
0
1
1
python,windows,multithreading,timeout
7,036,901
9
false
0
0
If you're running code that you expect to die after a set time, then you should write it properly so that there aren't any negative effects on shutdown, no matter if its a thread or a subprocess. A command pattern with undo would be useful here. So, it really depends on what the thread is doing when you kill it. If its...
3
32
0
I looked online and found some SO discussing and ActiveState recipes for running some code with a timeout. It looks there are some common approaches: Use thread that run the code, and join it with timeout. If timeout elapsed - kill the thread. This is not directly supported in Python (used private _Thread__stop functi...
right way to run some code with timeout in Python
0
0
0
18,777
6,947,065
2011-08-04T18:59:00.000
10
0
1
1
python,windows,multithreading,timeout
7,027,923
9
true
0
0
A completely general solution to this really, honestly does not exist. You have to use the right solution for a given domain. If you want timeouts for code you fully control, you have to write it to cooperate. Such code has to be able to break up into little chunks in some way, as in an event-driven system. You can al...
3
32
0
I looked online and found some SO discussing and ActiveState recipes for running some code with a timeout. It looks there are some common approaches: Use thread that run the code, and join it with timeout. If timeout elapsed - kill the thread. This is not directly supported in Python (used private _Thread__stop functi...
right way to run some code with timeout in Python
1.2
0
0
18,777
6,948,383
2011-08-04T20:54:00.000
16
0
1
0
python,collections,language-design,zen-of-python
6,948,527
8
true
0
0
These data types all serve different purposes, and in an ideal world you might be able to unify them more. However, in the real world we need to have efficient implementations of the basic collections, and e.g. ordering adds a runtime penalty. The named tuples mainly serve to make the interface of stat() and the like m...
7
23
0
One of the reasons I love Python is the expressive power / reduced programming effort provided by tuples, lists, sets and dictionaries. Once you understand list comprehensions and a few of the basic patterns using in and for, life gets so much better! Python rocks. However I do wonder why these constructs are treated...
Why does Python treat tuples, lists, sets and dictionaries as fundamentally different things?
1.2
0
0
5,194
6,948,383
2011-08-04T20:54:00.000
1
0
1
0
python,collections,language-design,zen-of-python
6,948,464
8
false
0
0
A dictionary is indexed by key (in fact, it's a hash map); a generic list of tuples won't be. You might argue that both should be implemented as relations, with the ability to add indices at will, but in practice having optimized types for the common use cases is both more convenient and more efficient. New specialized...
7
23
0
One of the reasons I love Python is the expressive power / reduced programming effort provided by tuples, lists, sets and dictionaries. Once you understand list comprehensions and a few of the basic patterns using in and for, life gets so much better! Python rocks. However I do wonder why these constructs are treated...
Why does Python treat tuples, lists, sets and dictionaries as fundamentally different things?
0.024995
0
0
5,194
6,948,383
2011-08-04T20:54:00.000
1
0
1
0
python,collections,language-design,zen-of-python
6,948,518
8
false
0
0
All of these specialized collection types provide specific functionalities that are not adequately or efficiently provided by the "standard" data types of list, tuple, dict, and set. For example, sometimes you need a collection of unique items, and you also need to retain the order in which you encountered them. You c...
7
23
0
One of the reasons I love Python is the expressive power / reduced programming effort provided by tuples, lists, sets and dictionaries. Once you understand list comprehensions and a few of the basic patterns using in and for, life gets so much better! Python rocks. However I do wonder why these constructs are treated...
Why does Python treat tuples, lists, sets and dictionaries as fundamentally different things?
0.024995
0
0
5,194
6,948,383
2011-08-04T20:54:00.000
0
0
1
0
python,collections,language-design,zen-of-python
6,948,506
8
false
0
0
One of the things I like in Python the most is agility. And a lot of functional, effective and usable collections types gives it to me. And there is still one way to do this - each type does its own job.
7
23
0
One of the reasons I love Python is the expressive power / reduced programming effort provided by tuples, lists, sets and dictionaries. Once you understand list comprehensions and a few of the basic patterns using in and for, life gets so much better! Python rocks. However I do wonder why these constructs are treated...
Why does Python treat tuples, lists, sets and dictionaries as fundamentally different things?
0
0
0
5,194
6,948,383
2011-08-04T20:54:00.000
2
0
1
0
python,collections,language-design,zen-of-python
6,948,581
8
false
0
0
First of all, Ordered Dictionaries and Named Tuples were introduced in Python 2, but that's beside the point. I won't point you at the docs since if you were really interested you would have read them already. The first difference between collection types is mutability. tuple and frozenset are immutable types. This mea...
7
23
0
One of the reasons I love Python is the expressive power / reduced programming effort provided by tuples, lists, sets and dictionaries. Once you understand list comprehensions and a few of the basic patterns using in and for, life gets so much better! Python rocks. However I do wonder why these constructs are treated...
Why does Python treat tuples, lists, sets and dictionaries as fundamentally different things?
0.049958
0
0
5,194
6,948,383
2011-08-04T20:54:00.000
0
0
1
0
python,collections,language-design,zen-of-python
6,948,651
8
false
0
0
The Zen of Python says "There should be one-- and preferably only one --obvious way to do it". It seems to me this profusion of specialized collections types is in conflict with this Python precept. Not remotely. There are several different things being done here. We choose the right tool for the job. All of these con...
7
23
0
One of the reasons I love Python is the expressive power / reduced programming effort provided by tuples, lists, sets and dictionaries. Once you understand list comprehensions and a few of the basic patterns using in and for, life gets so much better! Python rocks. However I do wonder why these constructs are treated...
Why does Python treat tuples, lists, sets and dictionaries as fundamentally different things?
0
0
0
5,194
6,948,383
2011-08-04T20:54:00.000
0
0
1
0
python,collections,language-design,zen-of-python
6,948,528
8
false
0
0
The world of data structures (language agnostic) can generally be boiled down to a few small basic structures - lists, trees, hash-tables and graphs, etc. and variants and combinations thereof. Each has its own specific purpose in terms of use and implementation. I don't think that you can do things like reduce a dict...
7
23
0
One of the reasons I love Python is the expressive power / reduced programming effort provided by tuples, lists, sets and dictionaries. Once you understand list comprehensions and a few of the basic patterns using in and for, life gets so much better! Python rocks. However I do wonder why these constructs are treated...
Why does Python treat tuples, lists, sets and dictionaries as fundamentally different things?
0
0
0
5,194
6,948,483
2011-08-04T21:03:00.000
6
0
0
0
python,scala,numpy,simulation,scientific-computing
6,948,576
4
false
0
0
I believe that most highly performant MD codes are written in native languages like Fortran, C or C++. Modern GPU programming techniques are also finding favour more recently. A language like Python would allow for much more rapid development that native code. The flip side of that is that the performance is typically ...
1
4
1
I need to build a heavy duty molecular dynamics simulator. I am wondering if python+numpy is a good choice. This will be used in production, so I wanted to start with a good language. I am wondering if I should rather start with a functional language like eg.scala. Do we have enough library support for scientific compu...
Best language for Molecular Dynamics Simulator, to be run in production. (Python+Numpy?)
1
0
0
2,217
6,949,915
2011-08-04T23:44:00.000
1
1
1
1
java,python,windows,perl,installation
6,950,147
2
false
0
0
Why don't you try migrating your perl/python code into java and then packagin everything into a nice webstart application? What do perl/python offer that java doesn't support? For perl you can use something like perl2exe and for python py2exe so you can have 2 exes (which would include all the necessary interpreter bit...
1
1
0
I have several scripts written in perl, python, and java (wrapped under java GUI with system calls to perl & python). And I have many not-tech-savy users that need to use this in their windows machines (xp & 7). To avoid users from installing perl,python,and java and to avoid potential incompatibility between various ...
Package them all! Perl, python, java for naive users (in windows)
0.099668
0
0
168
6,952,987
2011-08-05T07:39:00.000
1
0
1
1
python,windows,scons
6,953,895
1
true
0
0
Try to set PYTHONHOME and PYTHONPATH in the scons.bat scripts to the right values for each Python installation respectively.
1
0
0
I have installed two different python versions (3.1 and 2,7) And this is now causing a headache. The default installation is the 3.1 which have the PYTHONHOME and PYTHONPATH set. Problem is that when I try to run scons from the 2.7 installation (via Python27/Scripts/scons.bat) I get various import errors that reference...
Running Scons with two Python installations on Windows
1.2
0
0
1,657
6,953,132
2011-08-05T07:53:00.000
0
0
0
0
python,django,filesystems
6,953,764
1
false
1
0
Use the file:// protocol instead of http:// in your links.
1
0
0
What I want to achieve is a bit complicated to explain, so I hope I'll be clear enough ! I'm starting to write a Django application for my company. It is installed on a local server which has access to some disks, that the users have access to also. I want to be able to list some files on these disks and when a user cl...
Open file from specific disk
0
0
0
171
6,953,370
2011-08-05T08:18:00.000
3
1
1
0
python,internationalization,plone,zope
6,956,931
3
false
0
0
be aware that _() does not translate the text at call, but returns a Message object which will be translated when rendered in a template. That means: do not concat Message objects. "text %s" % _('translation') will not work, as well as "text" + _('translation') if you do not send the text to the browser through a temp...
1
2
0
I'm trying to get certain strings in a .py file translated, using the i18n machinery. Translating .pt files is not a problem, but whenever I try to translate using _('Something') in Python code on the filesystem, it always gives English text (which is the default) instead of the Norwegian text that should be there. S...
Translating content in filesystem for a Plone product
0.197375
0
0
190
6,953,930
2011-08-05T09:08:00.000
2
0
0
0
python,django,model-view-controller
6,954,395
1
true
1
0
I suggest separating your logic in the following way: Implement the logic belonging to what your application is doing under the hood in your Django handlers. It usually covers most of your logic. Implement only the logic belonging to the actual presentation in your HTML templates. For example you can put you logic sel...
1
0
0
I'm starting to learn Django and I'm completely new to the MVC/MTV (whatever you want to call it) playground. In Django templates can perform logical conditions and filters. I want to know from a performance standpoint, is it better to do the conditions in the view or on the template itself. I actually find my self mo...
Is it better to perform logical conditions in view or template?
1.2
0
0
81
6,956,690
2011-08-05T13:01:00.000
5
0
1
0
python,dry,pythonpath
6,956,852
4
false
0
0
Of your three options, PYTHONPATH is the way to go. Copy & paste is clearly out, and adding code to your other projects to modify sys.path simply pollutes those files with knowledge about their environment. A fourth option is, create a true installable package from your common code, and install it into your Python ins...
1
33
0
I have write a python library app(which contains several *.py files). And several of my python projects need to reuse the code in the library app. What's the recommended best practice for reusing python code? Currently I have thought out three options: Copy and paste. This is far away from best practice. It violates t...
Best practice for reusing python code
0.244919
0
0
7,994
6,957,355
2011-08-05T13:48:00.000
0
0
1
0
python
6,957,382
2
false
0
0
It depends completely on what type of data you have in XML, what kinds of processing you'll need to do with it, what sort of output you'll need to produce from it, etc.
1
1
0
Maybe a silly question, but I usually learn a lot with those. :) I'm working on a software that deals a lot with XML, both as input and as output, and in between a lot of processing occurs. My first thought was to use internally a dict as a internal data structure, and from there, work my way with a process of reading...
Ideal Data Structure to Deal with XML Data
0
0
1
95
6,957,484
2011-08-05T13:58:00.000
0
0
1
0
python
46,186,478
3
false
0
0
An IDE for Python, called ERIC used to have this very functionality
1
19
0
Is there tool out there which can be used to graphically represent the structure of a python module? I'm thinking that a graph of sub-modules and classes connected by arrows representing imports.
Visualize the structure of a Python module
0
0
0
5,351
6,959,310
2011-08-05T16:10:00.000
2
1
1
0
python,python-module
6,959,402
1
true
0
0
You don't need a tool to create a python module, any filename ending in .py is sufficient. A package, which is a collection of modules, is similarly created by the presence of a file named __init__.py in the same folder as other modules (and possibly other packages). The __init__.py file can be empty or not, your cho...
1
0
0
I'm newbie to python and it's philosophy. I'm trying to develop a module on github. Is there any Ruby's gem generator like tool for developing module? How to develop a module? Thank you for any advise.
Python module generator for github
1.2
0
0
445
6,961,099
2011-08-05T18:39:00.000
91
1
1
0
python,unit-testing
6,961,157
3
true
0
0
I believe that you don't have to do anything. Your helper methods should just not start with test_.
2
62
0
Ok, as Google search isn't helping me in a while (even when using the correct keywords). I have a class extending from TestCase in which I want to have some auxiliary methods that are not going to be executed as part of the test, they'll be used to generate some mocked objects, etc, auxiliary things for almost any test...
Non-test methods in a Python TestCase
1.2
0
0
18,227
6,961,099
2011-08-05T18:39:00.000
3
1
1
0
python,unit-testing
6,961,191
3
false
0
0
The test runner will only directly execute methods beginning with test, so just make sure your helper methods' names don't begin with test.
2
62
0
Ok, as Google search isn't helping me in a while (even when using the correct keywords). I have a class extending from TestCase in which I want to have some auxiliary methods that are not going to be executed as part of the test, they'll be used to generate some mocked objects, etc, auxiliary things for almost any test...
Non-test methods in a Python TestCase
0.197375
0
0
18,227
6,964,595
2011-08-06T03:42:00.000
0
0
1
0
python,visual-studio,ide,editor
6,964,672
5
false
0
0
Alright, I found Wing, PyDev have the two features!
3
2
0
I am searching for a Python IDE with visual studio features. After going through similar questions and reading reviews, I hardly see the following two features mentioned: goto definition - e.g. go from the place where a method is called to its definition (perhaps the class is in another module). find all references - ...
Which Python IDE has visual studio features?
0
0
0
2,893
6,964,595
2011-08-06T03:42:00.000
0
0
1
0
python,visual-studio,ide,editor
16,174,341
5
false
0
0
support PyCharm , very good IDE for python!
3
2
0
I am searching for a Python IDE with visual studio features. After going through similar questions and reading reviews, I hardly see the following two features mentioned: goto definition - e.g. go from the place where a method is called to its definition (perhaps the class is in another module). find all references - ...
Which Python IDE has visual studio features?
0
0
0
2,893
6,964,595
2011-08-06T03:42:00.000
3
0
1
0
python,visual-studio,ide,editor
6,965,661
5
false
0
0
Eclipse with PyDev is outstanding. (It's also portable across platforms, as an added bonus. And free. And widely-used.)
3
2
0
I am searching for a Python IDE with visual studio features. After going through similar questions and reading reviews, I hardly see the following two features mentioned: goto definition - e.g. go from the place where a method is called to its definition (perhaps the class is in another module). find all references - ...
Which Python IDE has visual studio features?
0.119427
0
0
2,893
6,965,431
2011-08-06T07:30:00.000
1
0
0
1
python,google-app-engine,task-queue
8,681,117
3
false
1
0
These APIS work only for GAE server since the queues can be created only via queue.yaml and infact API does not expose any API for inserting queue and tasks or project.
1
2
0
I'm attempting to use GAE TaskQueue's REST API to pull tasks from a queue to an external server (a server not on GAE). Is there a library that does this for me? The API is simple enough, so I just need to figure out authentication. I examined the request sent by gtaskqueue_sample from google-api-python-client using --...
GAE TaskQueue: Sample code for accessing pull queue from outside App Engine?
0.066568
0
0
1,520
6,967,076
2011-08-06T13:22:00.000
0
0
1
0
python,class,private
68,909,648
2
false
0
0
Here’s a way to declare private variables: overload the __setattr__ (and other many methods about attributes) method, in the method, you can check current executing method is in the own class. If it is true, let it pass. Otherwise, you can raise an exception, or you can use your own customize error handle logic. (Tips:...
1
1
0
When trying to access __variables from a class, the parser assumes the 2 underscores are private relative to the current class. Notice how an unrelated function gets a "private" variable. Is this a bug? >>> def f(): pass ... >>> class A: ... def g(self): ... f.__x = 1 ... def h(): ... ...
Python private class variables that aren't class variables
0
0
0
514
6,967,166
2011-08-06T13:37:00.000
3
1
1
0
python,import
6,967,383
4
false
0
0
The performance will be same either way. The entire module is compiled, if needed, and the code executed, the first time you import a module, no matter how you import it.
1
1
0
Well, this query struck my mind when someone pointed out to me that importing a package using import package gives more code readability. Is this actually true? I mean when using this statement as compared to from package import x, y, z, isn't there any overhead of importing the entire package?
Python "import" performance query
0.148885
0
0
557
6,969,820
2011-08-07T00:05:00.000
8
0
1
0
python,sqlite,multiprocessing
12,809,817
4
false
0
0
I've actually just been working on something very similar: multiple processes (for me a processing pool of 4 to 32 workers) each process worker does some stuff that includes getting information from the web (a call to the Alchemy API for mine) each process opens its own sqlite3 connection, all to a single file, and e...
1
8
0
I noticed that sqlite3 isn´t really capable nor reliable when i use it inside a multiprocessing enviroment. Each process tries to write some data into the same database, so that a connection is used by multiple threads. I tried it with the check_same_thread=False option, but the number of insertions is pretty random: S...
SQLite3 and Multiprocessing
1
1
0
20,258
6,969,951
2011-08-07T00:39:00.000
0
1
1
0
python,linux
6,969,990
2
false
0
0
A .so file (.pyd on Windows) is a module which was written in C. It's compiled for, and tied to, a specific version of Python, in this case Python 2.4.x. If you want it to work with a different version of Python, you'll need to re-compile the original source code for that version.
2
0
0
I am having a python .so file which works fine with python v2.4.3 , but I dont have the source code of that library file. Now It fails to work in python 2.6.5. Is it possible to open the .so file and recompile it in python 2.6.5 ?? I dont know whether it is possible, I am just curious . Thanks ! The error I get Trac...
Finding out what is inside a python library file
0
0
0
152
6,969,951
2011-08-07T00:39:00.000
0
1
1
0
python,linux
6,969,991
2
true
0
0
Extension modules need to be compiled for a specific version of Python. Without the source code, no, you can't use it for a different version.
2
0
0
I am having a python .so file which works fine with python v2.4.3 , but I dont have the source code of that library file. Now It fails to work in python 2.6.5. Is it possible to open the .so file and recompile it in python 2.6.5 ?? I dont know whether it is possible, I am just curious . Thanks ! The error I get Trac...
Finding out what is inside a python library file
1.2
0
0
152