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
3,184,089
2010-07-06T06:50:00.000
0
0
1
0
python,tuples,coupling
3,184,127
3
false
0
0
In those cases, I tend to use dictionaries. If only to have things easily understandable for myself when I come back a bit later to use the code. I don't know if it's a "huge overhead". I guess it depends on how often you do it and what it is used for. I start off with the easiest solution and optimize when I really ...
1
1
0
I have a small Python program consisting of very few modules (about 4 or so). The main module creates a list of tuples, thereby representing a number of records. These tuples are available to the other modules through a simple function that returns them (say, get_records()). I am not sure if this is good design howev...
Is it OK to exchange tuples between Python modules?
0
0
0
245
3,184,821
2010-07-06T08:57:00.000
1
0
1
0
python,png,palette,color-palette
3,184,867
2
false
0
0
If it's a palletted image then you can use the getcolors() method once you have loaded it into PIL. If it's a RGB or RGBA image then you'll need to do color reduction until you have 256 colors at most.
1
2
0
What would be the best python based library for generating 8-bit palette from the given .png file. As in photoshop generating under .pal format. PS: Input PNG is already in 8 bit format. (paletted) Regards
Generation of 8 bit palette from png file via Python
0.099668
0
0
1,898
3,184,974
2010-07-06T09:20:00.000
1
1
0
1
python,ssh,exit,signals
3,186,685
1
false
0
0
Well, the reason they're not shutting down when your ssh session terminates is because HUP is the signal used by a parent to inform its children that they should shut down. If you're overriding the behavior of this signal, then your processes will not automatically shut down when the SSH session is closed. As for why y...
1
0
0
I've written a python script which does some curses and pysqlite stuff, but I've noticed that in occasions where I've been running this script over ssh when that ssh session is killed for whatever reason the python script doesn't actually exit, instead it ends up as being a child of init and just stays there forever. I...
Python scripts (curses + pysqlite) hanging after parent shell goes away
0.197375
0
0
281
3,185,263
2010-07-06T10:05:00.000
2
0
0
1
python,linux
3,185,279
3
true
0
0
Add a signal handler for SIGHUP. (x)inetd sends this upon the socket disconnecting.
2
0
0
This may or may not being a coding issue. It may also be an xinetd deamon issue, i do not know. I have a python script which is triggered from a linux server running xinetd. Xinetd has been setup to only allow one instance as I only want one machine to be able to connect to the service, which is therefore also limited ...
python xinetd client disconnection handling
1.2
0
0
864
3,185,263
2010-07-06T10:05:00.000
0
0
0
1
python,linux
7,097,401
3
false
0
0
Monitor the signals sent to your proccess. Maybe your script isn't responding to the SIGHUP sent by xinet, monitor the signal and let it die.
2
0
0
This may or may not being a coding issue. It may also be an xinetd deamon issue, i do not know. I have a python script which is triggered from a linux server running xinetd. Xinetd has been setup to only allow one instance as I only want one machine to be able to connect to the service, which is therefore also limited ...
python xinetd client disconnection handling
0
0
0
864
3,186,576
2010-07-06T13:28:00.000
1
0
0
0
python,pyqt4
3,187,108
1
true
0
1
i finally found out how. there's a signal call anchorClicked(QUrl) that should do the trick :)
1
0
0
is it possible to connect a href link in QTextBrowser to a slot? I want to make something that looks like a link in a QTextBrowser, but when user clicked on it, it will call one of the methods. Is that possible? if that is not, what is a good alternative? Thanks in advance.
is it possible to connect a href link in QTextBrowser to a slot?
1.2
0
0
198
3,187,301
2010-07-06T14:49:00.000
3
0
0
1
python,perl,bash
3,187,323
3
true
0
0
Just do python /path/to/my/python/script.py.
1
0
0
I previously used to copy Python/Perl scripts to access from my bash script. Duplication is not a good idea I know! Is there a way to call them from bin or libs folder that we have set up? For instance : My python script resides in /home/ThinkCode/libs/python/script.py My bash script resides in /home/ThinkCode/NewPro...
How do I call a Python/Perl script in bin folder from a Bash script?
1.2
0
0
1,145
3,188,024
2010-07-06T16:07:00.000
1
0
1
0
python,regex
3,188,036
3
false
0
0
I personally use your first approach where the expressions I'll reuse are compiled early on and available globally to the functions / methods that will need them. In my experience this is reliable, and reduces total compile time for them.
1
2
0
Is there a Pythonic 'standard' for how regular expressions should be used? What I typically do is perform a bunch of re.compile statements at the top of my module and store the objects in global variables... then later on use them within my functions and classes. I could define the regexs within the functions I would b...
Python regular expression style
0.066568
0
0
266
3,188,274
2010-07-06T16:38:00.000
1
0
0
1
python,django,google-app-engine
3,192,350
1
true
1
0
You probably are still going to hit the DB once to get the session record, which is where the user_id field is stored. Then you may need to side-step the lazy evaluation done in the django.contrib.auth.middleware code. It's not difficult, but you need to read the code and find exactly the info you want and then get at ...
1
1
0
I'm using Django on GAE. When I say user = request.user, I believe it hits the datastore to fetch the User entity. I would like to just get the key for the currently logged in user, because that will allow me to get the user-related data I need from the memcache.
Get the key of logged-in user with no DB access in Django on Google App Engine?
1.2
0
0
64
3,188,289
2010-07-06T16:39:00.000
0
0
0
0
python,mysql,performance
3,188,555
1
false
0
0
Two ideas: MySQL may have query caching enabled, which makes it difficult to get accurate timing when you run the same query repeatedly. Try changing the ID in your query to make sure that it really does run in 3-4 seconds consistently. Try using strace on the python process to see what it is doing during this time.
1
0
0
I'm writing a script for exporting some data. Some details about the environment: The project is Django based I'm using raw/custom SQL for the export The database engine is MySQL. The database and code are on the same box.- Details about the SQL: A bunch of inner joins A bunch of columns selected, some with a basic ...
Python MySQL Performance: Runs fast in mysql command line, but slow with cursor.execute
0
1
0
705
3,189,138
2010-07-06T18:34:00.000
3
1
0
0
python,firewall
3,189,187
6
false
0
0
I'm sure it's probably possible, but ill-advised. As mcandre mentions, most OSes couple the low level networking capabilities you need for a firewall tightly into the kernel and thus this task is usually done in C/C++ and integrates tightly with the kernel. The microkernel OSes (Mach et al) might be more amenable tha...
4
13
0
Is it possible to write a firewall in python? Say it would block all traffic?
Is it possible to write a firewall in python?
0.099668
0
1
31,230
3,189,138
2010-07-06T18:34:00.000
2
1
0
0
python,firewall
3,189,232
6
false
0
0
"Yes" - that's usually the answer to "is it possible...?" questions. How difficult and specific implementations are something else entirely. I suppose technically in a don't do this sort of way, if you were hell-bent on making a quick firewall in Python, you could use the socket libraries and open connections to and fr...
4
13
0
Is it possible to write a firewall in python? Say it would block all traffic?
Is it possible to write a firewall in python?
0.066568
0
1
31,230
3,189,138
2010-07-06T18:34:00.000
4
1
0
0
python,firewall
3,189,540
6
false
0
0
I'm sure in theory you could achieve what you want, but I believe in practice your idea is not doable (if you wonder why, it's because it's too hard to "interface" a high level language with the low level kernel). What you could do instead is some Python tool that controls the firewall of the operating system so you co...
4
13
0
Is it possible to write a firewall in python? Say it would block all traffic?
Is it possible to write a firewall in python?
0.132549
0
1
31,230
3,189,138
2010-07-06T18:34:00.000
3
1
0
0
python,firewall
15,045,900
6
false
0
0
Interesting thread. I stumbled on it looking for Python NFQUEUE examples. My take is you could create a great firewall in python and use the kernel. E.g. Add a linux fw rule through IP tables that forward sys packets (the first) to NFQUEUE for python FW to decide what to do. If you like it mark the tcp stream/flow wit...
4
13
0
Is it possible to write a firewall in python? Say it would block all traffic?
Is it possible to write a firewall in python?
0.099668
0
1
31,230
3,189,206
2010-07-06T18:42:00.000
4
0
1
0
python
3,189,234
6
true
0
0
It depends on your operating system. If you have python 2.6 installed, you need to change your environment path to point to the 2.6 executable rather than the 2.5 executable. Do a Google search for changing your PATH variable on your operating system.
2
7
0
New to Python and programming in general. I want to "install" a module from the command line for v 2.6, but it looks like my default Python is 2.5. (python --version returns 2.5.4) How can I run my python setup.py build/install on 2.6 instead? Many thanks in advance, Brock
Windows Command Line Python Change Version
1.2
0
0
28,100
3,189,206
2010-07-06T18:42:00.000
-3
0
1
0
python
3,189,210
6
false
0
0
Download Python v2.6.
2
7
0
New to Python and programming in general. I want to "install" a module from the command line for v 2.6, but it looks like my default Python is 2.5. (python --version returns 2.5.4) How can I run my python setup.py build/install on 2.6 instead? Many thanks in advance, Brock
Windows Command Line Python Change Version
-0.099668
0
0
28,100
3,190,013
2010-07-06T20:35:00.000
0
1
0
0
python
3,190,568
3
false
0
1
Portability is one thing. There are even differences between python 2.x and 3.x that can make things difficult with C extensions, if the writer didn't update them. Another thing is that pure python code gives you a bit more possibilities to read, understand and even modify (although it is usually a bad sign if you need...
3
1
0
Are there any downsides in Python to using a library that is just a binding to a C library? Does that hurt the portability of your application? Anything else I should look out for?
What are the pros and cons in Python of using a c library vs a native python one
0
0
0
146
3,190,013
2010-07-06T20:35:00.000
4
1
0
0
python
3,190,053
3
false
0
1
C library is likely to have better performance, but needs to be recompiled for each platform. You can't use C libraries on Google App Engine
3
1
0
Are there any downsides in Python to using a library that is just a binding to a C library? Does that hurt the portability of your application? Anything else I should look out for?
What are the pros and cons in Python of using a c library vs a native python one
0.26052
0
0
146
3,190,013
2010-07-06T20:35:00.000
4
1
0
0
python
3,190,035
3
true
0
1
Of course using a C library hurts portability. It also prohibites you (in general) to use Jython or IronPython. I would only use a C library if I had no other option. This could happen if direct access to hardware is necessary or if special efficiency requirements apply.
3
1
0
Are there any downsides in Python to using a library that is just a binding to a C library? Does that hurt the portability of your application? Anything else I should look out for?
What are the pros and cons in Python of using a c library vs a native python one
1.2
0
0
146
3,190,122
2010-07-06T20:51:00.000
1
0
1
0
python,string,list,range,ascii
3,190,229
18
false
0
0
This is your 2nd question: string.lowercase[ord('a')-97:ord('n')-97:2] because 97==ord('a') -- if you want to learn a bit you should figure out the rest yourself ;-)
1
142
0
1. Print a-n: a b c d e f g h i j k l m n 2. Every second in a-n: a c e g i k m 3. Append a-n to index of urls{hello.com/, hej.com/, ..., hallo.com/}: hello.com/a hej.com/b ... hallo.com/n
Python: how to print range a-z?
0.011111
0
0
323,159
3,190,226
2010-07-06T21:04:00.000
1
0
1
1
python,windows
3,551,199
1
false
0
0
This is a very complex task. I woudl look at open-source forensic tools. You also should analyze the recylcing bin ( not completly deleted file ) For FAT you will not be able to get the first character of a deleted file. For some deleted files the metadata will be gone. NTFS is much more complex and time consuming due...
1
0
0
I am wondering if it is possible to compile a list of deleted files on a windows file system, FAT or NTFS. I do not need to actually recover the files, only have access to their name and any other accessible time (time deleted, created etc). Even if I can run a cmd line tool to achieve this it would be acceptable. The...
How to show list of deleted files in windows file system
0.197375
0
0
1,086
3,192,001
2010-07-07T04:51:00.000
0
0
1
0
python,zip,tar,lzma
44,927,799
2
false
0
0
if you can use python 3.3 and later, you could use the built-in lzma module
1
1
0
i need to create a lzma file with the existing .tar file and another metadata file to further create a zip file.
create a lzma file in python
0
0
0
1,411
3,192,747
2010-07-07T07:36:00.000
0
0
0
0
python,validation,formencode,wtforms,toscawidgets
3,219,559
5
false
1
0
it depends on what underlying framework you use. for django , built in form framework is best, while kay uses extended version of zine's form system and tipfy uses WTForms. django's built in system is best so far . what framework do you use under the hood ?
1
38
0
I would like a form validation library that 1.separate html generation from form validation; 2.validation errors can be easily serialized, eg. dumped as a json object What form validation library would you choose in a python web project?
Recommendation for python form validation library
0
0
0
21,514
3,193,012
2010-07-07T08:18:00.000
13
1
1
1
python,programming-languages,scripting,lua,dynamic-languages
3,193,910
7
false
0
0
Both Lua and Python can provide the features you mention, so choosing one of them will depend on other criteria. Lua is a lighter weight solution, it will have a much smaller disk footprint and likely a smaller memory overhead than Python too. For some uses it may be faster. Python has a much richer standard library, m...
3
7
0
I am looking for a good scripting language to link to my program. I am looking for 2 important attributes: Scripting language should be hard linked into the executable (not requiring 3rd party installations). This is important to me to simplify distribution. Scripting should allow some run-time debugging option (When...
Scripting Languages
1
0
0
932
3,193,012
2010-07-07T08:18:00.000
0
1
1
1
python,programming-languages,scripting,lua,dynamic-languages
3,217,793
7
false
0
0
I'll add Tcl to the mix. It's designed to be easily embedded into other programs.
3
7
0
I am looking for a good scripting language to link to my program. I am looking for 2 important attributes: Scripting language should be hard linked into the executable (not requiring 3rd party installations). This is important to me to simplify distribution. Scripting should allow some run-time debugging option (When...
Scripting Languages
0
0
0
932
3,193,012
2010-07-07T08:18:00.000
1
1
1
1
python,programming-languages,scripting,lua,dynamic-languages
3,195,618
7
false
0
0
I really like Lua for embedding, but just as another alternative, JavaScript is easily embeddable in C, C++ (SpiderMonkey and V8) and Java (Rhino) programs.
3
7
0
I am looking for a good scripting language to link to my program. I am looking for 2 important attributes: Scripting language should be hard linked into the executable (not requiring 3rd party installations). This is important to me to simplify distribution. Scripting should allow some run-time debugging option (When...
Scripting Languages
0.028564
0
0
932
3,193,346
2010-07-07T09:08:00.000
0
0
0
1
python,django,nginx,wsgi,uwsgi
28,769,075
3
false
1
0
I will go with supervisord for managing the starting, stoping process.
1
6
0
I am leaning towards uwsgi+nginx for my Django app, can anyone share the best method for starting up my uwsgi processes? Does anyone have experience tuning uwsgi?
uwsgi + django via Nginx - uwsgi settings/spawn?
0
0
0
3,116
3,193,756
2010-07-07T10:07:00.000
2
0
0
0
python,machine-learning,adaboost
3,207,845
2
true
0
0
Thanks a million Steve! In fact, your suggestion had some compatibility issues with MacOSX (a particular library was incompatible with the system) BUT it helped me find out a more interesting package : icsi.boost.macosx. I am just denoting that in case any Mac-eter finds it interesting! Thank you again! Tim
1
5
1
Is there anyone that has some ideas on how to implement the AdaBoost (Boostexter) algorithm in python? Cheers!
AdaBoost ML algorithm python implementation
1.2
0
0
4,289
3,195,437
2010-07-07T13:55:00.000
0
0
0
0
python,soap
3,195,467
3
false
1
0
If library is not under active development, then there are two options: it was abandoned, it has no errors anymore. Why are you looking something else? Did you test these two?
1
0
0
I need an advice. What python framework I can use to develop a SOAP web service? I know about SOAPpy and ZSI but that libraries aren't under active development. Is there something better? Thanks.
Python framework for SOAP web services
0
0
1
1,428
3,197,236
2010-07-07T17:19:00.000
1
0
1
0
c++,python,boost-thread,boost-python
3,223,165
1
false
0
1
Python can be called from multiple threads serially, I don't think that's a problem. It sounds to me like your errors are just coming from bad C++ code, as you said the errors happened after PY_BEGIN_ALLOW_THREADS and before PY_END_ALLOW_THREADS. If you know that's not true, can you post a little more of your actual c...
1
7
0
Me and a friend are developing an application which uses Boost::Python. I have defined an interface in C++ (well a pure virtual class), exposed through Boost::Python to the users, who have to inherit from it and create a class, which the application takes and uses for some callback mechanism. Everything that far goes p...
Problems regarding Boost::Python and Boost::Threads
0.197375
0
0
511
3,197,299
2010-07-07T17:30:00.000
1
0
0
0
python,urllib2
3,410,537
2
false
0
0
As a general strategy, open wireshark and watch the traffic generated by urllib2.urlopen(url). You may be able to see where the error is coming from.
1
3
0
I am trying to open a page using urllib2 but i keep getting connection timed out errors. The line which i am using is: f = urllib2.urlopen(url) exact error is: URLError: <urlopen error [Errno 110] Connection timed out>
urllib2 connection timed out error
0.099668
0
1
17,707
3,197,509
2010-07-07T17:59:00.000
0
0
1
1
python,stdout,stdio,os.system
3,197,579
4
false
0
0
If you want to completely eliminate the console that launches with the python program, you can save it with the .pyw extension. I may be misunderstanding the question, though.
2
9
0
Usually I can change stdout in Python by changing the value of sys.stdout. However, this only seems to affect print statements. So, is there any way I can suppress the output (to the console), of a program that is run via the os.system() command in Python?
Redirecting stdio from a command in os.system() in Python
0
0
0
42,816
3,197,509
2010-07-07T17:59:00.000
0
0
1
1
python,stdout,stdio,os.system
3,197,521
4
false
0
0
Redirect stderr as well as stdout.
2
9
0
Usually I can change stdout in Python by changing the value of sys.stdout. However, this only seems to affect print statements. So, is there any way I can suppress the output (to the console), of a program that is run via the os.system() command in Python?
Redirecting stdio from a command in os.system() in Python
0
0
0
42,816
3,198,104
2010-07-07T19:23:00.000
-1
0
0
0
python,authentication,saml,single-sign-on
3,255,786
1
false
0
0
I know you are looking for a Python based solution but there are quite a few "server" based solutions that would potentially solve your problem as well and require few ongoing code maintenance issues. For example, using the Apache or IIS Integration kits in conjunction with the PingFederate server from www.pingidentit...
1
7
0
I'd like to integrate a web site written in Python (using Pylons) with an existing SAML based authentication service. From reading about SAML, I believe that the IdP (which already exists in this scenario) will send an XML document (via browser post) to the Service Provider (which I am implementing). The Service Prov...
Implementing a SAML client in Python
-0.197375
0
1
3,557
3,198,646
2010-07-07T20:45:00.000
2
1
0
0
java,python,user-interface,mobile
3,198,745
3
true
1
0
Java is certainly available on more platforms. I would pick a target platform (or set of targets) and see what language(s) would require the least number of redundant implementations. Also, when you get to a certain level of complexity, the language often doesn't factor into speed. For initial prototypes, sure some ...
2
0
0
I know Python apps are faster to write, but it seems Java is the 800 lb gorilla for mobile and GUI development. Are there any mobile platforms that run Python, or should I go the Java route?
Python or Java? Whats better for mobile development, and GUI applications
1.2
0
0
5,062
3,198,646
2010-07-07T20:45:00.000
0
1
0
0
java,python,user-interface,mobile
3,199,234
3
false
1
0
The first question is whether you really need to develop an app, which requires per-platform work, vs a webapp. If you really need an app, then you might likely need a separate language for each platform! For Android you'd want to use Java, and for iPhone/iPad you'd want to use Objective-C. A good argument for really t...
2
0
0
I know Python apps are faster to write, but it seems Java is the 800 lb gorilla for mobile and GUI development. Are there any mobile platforms that run Python, or should I go the Java route?
Python or Java? Whats better for mobile development, and GUI applications
0
0
0
5,062
3,198,874
2010-07-07T21:13:00.000
-2
0
0
1
python,beautifulsoup
3,198,945
5
false
1
0
Look at column 3 of line 100 in the "data" that is mentioned in File "/usr/bin/Sipie/Sipie/Factory.py", line 298
1
9
0
I just installed python, mplayer, beautifulsoup and sipie to run Sirius on my Ubuntu 10.04 machine. I followed some docs that seem straightforward, but am encountering some issues. I'm not that familiar with Python, so this may be out of my league. I was able to get everything installed, but then running sipie gives ...
malformed start tag error - Python, BeautifulSoup, and Sipie - Ubuntu 10.04
-0.07983
0
0
7,977
3,199,363
2010-07-07T22:21:00.000
0
0
1
0
python,list,file
3,199,376
3
false
0
0
It simply returns a list containing each line -- there's no "EOF" item in the list.
2
1
0
When you use the fileName.readlines() function in Python, is there a symbol for the end of the file that is included in the list? For example, if the file is read into a list of strings and the last line is 'End', will there be another place in the list with a symbol indicating the end of the file? Thanks.
Reading files to list of strings in Python
0
0
0
3,258
3,199,363
2010-07-07T22:21:00.000
1
0
1
0
python,list,file
3,200,822
3
false
0
0
The list returned by .readlines(), like any other Python list, has no "end" marker -- assumin e.g. you start with L = myfile.readlines(), you can see how many items L has with len(L), get the last one with L[-1], loop over all items one after the other with for item in L:, and so forth ... again -- just like any other ...
2
1
0
When you use the fileName.readlines() function in Python, is there a symbol for the end of the file that is included in the list? For example, if the file is read into a list of strings and the last line is 'End', will there be another place in the list with a symbol indicating the end of the file? Thanks.
Reading files to list of strings in Python
0.066568
0
0
3,258
3,199,611
2010-07-07T23:12:00.000
1
0
1
0
python,eclipse,variables,debugging
11,030,623
4
false
0
0
As this was the top hit on Google I should add that if you right-click on the variables pane in debug mode and select 'copy variables' the string value that Eclipse is truncating (along with all other variables) is added in full to the system clipboard. you can then paste it into your favourite text editor to extract ...
1
21
0
I'm debugging Python code and when I try to show the contents of an string variable its showed truncated... How can show the full contents of a variable debugging Python code with PyDev on Eclipse?
Variables viewer on Eclipse debugging truncates the string values
0.049958
0
0
18,404
3,199,702
2010-07-07T23:40:00.000
12
0
0
1
python,eclipse,twisted,pydev
3,199,728
1
true
1
0
go to preferences->Pydev->Interpreter - Python and hit the apply button. That will rescan your modules directory and add any missing modules. That should fix any normal import errors. Some modules do some runtime magic that PyDev cant follow.
1
5
0
It seems like my Eclipse PyDev does not recognize that Twisted is installed on my system. I can't make auto suggest working. Does anyone know how to solve it?
pydev and twisted framework
1.2
0
0
1,684
3,200,004
2010-07-08T00:59:00.000
1
0
0
0
python,django,soap,multithreading,asynchronous
3,200,013
2
true
1
0
That sounds great! You almost always want to do long running stuff in a background thread, and many soap requests spend a lot of time waiting on network IO... The only question is how do you get the data back to the user. Is this a GUI app, or a web app, or what?
2
1
0
I'm working with an application that needs to be make some time consuming SOAP requests (using suds, as it were). There are several instances where a user will change the state of an object and in doing so trigger one or more SOAP requests that fetch some data. This could be done in the background, and right now the u...
Threaded SOAP requests in Python (Django) application?
1.2
0
0
619
3,200,004
2010-07-08T00:59:00.000
0
0
0
0
python,django,soap,multithreading,asynchronous
3,200,022
2
false
1
0
I use the producer consumer model with a RPCXML server for just this sort of thing. I start a pool of 3 threads, when someone requests something done (add file, etc) I add the work to the queue and return a key. an ajax request can check on the status of the key to set a progress bar, etc.
2
1
0
I'm working with an application that needs to be make some time consuming SOAP requests (using suds, as it were). There are several instances where a user will change the state of an object and in doing so trigger one or more SOAP requests that fetch some data. This could be done in the background, and right now the u...
Threaded SOAP requests in Python (Django) application?
0
0
0
619
3,201,446
2010-07-08T07:26:00.000
0
0
0
1
python,web-services
3,201,519
4
false
0
0
Don't re-invent the bicycle! Run jobs via cron script, and create a separate web interface using, for example, Django or Tornado. Connect them via a database. Even sqlite will do the job if you don't want to scale on more machines.
2
0
0
To give a little background, I'm writing (or am going to write) a daemon in Python for scheduling tasks to run at user-specified dates. The scheduler daemon also needs to have a JSON-based HTTP web service interface (buzzword mania, I know) for adding tasks to the queue and monitoring the scheduler's status. The interf...
what's a good module for writing an http web service interface for a daemon?
0
0
1
400
3,201,446
2010-07-08T07:26:00.000
0
0
0
1
python,web-services
3,201,631
4
false
0
0
I believed all kinds of python web framework is useful. You can pick up one like CherryPy, which is small enough to integrate into your system. Also CherryPy includes a pure python WSGI server for production. Also the performance may not be as good as apache, but it's already very stable.
2
0
0
To give a little background, I'm writing (or am going to write) a daemon in Python for scheduling tasks to run at user-specified dates. The scheduler daemon also needs to have a JSON-based HTTP web service interface (buzzword mania, I know) for adding tasks to the queue and monitoring the scheduler's status. The interf...
what's a good module for writing an http web service interface for a daemon?
0
0
1
400
3,201,642
2010-07-08T08:00:00.000
1
0
0
1
python,distribution,cx-freeze
3,219,422
2
false
0
0
Try py2app for Mac OS X. (And py2exe for Windows.)
2
1
0
I created independent python app using cxfreeze under linux and can run it other machines without python and other dependencies. But while doing it for mac OS X, in other machines the app searches for the following python installed location which actually present in the machine where it is frozen. "/Library/Frameworks...
distributing independent python app to other machines
0.099668
0
0
149
3,201,642
2010-07-08T08:00:00.000
0
0
0
1
python,distribution,cx-freeze
3,226,239
2
false
0
0
Is py2app supports python 3 version?
2
1
0
I created independent python app using cxfreeze under linux and can run it other machines without python and other dependencies. But while doing it for mac OS X, in other machines the app searches for the following python installed location which actually present in the machine where it is frozen. "/Library/Frameworks...
distributing independent python app to other machines
0
0
0
149
3,201,685
2010-07-08T08:07:00.000
0
0
0
0
python,pygame,flip
3,201,723
1
false
0
1
Just poll for the time immediately after the flip call, if that one syncs to the vertical retrace.
1
0
0
I am using Pygame to pageflip different stimuli on the screen. The problem is that pygame's flip function, although syncing the flip to the vertical retrace, does not tell me when the retrace was. Does anyone know of a way to get this information (preferably platform independent) in Python? Regards, fladd
How to get the point in time of (last) vertical retrace under Python?
0
0
0
153
3,204,037
2010-07-08T13:25:00.000
1
0
1
0
python,multiprocessing
3,204,794
1
true
0
0
multiprocessing.Process objects take an optional name argument on initialization. You can use that name as a key in a dictionary: child_procs = {'name1' : Process(target=myprocfunc, name='name1'), ...} As for IPC between the parent process and the children, you should be fine with just maintaining a separate multiproc...
1
1
0
I am using multiprocessing module. This module is works on Queue that is its pick random process and assign the entery from Queue. I want to decide which process will work on which entry of Queue Here is my requirements, I will pass 2 parameters to queue Initiator Process name Action/method ( What process is going ...
How to call process by name or tags in python
1.2
0
0
304
3,204,614
2010-07-08T14:26:00.000
13
0
1
0
python
3,204,625
10
false
0
0
str(object) will do the trick. If you want to alter the way object is stringified, define __str__(self) method for object's class. Such method has to return str or unicode object.
3
159
0
How can I change any data type into a string in Python?
How to change any data type into a string?
1
0
0
557,158
3,204,614
2010-07-08T14:26:00.000
6
0
1
0
python
3,204,624
10
false
0
0
With str(x). However, every data type can define its own string conversion, so this might not be what you want.
3
159
0
How can I change any data type into a string in Python?
How to change any data type into a string?
1
0
0
557,158
3,204,614
2010-07-08T14:26:00.000
20
0
1
0
python
36,364,940
10
false
0
0
I see all answers recommend using str(object). It might fail if your object have more than ascii characters and you will see error like ordinal not in range(128). This was the case for me while I was converting list of string in language other than English I resolved it by using unicode(object)
3
159
0
How can I change any data type into a string in Python?
How to change any data type into a string?
1
0
0
557,158
3,205,349
2010-07-08T15:38:00.000
1
0
0
0
python,security,authentication,encryption,cryptography
3,205,573
3
false
1
0
I don't think RegistrationKey adds any real security. It needs more nonces (against replay attacks). It needs more padding (or else the messages are small and thus easy to decrypt). An algorithm can be proven to be secure, you may want to do this. Most flaws in crypto are in the implementation, not in the algorithm (ti...
1
1
0
We have a custom built program that needs authenticated/encrypted communication between a client and a server[both in Python]. We are doing an overhaul from custom written Diffie-Hellman+AES to RSA+AES in a non-orthodox way. So I would be very interested in comments about my idea. Prequisites: Klient has a 128bit Regis...
HTTP based authentication/encryption protocol in a custom system
0.066568
0
0
1,123
3,207,219
2010-07-08T19:31:00.000
3
0
1
0
python,directory
47,758,562
21
false
0
0
I will provide a sample one liner where sourcepath and file type can be provided as input. The code returns a list of filenames with csv extension. Use . in case all files needs to be returned. This will also recursively scans the subdirectories. [y for x in os.walk(sourcePath) for y in glob(os.path.join(x[0], '*.csv'...
1
3,467
0
How can I list all files of a directory in Python and add them to a list?
How do I list all files of a directory?
0.028564
0
0
6,808,733
3,207,572
2010-07-08T20:12:00.000
1
0
1
0
python
3,207,610
11
false
0
0
if you want globally set parameters for a callable 'thing' you could always create a class and implement the __call__ method?
3
8
0
I've got a bunch of functions (outside of any class) where I've set attributes on them, like funcname.fields = 'xxx'. I was hoping I could then access these variables from inside the function with self.fields, but of course it tells me: global name 'self' is not defined So... what can I do? Is there some magic variab...
"self" inside plain function?
0.01818
0
0
2,968
3,207,572
2010-07-08T20:12:00.000
0
0
1
0
python
3,207,623
11
false
0
0
What exactly are you hoping "self" would point to, if the function is defined outside of any class? If your function needs some global information to execute properly, you need to send this information to the function in the form of an argument. If you want your function to be context aware, you need to declare it wit...
3
8
0
I've got a bunch of functions (outside of any class) where I've set attributes on them, like funcname.fields = 'xxx'. I was hoping I could then access these variables from inside the function with self.fields, but of course it tells me: global name 'self' is not defined So... what can I do? Is there some magic variab...
"self" inside plain function?
0
0
0
2,968
3,207,572
2010-07-08T20:12:00.000
1
0
1
0
python
3,207,667
11
false
0
0
There is no special way, within a function's body, to refer to the function object whose code is executing. Simplest is just to use funcname.field (with funcname being the function's name within the namespace it's in, which you indicate is the case -- it would be harder otherwise).
3
8
0
I've got a bunch of functions (outside of any class) where I've set attributes on them, like funcname.fields = 'xxx'. I was hoping I could then access these variables from inside the function with self.fields, but of course it tells me: global name 'self' is not defined So... what can I do? Is there some magic variab...
"self" inside plain function?
0.01818
0
0
2,968
3,207,671
2010-07-08T20:24:00.000
3
0
0
1
python,google-app-engine,google-cloud-datastore
3,207,714
2
true
1
0
I can reference it through record.key().id(). I just found this RIGHT AFTER I posted this question (as luck would have it). Sorry for wasting anybody's time.
2
2
0
I have a feeling the answer is simple and documented, but I'm absolutely missing it: Is there a way, using Python and webapp through Google App Engine, to pass the id field of a record to the template? I'm fairly new to the app engine, and yes, I have searched all around the Google Documentation to find this.
Reference ID in GAE
1.2
0
0
105
3,207,671
2010-07-08T20:24:00.000
1
0
0
1
python,google-app-engine,google-cloud-datastore
3,209,539
2
false
1
0
Assuming you're using the built-in Django 0.96 templates, you can access the ID (assuming the entity has one; it might have a key name instead if you saved it with one) with {{entity.key.id}}.
2
2
0
I have a feeling the answer is simple and documented, but I'm absolutely missing it: Is there a way, using Python and webapp through Google App Engine, to pass the id field of a record to the template? I'm fairly new to the app engine, and yes, I have searched all around the Google Documentation to find this.
Reference ID in GAE
0.099668
0
0
105
3,207,719
2010-07-08T20:29:00.000
0
0
1
0
python
3,207,765
4
false
0
0
How big and does it need to be done in python? If this is on unix, would split/csplit/grep suffice?
1
0
0
Hey I need to split a large file in python into smaller files that contain only specific lines. How do I do this?
question about splitting a large file
0
0
0
538
3,208,450
2010-07-08T22:24:00.000
0
0
0
1
python,c,macos,python-idle
3,208,731
4
false
0
0
Is your application GUI-driven? If so, you could start a timer when the GUI comes up and then have keyboard and mouse callbacks at the top level. Every time the keyboard or mouse callback is triggered, reset the timer. Otherwise when the timer goes off, it's handler code should suspend your counter. If not, ignore th...
2
2
0
How can i get system idle time (no keys pressed - mouse moved) in C or Python? EDIT: My program suspend a counter when idle time > 10 sec
Get Mac idle time C or Python
0
0
0
1,227
3,208,450
2010-07-08T22:24:00.000
0
0
0
1
python,c,macos,python-idle
3,208,501
4
false
0
0
what about that in python ( win ) ? like time module in standard lib of python ... ?
2
2
0
How can i get system idle time (no keys pressed - mouse moved) in C or Python? EDIT: My program suspend a counter when idle time > 10 sec
Get Mac idle time C or Python
0
0
0
1,227
3,210,577
2010-07-09T07:21:00.000
1
0
0
1
python,google-app-engine
3,211,471
1
true
1
0
The best way is to populate the summaries (aggregates) at the time of write. This way your reads will be faster, since they just read - at the cost of writes which will have to update the summaries if its likely to be effected by the write. Hopefully you will be reading more often than writing/updating summaries.
1
0
0
As is mentioned in the doc for google app engine, it does not support group by and other aggregation functions. Is there any alternatives to implement the same functionality? I am working on a project where I need it on urgent basis, being a large database its not efficient to iterate the result set and then perform th...
Google application engine Datastore - any alternatives to aggregate functions and group by?
1.2
1
0
322
3,210,902
2010-07-09T08:10:00.000
9
0
0
1
python
3,210,928
5
false
0
0
You might get that error if the current working directory has been deleted. Programs that are working in a particular directory don't automatically notice if the directory gets deleted; as far as the program is concerned, the CWD is just a string, at least until you do something like os.getcwd() that actually accesses ...
5
30
0
I have this program that at one point accesses os.getcwd(), but some times, depending on where the program has gone before getting to that line, it crashes with the message "OSError: [Errno 2] No such file or directory". I cannot figure out what i can do wrong then calling os.getcwd(). There's no arguments, and there ...
Python: Why does os.getcwd() sometimes crash with OSError?
1
0
0
15,175
3,210,902
2010-07-09T08:10:00.000
48
0
0
1
python
3,210,929
5
true
0
0
The current directory may have been deleted by another process.
5
30
0
I have this program that at one point accesses os.getcwd(), but some times, depending on where the program has gone before getting to that line, it crashes with the message "OSError: [Errno 2] No such file or directory". I cannot figure out what i can do wrong then calling os.getcwd(). There's no arguments, and there ...
Python: Why does os.getcwd() sometimes crash with OSError?
1.2
0
0
15,175
3,210,902
2010-07-09T08:10:00.000
1
0
0
1
python
59,532,717
5
false
0
0
It is also possible to get this error when working with an encrypted filesystem and if the partition containing the working directory went back to a "locked" state. In my case, a README file was available at the mounting point of the partition explaining how to unlock the partition again. It could depend of the encry...
5
30
0
I have this program that at one point accesses os.getcwd(), but some times, depending on where the program has gone before getting to that line, it crashes with the message "OSError: [Errno 2] No such file or directory". I cannot figure out what i can do wrong then calling os.getcwd(). There's no arguments, and there ...
Python: Why does os.getcwd() sometimes crash with OSError?
0.039979
0
0
15,175
3,210,902
2010-07-09T08:10:00.000
0
0
0
1
python
65,927,209
5
false
0
0
Sommeone probably erased your filesystem while you had the Python open. That is why Python is stating that it could not be found. This had happened to me.
5
30
0
I have this program that at one point accesses os.getcwd(), but some times, depending on where the program has gone before getting to that line, it crashes with the message "OSError: [Errno 2] No such file or directory". I cannot figure out what i can do wrong then calling os.getcwd(). There's no arguments, and there ...
Python: Why does os.getcwd() sometimes crash with OSError?
0
0
0
15,175
3,210,902
2010-07-09T08:10:00.000
3
0
0
1
python
3,210,937
5
false
0
0
You would get that error if your current directory no longer exists (it is deleted).
5
30
0
I have this program that at one point accesses os.getcwd(), but some times, depending on where the program has gone before getting to that line, it crashes with the message "OSError: [Errno 2] No such file or directory". I cannot figure out what i can do wrong then calling os.getcwd(). There's no arguments, and there ...
Python: Why does os.getcwd() sometimes crash with OSError?
0.119427
0
0
15,175
3,210,994
2010-07-09T08:21:00.000
0
0
0
1
python,google-app-engine,performance,many-to-many
3,213,988
1
true
1
0
I don't think there's a hard and fast answer to questions like this. "Is this optimization worth it" always depends on many variables such as, is the lack of optimization actually a problem to start with? How much of a problem is it? What's the cost in terms of extra time and effort and risk of bugs of a more complex o...
1
1
0
I'm using Google Appengine to store a list of favorites, linking a Facebook UserID to one or more IDs from Bing. I need function calls returning the number of users who have favorited an item, and the number of times an item has been favorited (and by whom). My question is, should I resolve this relationship into two t...
Many-to-many relationships in Google AppEngine - efficient?
1.2
1
0
280
3,211,379
2010-07-09T09:27:00.000
0
0
1
1
python,multithreading,concurrency,datastore
3,211,387
1
true
1
0
What you're seeking isn't too Python specific, because AFAIU you want to communicate between two different processes, which are only incidentally written in Python. If this indeed is your problem, you should look for a general solution, not a Python-specific one. I think that a simple No-SQL key-value datastore such as...
1
1
0
I'm writing a small multithreaded client-side python application that contains a small webserver (only serves page to the localhost) and a daemon. The webserver loads and puts data into a persistent "datastore", and the daemon processes this data, modifies it and adds some more. It should also takes care of the synchro...
How should I share and store data in a small multithreaded python application?
1.2
0
0
178
3,211,690
2010-07-09T10:21:00.000
1
0
1
1
python,eclipse,relative-path,pydev
3,212,495
3
false
0
0
Take a look in the project settings, I've never used Pydev with Eclipse, but you should be able to set where the project is executed at, or paths for references. Of course there may be a better solution, but hopefully that's some help!
3
6
0
I installed eclipse with pydev plugin. I need to run my existing project on eclipse. But there are relative paths to the files inside my code. I expect from eclipse to append relative paths to the project's default directory. Instead, it appends the relative path to the directory where Eclipse is installed. I could not...
Pydev relative project path
0.066568
0
0
3,341
3,211,690
2010-07-09T10:21:00.000
0
0
1
1
python,eclipse,relative-path,pydev
4,901,532
3
false
0
0
Another way to do it is to go to the 'Environment' tab from the "Run Configuration". Add a new variable with name, "PATH", specifying your desired directory in the "Value" box.
3
6
0
I installed eclipse with pydev plugin. I need to run my existing project on eclipse. But there are relative paths to the files inside my code. I expect from eclipse to append relative paths to the project's default directory. Instead, it appends the relative path to the directory where Eclipse is installed. I could not...
Pydev relative project path
0
0
0
3,341
3,211,690
2010-07-09T10:21:00.000
7
0
1
1
python,eclipse,relative-path,pydev
3,213,187
3
true
0
0
I finally found out how to do it and I am writing the answer for other people with the same problem. You can find it in Run Configurations or Debug Configurations. Choose "Python Run" and your run configuration from the left and then in the "Arguments" tab in the right side, set your "working directory" as "other" with...
3
6
0
I installed eclipse with pydev plugin. I need to run my existing project on eclipse. But there are relative paths to the files inside my code. I expect from eclipse to append relative paths to the project's default directory. Instead, it appends the relative path to the directory where Eclipse is installed. I could not...
Pydev relative project path
1.2
0
0
3,341
3,211,723
2010-07-09T10:25:00.000
1
0
0
1
python,google-app-engine
5,072,453
1
false
1
0
Note that even if you could get access to the ast modules on GAE, RestrictedPython might still not be the right solution for your use-case. It's only aimed at securing input from less trusted users, where you don't trust their ability to code. You still need to trust and know them. There's various ways in which a malic...
1
2
0
I'm looking for a way to execute user submitted python code in GAE in a secure fashion (much stricter then the GAE sandbox). RestrictedPython would certainly fit the shoe, being used in Zope for the exakt same purpose. But RestrictedPython relies on modifying the AST (abstract syntax tree) which means loading modules f...
RestrictedPython on Google AppEngine (GAE)
0.197375
0
0
336
3,212,396
2010-07-09T12:08:00.000
1
0
0
0
python,django,importerror,uwsgi
3,213,320
1
false
1
0
Seems like you have missed a comma in the settings.INSTALLED_APPS, after the app name. Go, check!
1
0
0
Hi I am trying to deploy a django app with uwsgi. I keep getting Import Errors that look like this: ImportError: No module named ?z? -or- ImportError: No module named ?j? -or- ImportError: No module named `?6 So basically the output of the module seems like gibberish and I am unable to figure out the problem. Does anyb...
Django: ImportError: No module named ?z?
0.197375
0
0
1,341
3,215,062
2010-07-09T17:26:00.000
0
1
0
0
python,flash,forms,mechanize,code-injection
3,849,851
2
false
1
0
Nice question but seems unfortunately mechanize can't be used for flash objects
1
2
0
I am trying to create an automated program in Python that deals with Flash. Right now I am using Python Mechanize, which is great for filling forms, but when it comes to flash I don't know what to do. Does anyone know how I can interact with flash forms (set and get variables, click buttons, etc.) via Python mechanize ...
Interact with Flash using Python Mechanize
0
0
0
1,702
3,215,168
2010-07-09T17:39:00.000
11
0
1
0
python,string
34,101,344
7
false
0
0
just use \xb0 (in a string); python will convert it automatically
1
86
0
How can I get a ° (degree) character into a string?
How to get ° character in a string in python?
1
0
0
176,258
3,215,455
2010-07-09T18:21:00.000
2
0
0
0
python,ruby-on-rails,ruby
3,218,192
4
false
1
0
Depending on your exact needs, you can either call out to an external process (using popen, system, etc) or you can setup another mini-web-server or something along those lines and have the rails server communicate with it over HTTP with a REST-style API (or whatever best suits your needs). In your example, you have a ...
3
2
0
Is it possible to use multiple languages along side with ruby. For example, I have my application code in Ruby on Rails. I would like to calculate the recommendations and I would like to use python for that. So essentially, python code would get the data and calculate all the stuff and probably get the data from DB, ca...
Using other languages with ruby
0.099668
0
0
1,299
3,215,455
2010-07-09T18:21:00.000
0
0
0
0
python,ruby-on-rails,ruby
3,218,487
4
false
1
0
An easy, quick 'n' dirty solution in case you have python scripts and you want to execute them from inside rails, is this: %x[shell commands or python path/of/pythonscript.py #{ruby variables to pass on the script}] or ``shell commands or python path/of/pythonscript.py #{ruby variables to pass on the script}\ (with ` s...
3
2
0
Is it possible to use multiple languages along side with ruby. For example, I have my application code in Ruby on Rails. I would like to calculate the recommendations and I would like to use python for that. So essentially, python code would get the data and calculate all the stuff and probably get the data from DB, ca...
Using other languages with ruby
0
0
0
1,299
3,215,455
2010-07-09T18:21:00.000
4
0
0
0
python,ruby-on-rails,ruby
3,215,496
4
false
1
0
If you are offloading work to an exterior process, you may want to make this a webservice (ajax, perhaps) of some sort so that you have some sort of consistent interface. Otherwise, you could always execute the python script in a subshell through ruby, using stdin/stdout/argv, but this can get ugly quick.
3
2
0
Is it possible to use multiple languages along side with ruby. For example, I have my application code in Ruby on Rails. I would like to calculate the recommendations and I would like to use python for that. So essentially, python code would get the data and calculate all the stuff and probably get the data from DB, ca...
Using other languages with ruby
0.197375
0
0
1,299
3,216,027
2010-07-09T19:47:00.000
1
0
0
0
python,mysql
3,216,500
1
true
0
0
Depending on your user privileges, you can execute SHOW PROCESSLIST or SELECT from information_schema.processlist while the UPDATE hangs to see if there is a contention issue with another query. Also do an EXPLAIN on a SELECT of the WHERE clause used in the UPDATE to see if you need to change the statement. If it's ...
1
0
0
I'm using MySQLdb and when I perform an UPDATE to a table row I sometimes get an infinite process hang. At first I thought, maybe its COMMIT since the table is Innodb, but even with autocommit(True) and db.commit() after each update I still get the hang. Is it possible there is a row lock and the query just fails to ca...
MySQLdb Handle Row Lock
1.2
1
0
544
3,216,654
2010-07-09T21:22:00.000
1
0
1
0
python
3,216,689
2
false
0
0
Python uses radians, as a float. There is no specific "angle" type, although you can write one yourself as needed.
1
0
0
What is the standard way to enter degrees into python? My total station gives degrees in degree-minute-second format. I could write a function to convert this to a decimal degree but I would like to know if there is a common way to do this that I am unaware of. -Chris
Entering precise degrees into python
0.099668
0
0
535
3,216,681
2010-07-09T21:28:00.000
0
1
1
0
python,coding-style,conditional
3,232,563
7
false
0
0
Might I suggest that the amount of bickering over this question is enough to answer it? Some argue that it "if x" should only be used for Z, others for Y, others for X. If such a simple statement is able to create such a fuss, to me it is clear that the statement is not clear enough. Write what you mean. If you want t...
4
5
0
Assuming that x is an integer, the construct if x: is functionally the same as if x != 0: in Python. Some languages' style guides explicitly forbid against the former -- for example, ActionScript/Flex's style guide states that you should never implicitly cast an int to bool for this sort of thing. Does Python have a pr...
Which of `if x:` or `if x != 0:` is preferred in Python?
0
0
0
6,685
3,216,681
2010-07-09T21:28:00.000
3
1
1
0
python,coding-style,conditional
3,216,964
7
false
0
0
There's no hard and fast rule here. Here are some examples where I would use each: Suppose that I'm interfacing to some function that returns -1 on error and 0 on success. Such functions are pretty common in C, and they crop up in Python frequently when using a library that wraps C functions. In that case, I'd use i...
4
5
0
Assuming that x is an integer, the construct if x: is functionally the same as if x != 0: in Python. Some languages' style guides explicitly forbid against the former -- for example, ActionScript/Flex's style guide states that you should never implicitly cast an int to bool for this sort of thing. Does Python have a pr...
Which of `if x:` or `if x != 0:` is preferred in Python?
0.085505
0
0
6,685
3,216,681
2010-07-09T21:28:00.000
-2
1
1
0
python,coding-style,conditional
3,216,911
7
false
0
0
Wouldn't if x is not 0: be the preferred method in Python, compared to if x != 0:? Yes, the former is a bit longer to write, but I was under the impression that is and is not are preferred over == and !=. This makes Python easier to read as a natural language than as a programming language.
4
5
0
Assuming that x is an integer, the construct if x: is functionally the same as if x != 0: in Python. Some languages' style guides explicitly forbid against the former -- for example, ActionScript/Flex's style guide states that you should never implicitly cast an int to bool for this sort of thing. Does Python have a pr...
Which of `if x:` or `if x != 0:` is preferred in Python?
-0.057081
0
0
6,685
3,216,681
2010-07-09T21:28:00.000
2
1
1
0
python,coding-style,conditional
3,216,691
7
false
0
0
Typically, I read: if(x) to be a question about existence. if( x != 0) to be a question about a number.
4
5
0
Assuming that x is an integer, the construct if x: is functionally the same as if x != 0: in Python. Some languages' style guides explicitly forbid against the former -- for example, ActionScript/Flex's style guide states that you should never implicitly cast an int to bool for this sort of thing. Does Python have a pr...
Which of `if x:` or `if x != 0:` is preferred in Python?
0.057081
0
0
6,685
3,217,222
2010-07-10T00:00:00.000
2
1
1
0
python
3,217,317
8
false
0
0
I found python in 1988 and fell in love with it. Our group at work had been dissolved and we were looking for other jobs on site, so I had a couple of months to play around doing whatever I wanted to. I spent the time profitably learning and using python. I suggest you spend time thinking up and writing utilities an...
1
43
0
Well just getting into the flow of thing with Python. Reading a few books, finding it fairly easy as I already have some experience with C++/Java from school and Python is definetly my favorite thus far. Anyway, I am getting a whole bunch of information on python, but haven't been putting it to much use. Thus, what I w...
Beginner Python Practice?
0.049958
0
0
142,555
3,217,673
2010-07-10T03:16:00.000
67
0
1
0
python,command-line,optparse,getopt,argparse
3,217,926
5
false
0
0
Why should I use it instead of optparse? Are their new features I should know about? @Nicholas's answer covers this well, I think, but not the more "meta" question you start with: Why has yet another command-line parsing module been created? That's the dilemma number one when any useful module is added to the ...
1
316
0
I noticed that the Python 2.7 documentation includes yet another command-line parsing module. In addition to getopt and optparse we now have argparse. Why has yet another command-line parsing module been created? Why should I use it instead of optparse? Are there new features that I should know about?
Why use argparse rather than optparse?
1
0
0
147,808
3,218,599
2010-07-10T09:10:00.000
1
1
1
1
python,bash
3,218,680
1
true
0
0
My interpretation of your context, is that you have a Python script that performs various make- or autoconf-like operations, and you want to allow clients to write their own Makefiles for Foobuzzle. The problem with directories I don't understand. import will always search the local directory? And you can os.chdir() wh...
1
0
0
Lets say I am designing a tool foobuzzle (foobuzzle's exact job is to set up SRPM files for cross-compiling a variety of codes into their own compartmentalized prefix directories, but this is not important). I would like foobuzzle to take in an input file (buzzle_input) specified by an (intelligent, code-savvy) client...
How do I execute Python/bash code in the current directory as part of a code?
1.2
0
0
276
3,219,765
2010-07-10T15:23:00.000
2
0
0
0
python,tkinter,grid,tkinter-entry
3,222,439
2
true
0
1
Don't place them in the same row and column; place the upper in a row, and the lower in row+1, both in the same column. That does the trick. Note that the grid manager does not need to have all rows and columns filled with widgets; it ignores empty rows and columns.
1
1
0
I am having a bit of trouble with the Tkinter grid() manager. It is spacing the rows too far apart. I have two entry widgets to place, and I need one almost directly under the other. When I place them both on the same row and column, but change the pady option, it places them directly on top of each other. I know there...
Tkinter grid() Manager
1.2
0
0
1,716
3,219,772
2010-07-10T15:25:00.000
1
0
1
1
python,diff,patch
3,219,785
2
false
0
0
Your update manager can know which version the current app is, and which version is the most recent one and apply only the relevant patches. Suppose the user runs 0.38, and currently there is 0.42 available. The update for 0.42 contains patches for 0.39, 0.40, 0.41 and 0.42 (and probably farther down the history). The ...
1
3
0
Currently my program updates itself by downloading the latest .tar.gz file containing the source code, and extracting it over the current directory where the program lives. There are 2 "modes" of update - one for users running the Python source, and one if the user is running the program as a Windows exe. Over time my...
Updating my program, using a diff-based patch approach
0.099668
0
0
535
3,220,280
2010-07-10T17:55:00.000
2
0
1
0
python,django,setuptools,virtualenv
66,091,958
5
false
1
0
pip install "django>=2.2,<3" To install djnago 2.2
1
96
0
I want to install some specific version of a package (in this case Django) inside the virtual environment. I can't figure it out. I'm on Windows XP, and I created the virtual environment successfully, and I'm able to run it, but how am I supposed to install the Django version I want into it? I mean, I know to use the n...
How do I install an old version of Django on virtualenv?
0.07983
0
0
80,239
3,220,433
2010-07-10T18:50:00.000
0
0
1
0
python,optimization,recursion,diff
3,220,449
2
false
0
0
If you have any expensive method that you are likely to call multiple times with the same parameters then you can just cache the result of the method, using the parameters as a key.
1
2
0
After finding the difflib.SequenceMatcher class in Python's standard library to be unsuitable for my needs, a generic "diff"-ing module was written to solve a problem space. After having several months to think more about what it is doing, the recursive algorithm appears to be searching more than in needs to by re-sear...
How to optimize a recursive algorithm to not repeat itself?
0
0
0
508
3,221,366
2010-07-11T00:21:00.000
2
0
1
0
python,timezone
3,221,517
2
false
0
0
I don't think that's a good idea. In Australia, Melbourne and Sydney usually share the same timezone, however the choice of when DST starts and ends is controlled by two different bodies. When Melbourne hosted the Commonwealth Games a few years back, they changed the DST (just for the one year) for convenience. I think...
1
9
0
There are way too many overlapping timezones in pytz's common list. Has anyone pared this down? For example there are 5 or 6 duplicate Canadian timezones and 15 or so duplicate US time zones. China is 1 timezone no DST, but has 5 entries.. By duplicate I mean GMT offset and DST are exactly the same. Getting rid of the...
Python timezones - pytz.common_timezones has too many
0.197375
0
0
1,191
3,221,739
2010-07-11T03:22:00.000
4
0
1
0
python,variables
3,221,742
2
false
0
0
There's no reason you can't hold 100 MB of data in Python, system memory permitting. But you should try to use an iterator, rather than reading the whole result set into a list.
1
2
0
I get an response in Python program from SQL server. How big can this response be? What is the maximum? Coult it be as much as about 100 mb?
How big can variable be, in python?
0.379949
0
0
4,638
3,222,654
2010-07-11T10:15:00.000
3
0
0
0
python,database,dom
3,222,720
3
true
1
0
Is there anything missing to my general approach for developing a web app? (Server-side scripting interacts with database to produce dynamic HTML which is then manipulated client-side via. the DOM/client-side scripting). No - that's the usual setup. Actually, client-side scripting is quite often missing, and web-page...
2
3
0
As a programmer used to developing native applications, I'm expanding my horizons and developing my first web app. I'm intermediate to expert with Linux and C, intermediate with Python and HTML and beginner to intermediate with MySQL and Java. I'm developing a web app that is more or less a resource allocator for a fri...
General guidelines for developing a web application
1.2
0
0
404
3,222,654
2010-07-11T10:15:00.000
1
0
0
0
python,database,dom
3,222,758
3
false
1
0
I'd like to suggest ditching PHP as soon as possible. Searching 'php wtf' here should be illuminating. While it is possible to write secure, safe, reliable applications in PHP, I think it is despite the best efforts of the PHP team to make The Most Exciting And Surprisin Language EVAR. With lots of funny side-effects. ...
2
3
0
As a programmer used to developing native applications, I'm expanding my horizons and developing my first web app. I'm intermediate to expert with Linux and C, intermediate with Python and HTML and beginner to intermediate with MySQL and Java. I'm developing a web app that is more or less a resource allocator for a fri...
General guidelines for developing a web application
0.066568
0
0
404
3,223,557
2010-07-11T15:28:00.000
0
1
0
0
php,python,jsp
3,223,599
7
false
1
0
I expect this question to be closed as being subjective. But, I'll put in my 2 cents. JSP would likely dovetail well with J2EE. (I've heard that it can be a bit rigid, but I have no experience to provide any insight on the matter.) PHP is a good candidate, because it's popular. You can find a lot of info on the web....
6
5
0
Friends, I've got some exp in c++ and now kind of starting my way to J2EE (to survive:))). Meanwhile, I've got a plan to venture in to a web portal my own. But with very little experience in web technology, I'd need to start from scratch. I'm little confused on which way to go and I'm here. PHP, Python or JSP, consid...
Which web technology to learn for an experienced C++ developer?
0
0
0
1,073
3,223,557
2010-07-11T15:28:00.000
1
1
0
0
php,python,jsp
3,225,166
7
false
1
0
Hit's per day isn't a really useful metric for estimating performance. You really need to be concerned with the peak load and the acceptable response time. 80-100k hits per day is an average of about 1 hit per second. The hits are not going to be evenly spread out, so for normal traffic you might expect a peak load of ...
6
5
0
Friends, I've got some exp in c++ and now kind of starting my way to J2EE (to survive:))). Meanwhile, I've got a plan to venture in to a web portal my own. But with very little experience in web technology, I'd need to start from scratch. I'm little confused on which way to go and I'm here. PHP, Python or JSP, consid...
Which web technology to learn for an experienced C++ developer?
0.028564
0
0
1,073
3,223,557
2010-07-11T15:28:00.000
1
1
0
0
php,python,jsp
3,223,588
7
false
1
0
Considering you're used to c++, should look at aspx and c# - probably closer to your current experience. That said, PHP is a doddle, so it shouldn't present any challenges. Bear in mind that if you want to get the most from the language, you absolutely have to learn a little bit about configuring apache, and frameworks...
6
5
0
Friends, I've got some exp in c++ and now kind of starting my way to J2EE (to survive:))). Meanwhile, I've got a plan to venture in to a web portal my own. But with very little experience in web technology, I'd need to start from scratch. I'm little confused on which way to go and I'm here. PHP, Python or JSP, consid...
Which web technology to learn for an experienced C++ developer?
0.028564
0
0
1,073