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
284,741
2008-11-12T17:50:00.000
1
1
0
0
python,http,post,java-me,midlet
284,857
5
false
1
0
Maybe it is a configuration issue? Django can be fronted with Apache by mod_python, WSGI and FastCGI and it can accept file uploads.
2
5
0
I have a j2me client that would post some chunked encoded data to a webserver. I'd like to process the data in python. The script is being run as a CGI one, but apparently apache will refuse a chunked encoded post request to a CGI script. As far as I could see mod_python, WSGI and FastCGI are no go too. I'd like to know if there is a way to have a python script process this kind of input. I'm open to any suggestion (e.g. a confoguration setting in apache2 that would assemble the chunks, a standalone python server that would do the same, etc.) I did quite a bit of googling and didn't find anything usable, which is quite strange. I know that resorting to java on the server side would be a solution, but I just can't imagine that this can't be solved with apache + python.
Processing chunked encoded HTTP POST requests in python (or generic CGI under apache)
0.039979
0
0
5,471
284,741
2008-11-12T17:50:00.000
2
1
0
0
python,http,post,java-me,midlet
284,869
5
false
1
0
Apache 2.2 mod_cgi works fine for me, Apache transparently unchunks the request as it is passed to the CGI application. WSGI currently disallows chunked requests, and mod_wsgi does indeed block them with a 411 response. It's on the drawing board for WSGI 2.0. But congratulations on finding something that does chunk requests, I've never seen one before!
2
5
0
I have a j2me client that would post some chunked encoded data to a webserver. I'd like to process the data in python. The script is being run as a CGI one, but apparently apache will refuse a chunked encoded post request to a CGI script. As far as I could see mod_python, WSGI and FastCGI are no go too. I'd like to know if there is a way to have a python script process this kind of input. I'm open to any suggestion (e.g. a confoguration setting in apache2 that would assemble the chunks, a standalone python server that would do the same, etc.) I did quite a bit of googling and didn't find anything usable, which is quite strange. I know that resorting to java on the server side would be a solution, but I just can't imagine that this can't be solved with apache + python.
Processing chunked encoded HTTP POST requests in python (or generic CGI under apache)
0.07983
0
0
5,471
285,132
2008-11-12T19:57:00.000
2
0
1
0
python,user-interface,ide
285,516
9
false
0
0
I'm not really a Pythonista, but I am a Mac user and I appreciate a good, native interface in the apps I write and use. So, if I were to use Python for a GUI app on the Mac, I'd use PyObjC with Interface Builder and Xcode, rather than a cross-platform solution.
1
3
0
Is there any IDE (like VS) with drag and drop support for building python GUI, connecting to dbs etc? Eventhough I am an emacs guy, I find it much easier to create GUI with VS.
With what kind of IDE (if any) you build python GUI projects?
0.044415
0
0
18,625
285,226
2008-11-12T20:28:00.000
2
1
0
0
python,web-services,twitter
285,252
5
false
0
0
Python has a very nice httplib module as well as a url module which together will probably accomplish most of what you need (at least with regards to wget functionality).
1
6
0
Let's say I wanted to make a python script interface with a site like Twitter. What would I use to do that? I'm used to using curl/wget from bash, but Python seems to be much nicer to use. What's the equivalent? (This isn't Python run from a webserver, but run locally via the command line)
What Python tools can I use to interface with a website's API?
0.07983
0
1
839
285,289
2008-11-12T20:43:00.000
3
0
1
0
python,exit-code
285,310
13
false
0
0
Exit codes in many programming languages are up to programmers. So you have to look at your program source code (or manual). Zero usually means "everything went fine".
3
290
0
I got a message saying script xyz.py returned exit code 0. What does this mean? What do the exit codes in Python mean? How many are there? Which ones are important?
Exit codes in Python
0.046121
0
0
634,909
285,289
2008-11-12T20:43:00.000
17
0
1
0
python,exit-code
285,304
13
false
0
0
Exit codes of 0 usually mean, "nothing wrong here." However if the programmer of the script didn't follow convention you may have to consult the source to see what it means. Usually a non-zero value is returned as an error code.
3
290
0
I got a message saying script xyz.py returned exit code 0. What does this mean? What do the exit codes in Python mean? How many are there? Which ones are important?
Exit codes in Python
1
0
0
634,909
285,289
2008-11-12T20:43:00.000
6
0
1
0
python,exit-code
285,306
13
false
0
0
The exit codes only have meaning as assigned by the script author. The Unix tradition is that exit code 0 means 'success', anything else is failure. The only way to be sure what the exit codes for a given script mean is to examine the script itself.
3
290
0
I got a message saying script xyz.py returned exit code 0. What does this mean? What do the exit codes in Python mean? How many are there? Which ones are important?
Exit codes in Python
1
0
0
634,909
287,379
2008-11-13T16:18:00.000
0
0
1
0
python,c++,c,parsing,c-preprocessor
287,393
5
false
0
0
The GCC preprocessor is typicallly a stand-alone program, typically called cpp. That will probably also strip off your comments, of course.
2
4
0
I have a C/C++ source file with conditional compilation. Before I ship it to customers I want to remove most of the #if statements, so that my customers do not need to worry about passing the right -D options to the compiler. I have this implemented and working in Python, but it only handles #ifdef and #ifndef statements properly. I need to add support for #if statements, but the syntax of #if is much more complex. (E.g. you can use &&, ||, !, brackets, relational operators, arithmetic, etc). Is there any existing open-source code to parse and evaluate #if statements? (Preferably in Python). The only implementation I know of is GCC, and that's much too complex for this task.
Parsing C++ preprocessor #if statements
0
0
0
3,386
287,379
2008-11-13T16:18:00.000
12
0
1
0
python,c++,c,parsing,c-preprocessor
287,405
5
false
0
0
How about just passing through the C preprocessor, and letting that do the job. It will get rid of all of them, so you might need to have a pre-preprocessor step and a post pre-processor step to protect things you don't want to be expanded. Change all #include to @include Pass file through preprocessor Change @include back to #include
2
4
0
I have a C/C++ source file with conditional compilation. Before I ship it to customers I want to remove most of the #if statements, so that my customers do not need to worry about passing the right -D options to the compiler. I have this implemented and working in Python, but it only handles #ifdef and #ifndef statements properly. I need to add support for #if statements, but the syntax of #if is much more complex. (E.g. you can use &&, ||, !, brackets, relational operators, arithmetic, etc). Is there any existing open-source code to parse and evaluate #if statements? (Preferably in Python). The only implementation I know of is GCC, and that's much too complex for this task.
Parsing C++ preprocessor #if statements
1
0
0
3,386
288,546
2008-11-13T22:19:00.000
1
1
0
0
python,email,connection,exchange-server,pywin32
288,569
4
true
0
0
I'm pretty sure this is going to be impossible without using Outlook and a MAPI profile. If you can sweet talk your mail admin into enabling IMAP on the Exchange server it would make your life a lot easier.
1
26
0
I need to connect to an Exchange mailbox in a Python script, without using any profile setup on the local machine (including using Outlook). If I use win32com to create a MAPI.Session I could logon (with the Logon() method) with an existing profile, but I want to just provide a username & password. Is this possible? If so, could someone provide example code? I would prefer if it only used the standard library and the pywin32 package. Unfortunately, enabling IMAP access for the Exchange server (and then using imaplib) is not possible. In case it is necessary: all the script will be doing is connecting to the mailbox, and running through the messages in the Inbox, retrieving the contents. I can handle writing the code for that, if I can get a connection in the first place! To clarify regarding Outlook: Outlook will be installed on the local machine, but it does not have any accounts setup (i.e. all the appropriate libraries will be available, but I need to operate independently from anything setup inside of Outlook).
Connect to Exchange mailbox with Python
1.2
0
1
107,535
288,695
2008-11-13T23:06:00.000
1
0
1
0
python,inheritance,oop
288,884
6
false
0
0
You should be fairly safe inheriting from a "builtin" class, as later modifications to these classes will usually be compatible with the current version. However, you should think seriously about wether you really want to tie your class to the additional functionality provided by the builtin class. As mentioned in another answer you should consider (perhaps even prefer) using delegation instead. As an example of why to avoid inheritance if you don't need it you can look at the java.util.Stack class. As it extends Vector it inherits all of the methods on Vector. Most of these methods break the contract implied by Stack, e.g. LIFO. It would have been much better to implement Stack using a Vector internally, only exposing Stack methods as the API. It would then have been easy to change the implementation to ArrayList or something else later, none of which is possible now due to inheritance.
4
6
0
I want to parse an Apache access.log file with a python program in a certain way, and though I am completely new to object-oriented programming, I want to start doing it now. I am going to create a class ApacheAccessLog, and the only thing I can imagine now, it will be doing is 'readline' method. Is it conventionally correct to inherit from the builtin file class in this case, so the class will behave just like an instance of the file class itself, or not? What is the best way of doing that?
Is it correct to inherit from built-in classes?
0.033321
0
0
1,007
288,695
2008-11-13T23:06:00.000
1
0
1
0
python,inheritance,oop
288,783
6
false
0
0
Although it is in some cases useful to inherit from builtins, the real question here is what you want to do with the output and what's your big-picture design. I would usually write a reader (that uses a file object) and spit out whatever data class I need to hold the information I just read. It's then easy to design that data class to fit in with the rest of my design.
4
6
0
I want to parse an Apache access.log file with a python program in a certain way, and though I am completely new to object-oriented programming, I want to start doing it now. I am going to create a class ApacheAccessLog, and the only thing I can imagine now, it will be doing is 'readline' method. Is it conventionally correct to inherit from the builtin file class in this case, so the class will behave just like an instance of the file class itself, or not? What is the best way of doing that?
Is it correct to inherit from built-in classes?
0.033321
0
0
1,007
288,695
2008-11-13T23:06:00.000
15
0
1
0
python,inheritance,oop
288,807
6
true
0
0
In this case I would use delegation rather than inheritance. It means that your class should contain the file object as an attribute and invoke a readline method on it. You could pass a file object in the constructor of the logger class. There are at least two reasons for this: Delegation reduces coupling, for example in place of file objects you can use any other object that implements a readline method (duck typing comes handy here). When inheriting from file the public interface of your class becomes unnecessarily broad. It includes all the methods defined on file even if these methods don't make sense in case of Apache log.
4
6
0
I want to parse an Apache access.log file with a python program in a certain way, and though I am completely new to object-oriented programming, I want to start doing it now. I am going to create a class ApacheAccessLog, and the only thing I can imagine now, it will be doing is 'readline' method. Is it conventionally correct to inherit from the builtin file class in this case, so the class will behave just like an instance of the file class itself, or not? What is the best way of doing that?
Is it correct to inherit from built-in classes?
1.2
0
0
1,007
288,695
2008-11-13T23:06:00.000
1
0
1
0
python,inheritance,oop
288,778
6
false
0
0
It is perfectly acceptable to inherit from a built in class. In this case I'd say you're right on the money. The log "is a" file so that tells you inheritance is ok.. General rule. Dog "is a"n animal, therefore inherit from animal. Owner "has a"n animal therefore don't inherit from animal.
4
6
0
I want to parse an Apache access.log file with a python program in a certain way, and though I am completely new to object-oriented programming, I want to start doing it now. I am going to create a class ApacheAccessLog, and the only thing I can imagine now, it will be doing is 'readline' method. Is it conventionally correct to inherit from the builtin file class in this case, so the class will behave just like an instance of the file class itself, or not? What is the best way of doing that?
Is it correct to inherit from built-in classes?
0.033321
0
0
1,007
291,448
2008-11-14T21:11:00.000
25
0
1
0
python
291,470
4
true
0
0
That's certainly possible. After the script is loaded/imported, the Python interpreter won't access it anymore, except when printing source line in a exception stack trace. Any pyc file will be regenerated the next time as the source file is newer than the pyc.
2
18
0
Is it possible for a python script to open its own source file and overwrite it? The idea was to have a very simple and very dirty way for a python script to download an update of itself so that the next time it is run it would be an updated version.
Is it possible for a running python program to overwrite itself?
1.2
0
0
6,179
291,448
2008-11-14T21:11:00.000
8
0
1
0
python
291,650
4
false
0
0
Actually, it's preferable that your application starts with a dummy checker-downloader that changes rarely (if ever); before running, it should check if any updates are available; if yes, then it would download them (typically the rest of the app would be modules) and then import them and start the app. This way, as soon as updates are available, you start the application and will run the latest version; otherwise, a restart of the application is required.
2
18
0
Is it possible for a python script to open its own source file and overwrite it? The idea was to have a very simple and very dirty way for a python script to download an update of itself so that the next time it is run it would be an updated version.
Is it possible for a running python program to overwrite itself?
1
0
0
6,179
291,467
2008-11-14T21:16:00.000
2
1
0
1
python,svn,file
291,477
1
true
0
0
I think it is easiest to check out (or, better, export) the source tree using the svn command line utility: you can use os.system to invoke it. There are also direct Python-to-svn API bindings, but I would advise against using them if you are new to Python. You can then traverse the checkout folder, e.g. using os.walk; the copying itself can be done with shutil.copy.
1
2
0
I would like my python script to search through a directory in SVN, locate the files ending with a particular extension (eg. *.exe), and copy these files to a directory that has been created in my C drive. How can I do this? I'm new to Python so a detailed response and/or point in the right direction would be very much appreciated. Follow-up: When using os.walk what parameter would I pass in to ensure that I'm copying files with a specific extension (eg. *.exe)?
Search directory in SVN for files with specific file extension and copy to another folder?
1.2
0
0
1,000
291,740
2008-11-14T23:12:00.000
43
0
1
0
python,text-files
2,203,797
16
false
0
0
linux has a split command split -l 100000 file.txt would split into files of equal 100,000 line size
2
32
0
I have a huge text file (~1GB) and sadly the text editor I use won't read such a large file. However, if I can just split it into two or three parts I'll be fine, so, as an exercise I wanted to write a program in python to do it. What I think I want the program to do is to find the size of a file, divide that number into parts, and for each part, read up to that point in chunks, writing to a filename.nnn output file, then read up-to the next line-break and write that, then close the output file, etc. Obviously the last output file just copies to the end of the input file. Can you help me with the key filesystem related parts: filesize, reading and writing in chunks and reading to a line-break? I'll be writing this code test-first, so there's no need to give me a complete answer, unless its a one-liner ;-)
How do I split a huge text file in python
1
0
0
96,451
291,740
2008-11-14T23:12:00.000
16
0
1
0
python,text-files
291,759
16
true
0
0
Check out os.stat() for file size and file.readlines([sizehint]). Those two functions should be all you need for the reading part, and hopefully you know how to do the writing :)
2
32
0
I have a huge text file (~1GB) and sadly the text editor I use won't read such a large file. However, if I can just split it into two or three parts I'll be fine, so, as an exercise I wanted to write a program in python to do it. What I think I want the program to do is to find the size of a file, divide that number into parts, and for each part, read up to that point in chunks, writing to a filename.nnn output file, then read up-to the next line-break and write that, then close the output file, etc. Obviously the last output file just copies to the end of the input file. Can you help me with the key filesystem related parts: filesize, reading and writing in chunks and reading to a line-break? I'll be writing this code test-first, so there's no need to give me a complete answer, unless its a one-liner ;-)
How do I split a huge text file in python
1.2
0
0
96,451
294,470
2008-11-16T22:11:00.000
5
1
0
1
python,linux,unix,process-management
294,535
2
false
0
0
Never directly scan /etc/passwd. For instance, on a Linux system I administer, the user accounts are not on /etc/passwd, but on a LDAP server. The correct way is to use getpwent/getgrent and related C functions (as in @TFKyle's answer), which will get the information on the correct way for each system (on Linux glibc, it reads /etc/nsswitch.conf to know which NSS dynamic libraries to load to get the information).
1
12
0
I need to set my process to run under 'nobody', I've found os.setuid(), but how do I find uid if I have login? I've found out that uids are in /etc/passwd, but maybe there is a more pythonic way than scanning /etc/passwd. Anybody?
How do I find userid by login (Python under *NIX)
0.462117
0
0
4,216
294,963
2008-11-17T05:44:00.000
2
1
1
0
python,performance,multithreading,internals
297,747
3
false
0
0
Reasoning about a system of this complexity will rarely produce the right answer. Measure the results, and use the setting that runs the fastest. If as you say, testing can't measure the difference in various settings of setcheckinterval, then why bother changing it? Only measurable differences are interesting. If your test run is too short to provide meaningful data, then make the run longer until it does.
1
1
0
I have a port scanning application that uses work queues and threads. It uses simple TCP connections and spends a lot of time waiting for packets to come back (up to half a second). Thus the threads don't need to fully execute (i.e. first half sends a packet, context switch, does stuff, comes back to thread which has network data waiting for it). I suspect I can improve performance by modifying the sys.setcheckinterval from the default of 100 (which lets up to 100 bytecodes execute before switching to another thread). But without knowing how many bytecodes are actually executing in a thread or function I'm flying blind and simply guessing values, testing and relying on the testing shows a measurable difference (which is difficult since the amount of code being executed is minimal; a simple socket connection, thus network jitter will likely affect any measurements more than changing sys.setcheckinterval). Thus I would like to find out how many bytecodes are in certain code executions (i.e. total for a function or in execution of a thread) so I can make more intelligent guesses at what to set sys.setcheckinterval to.
How do I count bytecodes in Python so I can modify sys.setcheckinterval appropriately
0.132549
0
0
728
295,135
2008-11-17T09:02:00.000
6
0
1
0
python,filenames,slug,sanitize
634,023
26
false
0
0
Though you have to be careful. It is not clearly said in your intro, if you are looking only at latine language. Some words can become meaningless or another meaning if you sanitize them with ascii characters only. imagine you have "forêt poésie" (forest poetry), your sanitization might give "fort-posie" (strong + something meaningless) Worse if you have to deal with chinese characters. "下北沢" your system might end up doing "---" which is doomed to fail after a while and not very helpful. So if you deal with only files I would encourage to either call them a generic chain that you control or to keep the characters as it is. For URIs, about the same.
3
379
0
I have a string that I want to use as a filename, so I want to remove all characters that wouldn't be allowed in filenames, using Python. I'd rather be strict than otherwise, so let's say I want to retain only letters, digits, and a small set of other characters like "_-.() ". What's the most elegant solution? The filename needs to be valid on multiple operating systems (Windows, Linux and Mac OS) - it's an MP3 file in my library with the song title as the filename, and is shared and backed up between 3 machines.
Turn a string into a valid filename?
1
0
0
230,947
295,135
2008-11-17T09:02:00.000
15
0
1
0
python,filenames,slug,sanitize
295,298
26
false
0
0
Keep in mind, there are actually no restrictions on filenames on Unix systems other than It may not contain \0 It may not contain / Everything else is fair game. $ touch " > even multiline > haha > ^[[31m red ^[[0m > evil" $ ls -la -rw-r--r-- 0 Nov 17 23:39 ?even multiline?haha??[31m red ?[0m?evil $ ls -lab -rw-r--r-- 0 Nov 17 23:39 \neven\ multiline\nhaha\n\033[31m\ red\ \033[0m\nevil $ perl -e 'for my $i ( glob(q{./*even*}) ){ print $i; } ' ./ even multiline haha red evil Yes, i just stored ANSI Colour Codes in a file name and had them take effect. For entertainment, put a BEL character in a directory name and watch the fun that ensues when you CD into it ;)
3
379
0
I have a string that I want to use as a filename, so I want to remove all characters that wouldn't be allowed in filenames, using Python. I'd rather be strict than otherwise, so let's say I want to retain only letters, digits, and a small set of other characters like "_-.() ". What's the most elegant solution? The filename needs to be valid on multiple operating systems (Windows, Linux and Mac OS) - it's an MP3 file in my library with the song title as the filename, and is shared and backed up between 3 machines.
Turn a string into a valid filename?
1
0
0
230,947
295,135
2008-11-17T09:02:00.000
6
0
1
0
python,filenames,slug,sanitize
295,354
26
false
0
0
Why not just wrap the "osopen" with a try/except and let the underlying OS sort out whether the file is valid? This seems like much less work and is valid no matter which OS you use.
3
379
0
I have a string that I want to use as a filename, so I want to remove all characters that wouldn't be allowed in filenames, using Python. I'd rather be strict than otherwise, so let's say I want to retain only letters, digits, and a small set of other characters like "_-.() ". What's the most elegant solution? The filename needs to be valid on multiple operating systems (Windows, Linux and Mac OS) - it's an MP3 file in my library with the song title as the filename, and is shared and backed up between 3 machines.
Turn a string into a valid filename?
1
0
0
230,947
295,670
2008-11-17T14:24:00.000
0
0
1
0
c#,python,oop,programming-languages
296,801
8
false
0
0
Python also has meta classes but that is more like a template class than a partial class. A good example of meta class usage is the Django ORM. All of your table models inherit from a base model class which also gets functionality included from a meta class. It is a pretty cool concept that enables an active record like pattern (is it full active record?).
3
8
0
What is and how can it be used in C#. Can you use the same concept in Python/Perl?
What is a partial class?
0
0
0
2,258
295,670
2008-11-17T14:24:00.000
1
0
1
0
c#,python,oop,programming-languages
295,704
8
false
0
0
Because python is a dynamic language you don't need a concept like partial class. In python is possible to extend object with functionality in runtime so it possible to break class declaration into different files
3
8
0
What is and how can it be used in C#. Can you use the same concept in Python/Perl?
What is a partial class?
0.024995
0
0
2,258
295,670
2008-11-17T14:24:00.000
0
0
1
0
c#,python,oop,programming-languages
295,735
8
false
0
0
A Partial type is a type whose declaration is separated across multiple files. It makes sense to use them if you have a big class, which is hard to handle and read for a typical developer, to separate that class definition in separate files and to put in each file a logically separated section of code (for instance all public methods and proprieties in one file, private in other, db handling code in third and so on..) No you don't have the same syntactical element in Python.
3
8
0
What is and how can it be used in C#. Can you use the same concept in Python/Perl?
What is a partial class?
0
0
0
2,258
296,490
2008-11-17T18:56:00.000
0
0
1
0
python,file
296,498
3
false
0
0
It is perfectly acceptable to have a 'cleanup()' function that you call at the end of your script, which will call 'os.remove()' on your files.
1
0
0
I would like to remove two files from a folder at the conclusion of my script. Do I need to create a function responsible for removing these two specific files? I would like to know in some detail how to use os.remove (if that is what I should use) properly. These two files will always be discarded at the conclusion of my script (which packages a series of files together in a zip format). Thanks in advance.
How do I remove a specific number of files using python (version 2.5)?
0
0
0
355
296,650
2008-11-17T19:48:00.000
8
1
0
1
java,python,performance,protocol-buffers,thrift
628,329
8
false
0
0
I did test performance of PB with number of other data formats (xml, json, default object serialization, hessian, one proprietary one) and libraries (jaxb, fast infoset, hand-written) for data binding task (both reading and writing), but thrift's format(s) was not included. Performance for formats with multiple converters (like xml) had very high variance, from very slow to pretty-darn-fast. Correlation between claims of authors and perceived performance was rather weak. Especially so for packages that made wildest claims. For what it is worth, I found PB performance to be bit over hyped (usually not by its authors, but others who only know who wrote it). With default settings it did not beat fastest textual xml alternative. With optimized mode (why is this not default?), it was bit faster, comparable with the fastest JSON package. Hessian was rather fast, textual json also. Properietary binary format (no name here, it was company internal) was the slowest. Java object serialization was fast for larger messages, less so for small objects (i.e. high fixed per-operation noverhead). With PB message size was compact, but given all trade-offs you have to do (data is not self-descriptive: if you lose the schema, you lose data; there are indexes of course, and value types, but from what you have reverse-engineer back to field names if you want), I personally would only choose it for specific use cases -- size-sensitive, closely coupled system where interface/format never (or very very rarely) changes. My opinion in this is that (a) implementation often matters more than specification (of data format), (b) end-to-end, differences between best-of-breed (for different formats) are usually not big enough to dictate the choice. That is, you may be better off choosing format+API/lib/framework you like using most (or has best tool support), find best implementation, and see if that works fast enough. If (and only if!) not, consider next best alternative. ps. Not sure what EJB3 here would be. Maybe just plain of Java serialization?
3
70
0
We're looking into transport/protocol solutions and were about to do various performance tests, so I thought I'd check with the community if they've already done this: Has anyone done server performance tests for simple echo services as well as serialization/deserialization for various messages sizes comparing EJB3, Thrift, and Protocol Buffers on Linux? Primarily languages will be Java, C/C++, Python, and PHP. Update: I'm still very interested in this, if anyone has done any further benchmarks please let me know. Also, very interesting benchmark showing compressed JSON performing similar / better than Thrift / Protocol Buffers, so I'm throwing JSON into this question as well.
Performance comparison of Thrift, Protocol Buffers, JSON, EJB, other?
1
0
0
64,229
296,650
2008-11-17T19:48:00.000
5
1
0
1
java,python,performance,protocol-buffers,thrift
297,193
8
false
0
0
If the raw net performance is the target, then nothing beats IIOP (see RMI/IIOP). Smallest possible footprint -- only binary data, no markup at all. Serialization/deserialization is very fast too. Since it's IIOP (that is CORBA), almost all languages have bindings. But I presume the performance is not the only requirement, right?
3
70
0
We're looking into transport/protocol solutions and were about to do various performance tests, so I thought I'd check with the community if they've already done this: Has anyone done server performance tests for simple echo services as well as serialization/deserialization for various messages sizes comparing EJB3, Thrift, and Protocol Buffers on Linux? Primarily languages will be Java, C/C++, Python, and PHP. Update: I'm still very interested in this, if anyone has done any further benchmarks please let me know. Also, very interesting benchmark showing compressed JSON performing similar / better than Thrift / Protocol Buffers, so I'm throwing JSON into this question as well.
Performance comparison of Thrift, Protocol Buffers, JSON, EJB, other?
0.124353
0
0
64,229
296,650
2008-11-17T19:48:00.000
4
1
0
1
java,python,performance,protocol-buffers,thrift
296,677
8
false
0
0
One of the things near the top of my "to-do" list for PBs is to port Google's internal Protocol Buffer performance benchmark - it's mostly a case of taking confidential message formats and turning them into entirely bland ones, and then doing the same for the data. When that's been done, I'd imagine you could build the same messages in Thrift and then compare the performance. In other words, I don't have the data for you yet - but hopefully in the next couple of weeks...
3
70
0
We're looking into transport/protocol solutions and were about to do various performance tests, so I thought I'd check with the community if they've already done this: Has anyone done server performance tests for simple echo services as well as serialization/deserialization for various messages sizes comparing EJB3, Thrift, and Protocol Buffers on Linux? Primarily languages will be Java, C/C++, Python, and PHP. Update: I'm still very interested in this, if anyone has done any further benchmarks please let me know. Also, very interesting benchmark showing compressed JSON performing similar / better than Thrift / Protocol Buffers, so I'm throwing JSON into this question as well.
Performance comparison of Thrift, Protocol Buffers, JSON, EJB, other?
0.099668
0
0
64,229
297,345
2008-11-17T23:27:00.000
1
1
1
0
python,zip
297,444
10
false
0
0
Some (many? most?) compression algorithms are based on looking at redundancies across the entire file. Some compression libraries will choose between several compression algorithms based on which works best on the file. I believe the ZipFile module does this, so it wants to see the entire file, not just pieces at a time. Hence, it won't work with generators or files to big to load in memory. That would explain the limitation of the Zipfile library.
1
23
0
I've got a large amount of data (a couple gigs) I need to write to a zip file in Python. I can't load it all into memory at once to pass to the .writestr method of ZipFile, and I really don't want to feed it all out to disk using temporary files and then read it back. Is there a way to feed a generator or a file-like object to the ZipFile library? Or is there some reason this capability doesn't seem to be supported? By zip file, I mean zip file. As supported in the Python zipfile package.
Create a zip file from a generator in Python?
0.019997
0
0
14,983
298,004
2008-11-18T06:32:00.000
1
0
1
1
java,python,jython,archive
298,027
2
false
1
0
You can use java.util.zip, when I was using Jython the built in zip library in python didn't work
1
1
0
Is there a neat archiving library that automatically handles archiving a folder or directories for you out there? I am using Jython, so Java libs are also open for use. -UPDATE- Also Im looking for timestamp archiving. ie archive-dir/2008/11/16/zipfilebypreference.zip then the next day call it again and it creates another folder. Im sure there is something out there on the internet, who knows?
python (jython) archiving library
0.099668
0
0
256
298,772
2008-11-18T13:52:00.000
8
0
0
0
javascript,python,django,google-app-engine,django-templates
304,627
16
false
1
0
For a dictionary, you're best of encoding to JSON first. You can use simplejson.dumps() or if you want to convert from a data model in App Engine, you could use encode() from the GQLEncoder library.
1
276
0
When I render a page using the Django template renderer, I can pass in a dictionary variable containing various values to manipulate them in the page using {{ myVar }}. Is there a way to access the same variable in Javascript (perhaps using the DOM, I don't know how Django makes the variables accessible)? I want to be able to lookup details using an AJAX lookup based on the values contained in the variables passed in.
Django Template Variables and Javascript
1
0
0
309,660
299,249
2008-11-18T16:22:00.000
1
1
0
1
python
299,262
2
false
0
0
In general: Use os.chdir to change the directory of the parent process, then os.system to run the jar file. If you need to keep Python's working directory stable, you need to chdir back to original working directory - you need to record that with os.getcwd(). On Unix: Create a child process with os.fork explicitly. In the parent, wait for the child with os.waitpid. In the child, use os.chdir, then os.exec to run java.
1
5
0
I am familiar with using the os.system to run from the command line. However, I would like to be able to run a jar file from inside of a specific folder, eg. my 'test' folder. This is because my jar (located in my 'test' folder) requires a file inside of my 'test' folder. So, how would I write a function in my script that does the following: c:\test>java -jar run_this.jar required_parameter.ext ? I'm a python newbie so details are greatly appreciated. Thanks in advance.
How can I get my python (version 2.5) script to run a jar file inside a folder instead of from command line?
0.099668
0
0
8,648
299,704
2008-11-18T18:39:00.000
0
0
1
0
python,debugging
2,537,067
16
false
0
0
Eric4 IDE also has a great built-in debugger.
6
53
0
I'm getting quite a few errors in my code. Consequently, I would like to be able to minimize them at the outset or see as many errors as possible before code execution. Is this possible and if so, how can I do this?
What are good ways to make my Python code run first time?
0
0
0
28,130
299,704
2008-11-18T18:39:00.000
4
0
1
0
python,debugging
300,397
16
false
0
0
The PyDev plugin for eclipse is my tool of choice. It recognizes simple syntax mistakes and indentation errors and underlines the error with a red line. It has a powerful debugger and even has a plugin called PyLint which warns you about dangerous code. Edit: It also has a user friendly stack trace on runtime errors, partial auto complete and some other nifty features. Edit again: I didn't notice that pydev was mentioned in the top post. I hope I brought something else to the table.
6
53
0
I'm getting quite a few errors in my code. Consequently, I would like to be able to minimize them at the outset or see as many errors as possible before code execution. Is this possible and if so, how can I do this?
What are good ways to make my Python code run first time?
0.049958
0
0
28,130
299,704
2008-11-18T18:39:00.000
5
0
1
0
python,debugging
299,732
16
false
0
0
Using assert statement liberally.
6
53
0
I'm getting quite a few errors in my code. Consequently, I would like to be able to minimize them at the outset or see as many errors as possible before code execution. Is this possible and if so, how can I do this?
What are good ways to make my Python code run first time?
0.062419
0
0
28,130
299,704
2008-11-18T18:39:00.000
7
0
1
0
python,debugging
299,727
16
false
0
0
Test early and test often. This doesn't necessarily mean to jump into the test driven design pool head first (though that's not such a bad idea). It just means, test your objects and methods as soon as you have something that works. Don't wait until you have a huge pile of code before doing testing. Invest some time in learning a testing framework. If it's trivial for you to type in a test case you'll more likely do it. If you don't have any sort of framework testing can be a pain so you'll avoid it. So, establish some good habits early on and you'll have fewer problems down the road.
6
53
0
I'm getting quite a few errors in my code. Consequently, I would like to be able to minimize them at the outset or see as many errors as possible before code execution. Is this possible and if so, how can I do this?
What are good ways to make my Python code run first time?
1
0
0
28,130
299,704
2008-11-18T18:39:00.000
15
0
1
0
python,debugging
299,753
16
false
0
0
All the really cool stuff is easily demonstrated in the interactive interpreter. I think this might be the "gold standard" for good design: Can you exercise your class interactively? If you can do stuff interactively, then you can write unittests and doctests with confidence that it's testable, simple, reliable. And, more important, you can explore it interactively. There's nothing better than the instant gratification that comes from typing code and seeing exactly what happens. The compiled language habits (write a bunch of stuff, debug a bunch of stuff, test a bunch of stuff) can be left behind. Instead, you can write a little bit of stuff, explore it, write a formal test and then attach your little bit of stuff to your growing final project. You still do overall design. But you don't squander time writing code that may or may not work. In Python you write code that works. If you're not sure, you play with it interactively until you're sure. Then you write code that works.
6
53
0
I'm getting quite a few errors in my code. Consequently, I would like to be able to minimize them at the outset or see as many errors as possible before code execution. Is this possible and if so, how can I do this?
What are good ways to make my Python code run first time?
1
0
0
28,130
299,704
2008-11-18T18:39:00.000
10
0
1
0
python,debugging
4,643,720
16
false
0
0
I am new to python, and have been trying several different debuggers. Here are the options I've come across so far: Eclipse with Pydev - If you're already using eclipse, this is probably the way to go. The debugger works well, and is pretty featureful. Komodo IDE - A light-weight python IDE. Basically a text editor + a debugger. It was really easy to figure out and be productive with immediately. WinPDB - Trying this one next. Looks very featureful, and I get to use whichever editor I choose. PDB - Haven't tried yet since I've read about how WinPDB is a better alternative. Ipython with %run command - I've used IPython, but not as a debugger like this. I need to try this out. (Thanks for the tip, EOL) Eric IDE - Also on the list to try. Old-school print, assert statements - Simple, useful, but not a full solution. Memory debugging - To debug memory problems, I've come across a few tools: objgraph - Will generate png's of reference graphs. Neat. There's other functionality as well, like: import objgraph;print(objgraph.show_most_common_types(limit=10)) will print the top 10 most common types in memory. gc module - Interact directly with the garbage collector. heapy - Heap analyzer. For example: from guppy import hpy; hp = hpy(); print(hp.heap()) will print the most common types, their memory usage, etc. This is a very incomplete list, but hopefully it's a good start.
6
53
0
I'm getting quite a few errors in my code. Consequently, I would like to be able to minimize them at the outset or see as many errors as possible before code execution. Is this possible and if so, how can I do this?
What are good ways to make my Python code run first time?
1
0
0
28,130
299,913
2008-11-18T19:51:00.000
4
1
0
0
java,php,python,dynamic-linking
300,035
2
true
1
0
"where I just can't figure out what model I need to produce the HTML form I want, which seems such a basic thing that I fear for my chances of doing anything more complex" Common problem. Root cause: Too much programming. Solution. Do less programming. Seriously. Define the Django model. Use the default admin pages to see if it's right. Fix the model. Regenerate the database. Look at the default admin pages. Repeat until the default admin pages work correctly and simply. Once it's right in the default admin pages, you have a model that works. It's testable. And the automatic stuff is hooked up correctly. Choices are defined correctly. Computations are in the model mmethods. Queries work. Now you can start working on other presentations of the data. Django generally starts (and ends) with the model. The forms, view and templates are derived from the model.
1
3
0
I've been trying to build a simple prototype application in Django, and am reaching the point of giving up, sadly, as it's just too complicated (I know it would be worth it in the long-run, but I really just don't have enough time available -- I need something up and running in a few days). So, I'm now thinking of going with PHP instead, as it's the method for creating dynamic web content I'm most familiar with, and I know I can get something working quickly. My application, while simple, is probably going to be doing some reasonably complex AI stuff, and it may be that libraries don't exist for what I need in PHP. So I'm wondering how easy / possible it is for a PHP script to "call" a Java program or Python script or a program or script in another language. It's not entirely clear to me what exactly I mean by "call" in this context, but I guess I probably mean that ideally I'd like to define a function in, let's say Java, and then be able to call it from PHP. If that's not possible, then I guess my best bet (assuming I do go with PHP) will be to pass control directly to the external program explicitly through a POST or GET to a CGI program or similar. Feel free to convince me I should stick with Django, although I'm really at the point where I just can't figure out what model I need to produce the HTML form I want, which seems such a basic thing that I fear for my chances of doing anything more complex... Alternatively, anyone who can offer any advice on linking PHP and other languages, that'll be grateful received.
Calling Java (or python or perl) from a PHP script
1.2
0
0
1,939
301,493
2008-11-19T10:35:00.000
2
1
0
0
java,.net,python,xml,ruby
301,538
9
false
1
0
either C# or VB.Net using LiNQ to XML. LiNQ to XML is very very powerful and easy to implement
1
21
0
We have developers with knowledge of these languages - Ruby , Python, .Net or Java. We are developing an application which will mainly handle XML documents. Most of the work is to convert predefined XML files into database tables, providing mapping between XML documents through database, creating reports from database etc. Which language will be the easiest and fastest to work with? (It is a web-app)
Which language is easiest and fastest to work with XML content?
0.044415
0
1
18,193
301,566
2008-11-19T11:00:00.000
1
0
0
0
python,database,postgresql,data-migration,turbogears
301,708
4
true
1
0
This always works and requires little thinking -- only patience. Make a backup. Actually make a backup. Everyone skips step 1 thinking that they have a backup, but they can never find it or work with it. Don't trust any backup that you can't recover from. Create a new database schema. Define your new structure from the ground up in the new schema. Ideally, you'll run a DDL script that builds the new schema. Don't have a script to build the schema? Create one and put it under version control. With SA, you can define your tables and it can build your schema for you. This is ideal, since you have your schema under version control in Python. Move data. a. For tables which did not change structure, move data from old schema to new schema using simple INSERT/SELECT statements. b. For tables which did change structure, develop INSERT/SELECT scripts to move the data from old to new. Often, this can be a single SQL statement per new table. In some cases, it has to be a Python loop with two open connections. c. For new tables, load the data. Stop using the old schema. Start using the new schema. Find every program that used the old schema and fix the configuration. Don't have a list of applications? Make one. Seriously -- it's important. Applications have hard-coded DB configurations? Fix that, too, while you're at it. Either create a common config file, or use some common environment variable or something to (a) assure consistency and (b) centralize the notion of "production". You can do this kind of procedure any time you do major surgery. It never touches the old database except to extract the data.
1
1
0
I am having a postgres production database in production (which contains a lot of Data). now I need to modify the model of the tg-app to add couple of new tables to the database. How do i do this? I am using sqlAlchemy.
How to update turbogears application production database
1.2
1
0
889
302,163
2008-11-19T15:08:00.000
2
0
0
1
python,gnome
302,168
2
true
0
0
Check out the Deskbar source code - they do this; afaik, they call out a C library that interacts with X11 to do the job
1
6
0
I would like to assign a global hotkey to my Python application, running in Gnome. How do I do that? All I can find are two year old posts saying, well, pretty much nothing :-)
Global hotkey for Python application in Gnome
1.2
0
0
1,770
302,983
2008-11-19T19:04:00.000
25
0
0
0
python,django,content-management-system
3,892,818
7
true
1
0
I have worked with all three (and more) and they are all built for different use cases IMHO. I would agree that these are the top-teir choices. The grid comparison at djangopluggables.com certainly can make evaluating each of these easier. django-cms is the most full-featured and is something you could actually hand over to clients without being irresponsible. Even though it has features for integrating other apps, it doesn't have the extensibility/integration of FeinCMS or the simplicity of django-page-cms. That being said, I think the consensus is that this is the best Open Source CMS for Django. However, it's docs are a little lacking. update: I have been told that integrating apps into DjangoCMS 2.1 has been improved. FeinCMS - Is a great set of tools for combining and building CMS functionality into your own apps. It's not "out of the box" at all, which means that you can integrate it however you want. It doesn't want to take over your urls.py or control how you route pages. It's probably a prototype for the next-generation of truly pluggable apps in Django. - We are moving from django-page-cms to FeinCMS because our primary models is high volume eCommerce and I have custom content-types I want to integrate that aren't blogs or flash. Good documentation and support as well. Django-page-cms - Is great if you want to just have some "About Us" pages around your principle application. Its menu system is not truly hierarchical and building your page presentation is up to you. But it's very simple, unobtrusive, and very easy to slap into your app and get a navigation going that clients can manage, or even for yourself. It has no docs that I know of, but you won't really need any. Read the code and you will get it all in 30 minutes or less. update Mezzanine - Is a very well designed CMS and one that I have finally settled on for most of my client work, mostly because it has an integrated eCommerce portion. But beyond that it has very extensible page models, and a custom admin interface that a client might be willing to use. It also has the best "out of the box" experience i.e. You can have a full fledged site up with one command.
1
14
0
So I have a relatively large (enough code that it would be easier to write this CMS component from scratch than to rewrite the app to fit into a CMS) webapp that I want to add basic Page/Menu/Media management too, I've seen several Django pluggables addressing this issue, but many seem targeted as full CMS platforms. Does anyone know of a plugin that can easily integrate with existing templates/views and still sports a powerful/comprehensive admin interface?
Best Django 'CMS' component for integration into existing site
1.2
0
0
12,696
303,200
2008-11-19T20:15:00.000
1
0
0
1
python,file
55,308,643
20
false
0
0
For Windows, if directory is not empty, and you have read-only files or you get errors like Access is denied The process cannot access the file because it is being used by another process Try this, os.system('rmdir /S /Q "{}"'.format(directory)) It's equivalent for rm -rf in Linux/Mac.
1
1,021
0
I am getting an 'access is denied' error when I attempt to delete a folder that is not empty. I used the following command in my attempt: os.remove("/folder_name"). What is the most effective way of removing/deleting a folder/directory that is not empty?
How do I remove/delete a folder that is not empty?
0.01
0
0
854,907
304,049
2008-11-20T01:12:00.000
0
1
1
0
python,emacs,ipython,emacs23
492,173
3
false
0
0
I've used ipython with emacs cvs (which has been emacs 23 for some time now) in my python development. I, however, use it the other way around: I call emacs from the ipython promt through the $EDITOR environment variable. I tried it the other way around, but got a bit tired of all the process buffers and what not. Emacs is great, but a command-line far more versatile.
1
24
0
Is there anyone out there using iPython with emacs 23? The documents on the emacs wiki are a bit of a muddle and I would be interested in hearing from anyone using emacs for Python development. Do you use the download python-mode and ipython.el? What do you recommend?
Emacs 23 and iPython
0
0
0
13,374
304,117
2008-11-20T01:56:00.000
7
0
0
0
python,google-app-engine,data-modeling
307,727
4
true
1
0
Thanks to both of you for your suggestions. I've implemented (first iteration) as follows. Not sure if it's the best approach, but it's working. Class A = Articles. Has a StringListProperty which can be queried on it's list elements Class B = Tags. One entity per tag, also keeps a running count of the total number of articles using each tag. Data modifications to A are accompanied by maintenance work on B. Thinking that counts being pre-computed is a good approach in a read-heavy environment.
2
8
0
Am wondering if anyone might provide some conceptual advice on an efficient way to build a data model to accomplish the simple system described below. Am somewhat new to thinking in a non-relational manner and want to try avoiding any obvious pitfalls. It's my understanding that a basic principal is that "storage is cheap, don't worry about data duplication" as you might in a normalized RDBMS. What I'd like to model is: A blog article which can be given 0-n tags. Many blog articles can share the same tag. When retrieving data would like to allow retrieval of all articles matching a tag. In many ways very similar to the approach taken here at stackoverflow. My normal mindset would be to create a many-to-may relationship between tags and blog articles. However, I'm thinking in the context of GAE that this would be expensive, although I have seen examples of it being done. Perhaps using a ListProperty containing each tag as part of the article entities, and a second data model to track tags as they're added and deleted? This way no need for any relationships and the ListProperty still allows queries where any list element matching will return results. Any suggestions on the most efficient way to approach this on GAE?
Data Modelling Advice for Blog Tagging system on Google App Engine
1.2
0
0
3,133
304,117
2008-11-20T01:56:00.000
1
0
0
0
python,google-app-engine,data-modeling
304,170
4
false
1
0
Many-to-many sounds reasonable. Perhaps you should try it first to see if it is actually expensive. Good thing about G.A.E. is that it will tell you when you are using too many cycles. Profiling for free!
2
8
0
Am wondering if anyone might provide some conceptual advice on an efficient way to build a data model to accomplish the simple system described below. Am somewhat new to thinking in a non-relational manner and want to try avoiding any obvious pitfalls. It's my understanding that a basic principal is that "storage is cheap, don't worry about data duplication" as you might in a normalized RDBMS. What I'd like to model is: A blog article which can be given 0-n tags. Many blog articles can share the same tag. When retrieving data would like to allow retrieval of all articles matching a tag. In many ways very similar to the approach taken here at stackoverflow. My normal mindset would be to create a many-to-may relationship between tags and blog articles. However, I'm thinking in the context of GAE that this would be expensive, although I have seen examples of it being done. Perhaps using a ListProperty containing each tag as part of the article entities, and a second data model to track tags as they're added and deleted? This way no need for any relationships and the ListProperty still allows queries where any list element matching will return results. Any suggestions on the most efficient way to approach this on GAE?
Data Modelling Advice for Blog Tagging system on Google App Engine
0.049958
0
0
3,133
304,216
2008-11-20T03:06:00.000
1
0
0
0
python,xml,search,celementtree
304,221
2
false
0
0
Have you looked at node.getiterator()?
1
2
0
Is there a way to find all nodes in a xml tree using cElementTree? The findall method works only for specified tags.
Find all nodes from an XML using cElementTree
0.099668
0
1
1,525
304,883
2008-11-20T10:27:00.000
4
0
0
1
python,linux,file-permissions
48,661,346
8
false
0
0
If one want to make executable hello.py first find the path where python is in your os with : which python it usually resides under "/usr/bin/python" folder. at the very first line of hello.py one should add : #!/usr/bin/python then through linux command chmod one should just make it executable like : chmod +x hello.py and execute with ./hello.py
2
105
0
I just installed a linux system (Kubuntu) and was wondering if there is a program to make python programs executable for linux.
What do I use on linux to make a python program executable
0.099668
0
0
222,482
304,883
2008-11-20T10:27:00.000
1
0
0
1
python,linux,file-permissions
56,267,080
8
false
0
0
I do the following: put #! /usr/bin/env python3 at top of script chmod u+x file.py Change .py to .command in file name This essentially turns the file into a bash executable. When you double-click it, it should run. This works in Unix-based systems.
2
105
0
I just installed a linux system (Kubuntu) and was wondering if there is a program to make python programs executable for linux.
What do I use on linux to make a python program executable
0.024995
0
0
222,482
305,359
2008-11-20T13:52:00.000
2
0
1
0
python,types,sequences
312,368
12
false
0
0
I'm new here so I don't know what's the correct way to do it. I want to answer my answers: The problem with all of the above mentioned ways is that str is considered a sequence (it's iterable, has __getitem__, etc.) yet it's usually treated as a single item. For example, a function may accept an argument that can either be a filename or a list of filenames. What's the most Pythonic way for the function to detect the first from the latter? Should I post this as a new question? Edit the original one?
2
18
0
I want to write a function that accepts a parameter which can be either a sequence or a single value. The type of value is str, int, etc., but I don't want it to be restricted to a hardcoded list. In other words, I want to know if the parameter X is a sequence or something I have to convert to a sequence to avoid special-casing later. I could do type(X) in (list, tuple) but there may be other sequence types I'm not aware of, and no common base class. -N. Edit: See my "answer" below for why most of these answers don't help me. Maybe you have something better to suggest.
Correct way to detect sequence parameter?
0.033321
0
0
5,050
305,359
2008-11-20T13:52:00.000
3
0
1
0
python,types,sequences
305,526
12
false
0
0
In cases like this, I prefer to just always take the sequence type or always take the scalar. Strings won't be the only types that would behave poorly in this setup; rather, any type that has an aggregate use and allows iteration over its parts might misbehave.
2
18
0
I want to write a function that accepts a parameter which can be either a sequence or a single value. The type of value is str, int, etc., but I don't want it to be restricted to a hardcoded list. In other words, I want to know if the parameter X is a sequence or something I have to convert to a sequence to avoid special-casing later. I could do type(X) in (list, tuple) but there may be other sequence types I'm not aware of, and no common base class. -N. Edit: See my "answer" below for why most of these answers don't help me. Maybe you have something better to suggest.
Correct way to detect sequence parameter?
0.049958
0
0
5,050
305,647
2008-11-20T15:28:00.000
0
0
1
1
python,windows
305,679
7
false
0
0
Does the app have any preferences, settings or options that the user can specify? If so, add an option where the user can specify the location of the data, with a default of the current Windows temp directory. There's always a chance they may not have enough space on the drive with the temp directory, and would need to use a different drive/directory.
1
3
0
My application caches some data on disk. Because the cache may be large, it should not be stored on a network drive. It should persist between invocations of the application. I have a mechanism for the user to choose a location, but would like the default to be sensible and "the right thing" for the platform. What is the appropriate location for such a cache? Is there an API for determining the appropriate location? How do I call it from Python?
Appropriate location for my application's cache on Windows
0
0
0
955
306,456
2008-11-20T19:02:00.000
0
0
0
1
python,gtk,pygtk
306,866
2
false
0
1
The panel you are referring to is the GNOME panel. So this is a GNOME question, not a GTK question. There is not a well-defined concept of "multi-window application" in GNOME that I know of. The panel task list is probably build by querying the window manager for the list of windows and grouping the windows by their "class" property. There are also various window manager hints that must be taken into account, for example to ignore panels and other utility windows. In your place, I would look at the source code of the taskbar applet. There is maybe some documentation somewhere that covers the status-quo, but I do know where it would be.
2
2
0
How can I get a list of the running applications? I'm referring to the ones in the panel at the bottom of the screen.
How can I get a list of the running applications with GTK?
0
0
0
368
306,456
2008-11-20T19:02:00.000
3
0
0
1
python,gtk,pygtk
307,046
2
true
0
1
I believe what you are looking for is libwnck
2
2
0
How can I get a list of the running applications? I'm referring to the ones in the panel at the bottom of the screen.
How can I get a list of the running applications with GTK?
1.2
0
0
368
306,811
2008-11-20T20:47:00.000
2
1
0
0
python,file,zip
307,091
1
true
0
0
Whatever you pass as zip_file to your function will be the file that the ZipFile object will write to. So if you pass it a full path, then it will be put there. If you pass it just a filename, then it will be written to that filename under the current working path. It sounds like you just need to make sure that zip_file is an absolute path.
1
1
0
I have been able to zip the contents of my folder. But I would like the zipped file to remain in the folder that was just compressed. For example, I've zipped a folder called test in my C: drive. But I would like my "test.zip" file to be contained in C:\test. How can I do this? Thanks in advance. clarification of question with code example: Someone kindly pointed out that my question is confusing, but for a python newbie a lot of things are confusing :) - my advance apologies if this question is too basic or the answer is obvious. I don't know how I can ensure that the resulting zip file is inside the folder that has been zipped. In other words, I would like the zip process to take place in 'basedir.' That way the user does not waste time searching for it somewhere on the C drive. def zip_folder(basedir, zip_file): z = zipfile.ZipFile(zip_file, 'w', zipfile.ZIP_DEFLATED) for dirpath, dirnames, filenames in os.walk(basedir): print "zipping files:" for fn in filenames: print fn absfn = os.path.join(dirpath, fn) z.write(absfn) z.close
With Python, how can I ensure that compression of a folder takes place within a particular folder?
1.2
0
0
228
307,305
2008-11-20T23:40:00.000
2
1
1
0
python,audio,platform-independent
1,852,392
10
false
0
0
wxPython has support for playing wav files on Windows and Unix - I am not sure if this includes Macs. However it only support wav files as far as I can tell - it does not support other common formats such as mp3 or ogg.
1
111
0
What's the easiest way to play a sound file (.wav) in Python? By easiest I mean both most platform independent and requiring the least dependencies. pygame is certainly an option, but it seems overkill for just sound.
Play a Sound with Python
0.039979
0
0
468,055
308,254
2008-11-21T09:26:00.000
1
0
1
0
python,ipython
45,552,382
5
false
0
0
I find the simplest way to specify which python version to use is to explicitly call the ipython script using that version. To do this, you may need to know the path to the ipython script, which you can find by running which ipython. Then simply run python <path-to-ipython> to start ipython.
1
10
0
I am running an Ubuntu 8.10, using Python 2.5 out of the box. This is fine from the system point of view, but I need Python2.4 since I dev on Zope / Plone. Well, installing python2.4 is no challenge, but I can't find a (clean) way to make iPython use it : no option in the man nor in the config file. Before, there was a ipython2.4 package but it is deprecated.
How to force iPython to use an older version of Python?
0.039979
0
0
9,837
308,605
2008-11-21T12:24:00.000
59
0
0
0
python,django,apache,rest
308,785
11
true
1
0
I'm thinking of falling back to simply writing view functions in Django that return JSON results. Explicit Portable to other frameworks Doesn't require patching Django
6
51
0
I've got a Django application that works nicely. I'm adding REST services. I'm looking for some additional input on my REST strategy. Here are some examples of things I'm wringing my hands over. Right now, I'm using the Django-REST API with a pile of patches. I'm thinking of falling back to simply writing view functions in Django that return JSON results. I can also see filtering the REST requests in Apache and routing them to a separate, non-Django server instance. Please nominate one approach per answer so we can vote them up or down.
Adding REST to Django
1.2
0
0
28,236
308,605
2008-11-21T12:24:00.000
4
0
0
0
python,django,apache,rest
308,885
11
false
1
0
Scrap the Django REST api and come up with your own open source project that others can contribute to. I would be willing to contribute. I have some code that is based on the forms api to do REST.
6
51
0
I've got a Django application that works nicely. I'm adding REST services. I'm looking for some additional input on my REST strategy. Here are some examples of things I'm wringing my hands over. Right now, I'm using the Django-REST API with a pile of patches. I'm thinking of falling back to simply writing view functions in Django that return JSON results. I can also see filtering the REST requests in Apache and routing them to a separate, non-Django server instance. Please nominate one approach per answer so we can vote them up or down.
Adding REST to Django
0.072599
0
0
28,236
308,605
2008-11-21T12:24:00.000
1
0
0
0
python,django,apache,rest
9,027,830
11
false
1
0
TastyPie looks quite interesting and promising. It goes well with Django.
6
51
0
I've got a Django application that works nicely. I'm adding REST services. I'm looking for some additional input on my REST strategy. Here are some examples of things I'm wringing my hands over. Right now, I'm using the Django-REST API with a pile of patches. I'm thinking of falling back to simply writing view functions in Django that return JSON results. I can also see filtering the REST requests in Apache and routing them to a separate, non-Django server instance. Please nominate one approach per answer so we can vote them up or down.
Adding REST to Django
0.01818
0
0
28,236
308,605
2008-11-21T12:24:00.000
1
0
0
0
python,django,apache,rest
736,425
11
false
1
0
you could try making a generic functions that process the data (like parand mentioned) which you can call from the views that generate the web pages, as well as those that generate the json/xml/whatever
6
51
0
I've got a Django application that works nicely. I'm adding REST services. I'm looking for some additional input on my REST strategy. Here are some examples of things I'm wringing my hands over. Right now, I'm using the Django-REST API with a pile of patches. I'm thinking of falling back to simply writing view functions in Django that return JSON results. I can also see filtering the REST requests in Apache and routing them to a separate, non-Django server instance. Please nominate one approach per answer so we can vote them up or down.
Adding REST to Django
0.01818
0
0
28,236
308,605
2008-11-21T12:24:00.000
2
0
0
0
python,django,apache,rest
312,910
11
false
1
0
I ended up going with my own REST API framework for Django (that I'd love to get rid of if I can find a workable alternative), with a few custom views thrown in for corner cases I didn't want to deal with. It's worked out ok. So a combination of 1 and 2; without some form of framework you'll end up writing the same boilerplate for the common cases. I've also done a few stand-alone APIs. I like having them as stand-alone services, but the very fact that they stand alone from the rest of the code leads to them getting neglected. No technical reason; simply out-of-sight, out-of-mind. What I'd really like to see is an approach that unifies Django forms and REST APIs, as they often share a lot of logic. Conceptually if your app exposes something in HTML it likely wants to expose it programmatically as well.
6
51
0
I've got a Django application that works nicely. I'm adding REST services. I'm looking for some additional input on my REST strategy. Here are some examples of things I'm wringing my hands over. Right now, I'm using the Django-REST API with a pile of patches. I'm thinking of falling back to simply writing view functions in Django that return JSON results. I can also see filtering the REST requests in Apache and routing them to a separate, non-Django server instance. Please nominate one approach per answer so we can vote them up or down.
Adding REST to Django
0.036348
0
0
28,236
308,605
2008-11-21T12:24:00.000
3
0
0
0
python,django,apache,rest
312,544
11
false
1
0
I'm thinking of falling back to simply writing view functions in Django that return JSON results. I would go with that .. Ali A summed it pretty well. The main point for me is beign explicit. I would avoid using a function that automatically converts an object into json, what if the object has a reference to a user and somehow the password (even if it's hashed) go into the json snippit?
6
51
0
I've got a Django application that works nicely. I'm adding REST services. I'm looking for some additional input on my REST strategy. Here are some examples of things I'm wringing my hands over. Right now, I'm using the Django-REST API with a pile of patches. I'm thinking of falling back to simply writing view functions in Django that return JSON results. I can also see filtering the REST requests in Apache and routing them to a separate, non-Django server instance. Please nominate one approach per answer so we can vote them up or down.
Adding REST to Django
0.054491
0
0
28,236
308,912
2008-11-21T14:22:00.000
2
0
1
0
python,optimization
308,964
4
false
0
0
The big difference is that tuples are immutable, while lists and dictionaries are mutable data structures. This means that tuples are also faster, so if you have a collection of items that doesn't change, you should prefer them over lists.
3
3
0
Is there any performance advantage to using lists over dictionaries over tuples in Python? If I'm optimising for speed, is there any reason to prefer one over another?
Python data structures overhead/performance
0.099668
0
0
1,837
308,912
2008-11-21T14:22:00.000
20
0
1
0
python,optimization
308,982
4
true
0
0
Rich, Lists and dicts are beasts suitable for different needs. Make sure you don't use lists for linear searches where dicts hashes are perfect, because it's way slower. Also, if you just need a list of elements to traverse, don't use dicts because it will take much more space than lists. That may sound obvious, but picking the correct data structures algorithmically has much higher performance gains that micro-optimization due to more efficient compiled code layouts, etc. If you search in a list in O(n) instead of in a dict in O(1), micro-optimizations won't save you.
3
3
0
Is there any performance advantage to using lists over dictionaries over tuples in Python? If I'm optimising for speed, is there any reason to prefer one over another?
Python data structures overhead/performance
1.2
0
0
1,837
308,912
2008-11-21T14:22:00.000
6
0
1
0
python,optimization
308,936
4
false
0
0
Tuples will be slightly faster to construct for a small number of elements. Although actually most of the gains will be in memory used rather than CPU cycles, since tuples require less space than lists. With that being said, the performance difference should be negligible, and in general you shouldn't worry about these kinds of micro-optimizations until you've profiled your code and identified a section of code that is a bottleneck.
3
3
0
Is there any performance advantage to using lists over dictionaries over tuples in Python? If I'm optimising for speed, is there any reason to prefer one over another?
Python data structures overhead/performance
1
0
0
1,837
309,135
2008-11-21T15:38:00.000
8
1
1
0
python,editor,notepad++,komodo,komodoedit
314,915
9
false
0
0
I use Komodo edit. The main reasons are: Intellisense (not as good as VisualStudio, but Python's a hard language to do intellisense for) and cross-platform compatibility. It's nice being able to use the same editor on my Windows machine, my linux machine, and my macbook with little to no change in feel.
8
16
0
I'm using Notepad++ for python development, and few days ago I found out about free Komodo Edit. I need Pros and Cons for Python development between this two editors...
Komodo Edit and Notepad++ ::: Pros & Cons ::: Python dev
1
0
0
27,320
309,135
2008-11-21T15:38:00.000
9
1
1
0
python,editor,notepad++,komodo,komodoedit
314,865
9
false
0
0
I just downloaded and started using Komodo Edit. I've been using Notepad++ for awhile. Here is what I think about some of the features: Komodo Edit Pros: You can jump to a function definition, even if it's in another file (I love this) There is a plugin that displays the list of classes, functions and such for the current file on the side. Notepad++ used to have a plugin like this, but it no longer works with the current version and hasn't been updated in a while. Notepad++ Pros: If you select a word, it will highlight all of those words in the current document (makes it easier to find misspellings), without having to hit Ctrl+F. When working with HTML, when the cursor is on/in a tag, the starting and ending tags are both highlighted Anyone know if either of those last 2 things is possible in Komodo Edit?
8
16
0
I'm using Notepad++ for python development, and few days ago I found out about free Komodo Edit. I need Pros and Cons for Python development between this two editors...
Komodo Edit and Notepad++ ::: Pros & Cons ::: Python dev
1
0
0
27,320
309,135
2008-11-21T15:38:00.000
1
1
1
0
python,editor,notepad++,komodo,komodoedit
500,622
9
false
0
0
If I had to choose between Notepad++ and Komodo i would choose PyScripter ;.) Seriously I consider PyScripter as a great alternative...
8
16
0
I'm using Notepad++ for python development, and few days ago I found out about free Komodo Edit. I need Pros and Cons for Python development between this two editors...
Komodo Edit and Notepad++ ::: Pros & Cons ::: Python dev
0.022219
0
0
27,320
309,135
2008-11-21T15:38:00.000
4
1
1
0
python,editor,notepad++,komodo,komodoedit
314,871
9
false
0
0
A downside I found of Notepad++ for Python is that it tends (for me) to silently mix tabs and spaces. I know this is configurable, but it caught me out, especially when trying to work with other people using different editors / IDE's, so take care.
8
16
0
I'm using Notepad++ for python development, and few days ago I found out about free Komodo Edit. I need Pros and Cons for Python development between this two editors...
Komodo Edit and Notepad++ ::: Pros & Cons ::: Python dev
0.088656
0
0
27,320
309,135
2008-11-21T15:38:00.000
1
1
1
0
python,editor,notepad++,komodo,komodoedit
311,426
9
false
0
0
I haven't used Komodo yet (the download never quite finished on the slow connection I was on at the time), but I use Eclipse with PyDev regularly and enjoy the "IDE" features described by the other respondents. However, I'm also regularly frustrated by how much of a resource hog it is. I downloaded Notepad++ recently (much smaller download size ;-) ) and have been enjoying it quite a bit. The editor itself is nice and fast and it looks to be extensible. I'm hoping to copy some of my favorite features from IDE into Notepad++ and migrate, at some distant point in the future.
8
16
0
I'm using Notepad++ for python development, and few days ago I found out about free Komodo Edit. I need Pros and Cons for Python development between this two editors...
Komodo Edit and Notepad++ ::: Pros & Cons ::: Python dev
0.022219
0
0
27,320
309,135
2008-11-21T15:38:00.000
5
1
1
0
python,editor,notepad++,komodo,komodoedit
309,140
9
false
0
0
As far as I know , Notepad++ doesn't show you the docstring each method has .
8
16
0
I'm using Notepad++ for python development, and few days ago I found out about free Komodo Edit. I need Pros and Cons for Python development between this two editors...
Komodo Edit and Notepad++ ::: Pros & Cons ::: Python dev
0.110656
0
0
27,320
309,135
2008-11-21T15:38:00.000
7
1
1
0
python,editor,notepad++,komodo,komodoedit
501,832
9
false
0
0
I use both Komodo Edit and Notepad++. Notepad++ is a lot quicker to launch and it's more lightweight, so I often use it for quick one-off editing. I use Komodo Edit for major projects, like my django and wxPython applications. KE is a full-featured IDE, so it has a lot more features. Main advantages of Komodo Edit for programming Python: Manage groups of files as projects Use custom commands to run files, run nosetests/pylint, etc. Auto complete & syntax checking Mozilla extension system, with several useful extensions available Write macros in JavaScript or Python Spell checking Some of the little things that Notepad++ is missing for Python development: Doesn't auto-indent after a colon You can't set tabs/spaces on a file-type basis (I like to use tabs for HTML) No code completion or tooltips No on-the-fly syntax checking
8
16
0
I'm using Notepad++ for python development, and few days ago I found out about free Komodo Edit. I need Pros and Cons for Python development between this two editors...
Komodo Edit and Notepad++ ::: Pros & Cons ::: Python dev
1
0
0
27,320
309,135
2008-11-21T15:38:00.000
-4
1
1
0
python,editor,notepad++,komodo,komodoedit
310,252
9
false
0
0
Downloaded both myself. Like Komodo better. Komodo Pros: Like it better. Does more. Looks like an IDE. Edits Django templates Notepad++ Cons: Don't like it as much. Does less. Looks less like and IDE.
8
16
0
I'm using Notepad++ for python development, and few days ago I found out about free Komodo Edit. I need Pros and Cons for Python development between this two editors...
Komodo Edit and Notepad++ ::: Pros & Cons ::: Python dev
-1
0
0
27,320
309,412
2008-11-21T16:44:00.000
1
0
1
0
python,windows,setuptools
897,332
14
false
0
0
OP option 1 did not work for me. However doing setup.py install as mentioned by NathanD did do the trick. Maybe that should become option 1? Werner
4
85
0
Is there any way to install Setuptools for Python 2.6 in Windows without having an exe installer? There isn't one built at the moment, and the maintainer of Setuptools has stated that it will probably be a while before he'll get to it. Does anyone know of a way to install it anyway?
How do I set up Setuptools for Python 2.6 on Windows?
0.014285
0
0
90,082
309,412
2008-11-21T16:44:00.000
1
0
1
0
python,windows,setuptools
706,069
14
false
0
0
The "first option" (4 steps: download, extract, run, verify PATH) didn't work on my Windows Server 2008 x64 machine with Python 2.6 32 bit installed, nor did it work on my Vista x64 machine with Python 2.6 32 bit installed. The "second option (5 steps: download, extract, extract, run, verify PATH) worked on both Windows Server 2008 x64 and on Windows Vista x64. Thanks a bunch for providing the instructions!
4
85
0
Is there any way to install Setuptools for Python 2.6 in Windows without having an exe installer? There isn't one built at the moment, and the maintainer of Setuptools has stated that it will probably be a while before he'll get to it. Does anyone know of a way to install it anyway?
How do I set up Setuptools for Python 2.6 on Windows?
0.014285
0
0
90,082
309,412
2008-11-21T16:44:00.000
0
0
1
0
python,windows,setuptools
817,335
14
false
0
0
Second option worked for me. Two notes: a. After installing, when you using easy_install in vista, do so as administrator. (Right click on your command line shortcut and click "run as administrator"). I had trouble trying to run easy_install without doing that. b. He means use ez_setup from setuptools-0.6c9.tar.gz
4
85
0
Is there any way to install Setuptools for Python 2.6 in Windows without having an exe installer? There isn't one built at the moment, and the maintainer of Setuptools has stated that it will probably be a while before he'll get to it. Does anyone know of a way to install it anyway?
How do I set up Setuptools for Python 2.6 on Windows?
0
0
0
90,082
309,412
2008-11-21T16:44:00.000
10
0
1
0
python,windows,setuptools
675,337
14
false
0
0
The Nov. 21 answer didn't work for me. I got it working on my 64 bit Vista machine by following the Method 1 instructions, except for Step 3 I typed: setup.py install So, in summary, I did: Download setuptools-0.6c9.tar.gz Use 7-zip to extract it to a folder (directory) outside your Windows Python installation folder At a DOS (command) prompt, cd to your the newly created setuptools-0.6c9 folder and type "setup.py install" (without the quotes). Ensure that your PATH includes the appropriate C:\Python2X\Scripts directory
4
85
0
Is there any way to install Setuptools for Python 2.6 in Windows without having an exe installer? There isn't one built at the moment, and the maintainer of Setuptools has stated that it will probably be a while before he'll get to it. Does anyone know of a way to install it anyway?
How do I set up Setuptools for Python 2.6 on Windows?
1
0
0
90,082
310,118
2008-11-21T20:37:00.000
4
0
1
1
python,linux,environment-variables
310,299
3
false
0
0
For accessing and setting environment variables, read up on the os.environ dictionary. You can also use os.putenv to set an environment variable.
2
1
0
I need to set an environment variable in Python and find the address in memory where it is located. Since it's on Linux, I don't mind about using libraries that only work consistently on Linux (if that's the only way). How would you do this? Edit: The scope of the problem is as follows: I'm trying to hack a program for class, and essentially I'm putting my shellcode into an environment variable and then overwriting one byte on the victim code with the address of my environment variable. I need to find a way to automate this in Python, so my question is two-fold: Is there a way to get the address in memory of an environment variable? Can this only be done in bash/C or can I do it purely in Python?
Python - Setting / Getting Environment Variables and Addrs
0.26052
0
0
10,481
310,118
2008-11-21T20:37:00.000
0
0
1
1
python,linux,environment-variables
310,717
3
false
0
0
Pass the address itself in an environment variable, and just read it with os.getenv().
2
1
0
I need to set an environment variable in Python and find the address in memory where it is located. Since it's on Linux, I don't mind about using libraries that only work consistently on Linux (if that's the only way). How would you do this? Edit: The scope of the problem is as follows: I'm trying to hack a program for class, and essentially I'm putting my shellcode into an environment variable and then overwriting one byte on the victim code with the address of my environment variable. I need to find a way to automate this in Python, so my question is two-fold: Is there a way to get the address in memory of an environment variable? Can this only be done in bash/C or can I do it purely in Python?
Python - Setting / Getting Environment Variables and Addrs
0
0
0
10,481
310,199
2008-11-21T21:08:00.000
0
0
1
0
python,regex
310,513
6
false
0
0
if the letters are unimportant, you could try \w\d\d\d\w\w\d\d_test.ext which would match the letter/number pattern, or b\d\d\dcv\d\d_test.ext or some mix of the two.
2
3
0
I am battling regular expressions now as I type. I would like to determine a pattern for the following example file: b410cv11_test.ext. I want to be able to do a search for files that match the pattern of the example file aforementioned. Where do I start (so lost and confused) and what is the best way of arriving at a solution that best matches the file pattern? Thanks in advance. Further clarification of question: I would like the pattern to be as follows: must start with 'b', followed by three digits, followed by 'cv', followed by two digits, then an underscore, followed by 'release', followed by .'ext'
How can I translate the following filename to a regular expression in Python?
0
0
0
987
310,199
2008-11-21T21:08:00.000
1
0
1
0
python,regex
310,267
6
false
0
0
Your question is a bit unclear. You say you want a regular expression, but could it be that you want a glob-style pattern you can use with commands like ls? glob expressions and regular expressions are similar in concept but different in practice (regular expressions are considerably more powerful, glob style patterns are easier for the most common cases when looking for files. Also, what do you consider to be the pattern? Certainly, * (glob) or .* (regex) will match the pattern. Also, _test.ext (glob) or ._test.ext (regexp) pattern would match, as would many other variations. Can you be more specific about the pattern? For example, you might describe it as "b, followed by digits, followed by cv, followed by digits ..." Once you can precisely explain the pattern in your native language (and that must be your first step), it's usually a fairly straight-forward task to translate that into a glob or regular expression pattern.
2
3
0
I am battling regular expressions now as I type. I would like to determine a pattern for the following example file: b410cv11_test.ext. I want to be able to do a search for files that match the pattern of the example file aforementioned. Where do I start (so lost and confused) and what is the best way of arriving at a solution that best matches the file pattern? Thanks in advance. Further clarification of question: I would like the pattern to be as follows: must start with 'b', followed by three digits, followed by 'cv', followed by two digits, then an underscore, followed by 'release', followed by .'ext'
How can I translate the following filename to a regular expression in Python?
0.033321
0
0
987
310,224
2008-11-21T21:18:00.000
0
0
1
0
python,installation,wxpython,cygwin,compilation
4,467,468
4
false
0
1
Isn't the whole point of using wxPython being to use WxWidgets? Isn't the whole point of using THAT being to have a cross platform GUI library? In other words, forget about X11, and just use the native wxPython on windows. If you want to avoid requiring the user to install wxPython and its dependencies, consider writing an installer. Alternatively, investigate py2exe to "compile" python to an .exe file (plus supporting .zip and .dll files), which is much more ammendable to "installing by merely copying files".
3
4
0
I am using CYGWIN as a platform and would like to use wxPython. Is there a way to get the source compiled and working in cygwin?
How do you compile wxPython under cygwin?
0
0
0
3,640
310,224
2008-11-21T21:18:00.000
0
0
1
0
python,installation,wxpython,cygwin,compilation
11,237,925
4
false
0
1
I tried another solution for using wxPython in cygwin: I installed python27 and wxPython in Windows7 Did "echo 'export PATH=/cygdrive/c/Python27/:$PATH'>>~/.bashrc" Restart cygwin It works. Cheer! I don't know if any other Path should be added, but my program was executed on Fedora and it works on there.
3
4
0
I am using CYGWIN as a platform and would like to use wxPython. Is there a way to get the source compiled and working in cygwin?
How do you compile wxPython under cygwin?
0
0
0
3,640
310,224
2008-11-21T21:18:00.000
3
0
1
0
python,installation,wxpython,cygwin,compilation
310,365
4
false
0
1
You would need a full working X environment to get it to work. It would be much easier to just use Python and wxPython under plain vanilla Windows. Do you have a special case?
3
4
0
I am using CYGWIN as a platform and would like to use wxPython. Is there a way to get the source compiled and working in cygwin?
How do you compile wxPython under cygwin?
0.148885
0
0
3,640
310,759
2008-11-22T02:26:00.000
0
1
0
0
python,django,pylons,snmp,turbogears
541,516
2
false
1
0
or you can start building your own solution (like me), you will be surprised how much can you do with few lines of code using for instance cherryp for web server, pysnmp, and python rrd module.
1
1
0
Comparable to cacti or mrtg.
Does anyone know of a python based web ui for snmp monitoring?
0
0
1
1,942
312,928
2008-11-23T20:39:00.000
2
0
0
1
python,windows,apache,fastcgi
318,517
3
false
0
0
You might find it easier to ditch FastCGI altogether and just run a python webserver on a localhost port. Then just use mod_rewrite to map the apache urls to the internal webserver. (I started offering FastCGI at my hosting company and to my surprise, nearly everyone ditched it in favor of just running their own web server on the ports I provided them.)
1
6
0
I need to run a simple request/response python module under an existing system with windows/apache/FastCGI. All the FastCGI wrappers for python I tried work for Linux only (they use socket.fromfd() and other such shticks). Is there a wrapper that runs under windows?
Python as FastCGI under windows and apache
0.132549
0
1
3,212
314,234
2008-11-24T14:17:00.000
1
0
0
0
python,django,jvm,jython
315,110
4
false
1
0
I have recently started working on an open source desktop project in my spare time. So this may not apply. I came to the same the question. I decided that I should write as much of the code as possible in python (and Django) and target all the platforms CPython, Jython, and IronPython. Then, I decided that I would write plugins that would interface with libraries on different implementations (for example, different GUI libraries). Why? I decided early on that longevity of my code may depend on targeting not only CPython but also virtual machines. For today's purposes CPython is the way to go because of speed, but who knows about tomorrow. If you code is flexible enough, you may not have to decide on targeting one. The downside to this approach is that you will have more code to create and maintain.
2
14
0
The background I'm building a fair-sized web application with a friend in my own time, and we've decided to go with the Django framework on Python. Django provides us with a lot of features we're going to need, so please don't suggest alternative frameworks. The only decision I'm having trouble with, is whether we use Python or Jython to develop our application. Now I'm pretty familiar with Java and could possibly benefit from the libraries within the JDK. I know minimal Python, but am using this project as an opportunity to learn a new language - so the majority of work will be written in Python. The attractiveness of Jython is of course the JVM. The number of python/django enabled web-hosts is extremely minimal - whereas I'm assuming I could drop a jython/django application on a huge variety of hosts. This isn't a massive design decision, but still one I think needs to be decided. I'd really prefer jython over python for the jvm accessibility alone. Questions Does Jython have many limitations compared to regular python? Will running django on jython cause problems? How quick is the Jython team to release updates alongside Python? Will Django work as advertised on Jython (with very minimal pre-configuration)? Decision Thanks for the helpful comments. What I think I'm going to do is develop in Jython for the JVM support - but to try to only use Python code/libraries. Portability isn't a major concern so if I need a library in the JDK (not readily available in python), I'll use it. As long as Django is fully supported, I'm happy.
Are there problems developing Django on Jython?
0.049958
0
0
3,101
314,234
2008-11-24T14:17:00.000
3
0
0
0
python,django,jvm,jython
314,448
4
false
1
0
I'd say that if you like Django, you'll also like Python. Don't make the (far too common) mistake of mixing past language's experience while you learn a new one. Only after mastering Python, you'll have the experience to judge if a hybrid language is better than either one. It's true that very few cheap hostings offer Django preinstalled; but it's quite probable that that will change, given that it's the most similar environment to Google's app engine. (and most GAE projects can be made to run on Django)
2
14
0
The background I'm building a fair-sized web application with a friend in my own time, and we've decided to go with the Django framework on Python. Django provides us with a lot of features we're going to need, so please don't suggest alternative frameworks. The only decision I'm having trouble with, is whether we use Python or Jython to develop our application. Now I'm pretty familiar with Java and could possibly benefit from the libraries within the JDK. I know minimal Python, but am using this project as an opportunity to learn a new language - so the majority of work will be written in Python. The attractiveness of Jython is of course the JVM. The number of python/django enabled web-hosts is extremely minimal - whereas I'm assuming I could drop a jython/django application on a huge variety of hosts. This isn't a massive design decision, but still one I think needs to be decided. I'd really prefer jython over python for the jvm accessibility alone. Questions Does Jython have many limitations compared to regular python? Will running django on jython cause problems? How quick is the Jython team to release updates alongside Python? Will Django work as advertised on Jython (with very minimal pre-configuration)? Decision Thanks for the helpful comments. What I think I'm going to do is develop in Jython for the JVM support - but to try to only use Python code/libraries. Portability isn't a major concern so if I need a library in the JDK (not readily available in python), I'll use it. As long as Django is fully supported, I'm happy.
Are there problems developing Django on Jython?
0.148885
0
0
3,101
315,165
2008-11-24T19:27:00.000
0
0
0
0
python,debugging,web2py
2,781,947
9
false
1
0
As Carl stated, it is as easy as: Installing PyDev in Eclipse Right Click on your Web2Py project, selecting Debug As > Python Run Selecting web2py.py as the file to run No other plugins or downloads are needed.
2
19
0
Is it possible? By debug I mean setting breakpoints, inspect values and advance step by step.
How to debug Web2py applications?
0
0
0
9,395
315,165
2008-11-24T19:27:00.000
8
0
0
0
python,debugging,web2py
806,233
9
false
1
0
One can debug applications built on Web2py using the following set-up: Eclipse IDE Install Pydev into Eclipse Set Breakpoints on your code as needed Within Eclipse right-click the file web2py.py and select Debug As -> Python Run When a breakpoint is hit Eclipse will jump to the breakpoint where you can inspect variables and step thru the code
2
19
0
Is it possible? By debug I mean setting breakpoints, inspect values and advance step by step.
How to debug Web2py applications?
1
0
0
9,395
315,363
2008-11-24T20:31:00.000
0
0
0
0
python,django,apache,spam-prevention
318,079
8
false
1
0
Yes, it should be a 404, not a 500. 500 indicates something is trying to deal with the URL and is failing in the process. You need to find and fix that. We have a similar problem. Since we are running Apache/mod_python, I chose to deal with it in .htaccess with mod_rewrite rules. I periodically look at the logs and add a few patterns to my "go to hell" list. These all rewrite to deliver a 1x1 pixel gif file. There is no tsunami of 404s to clutter up my log analysis and it puts minimal load on Django and Apache. You can't make these a**holes go away, so all you can do is minimize their impact on your system and get on with your life.
3
4
0
I have a nice and lovely Django site up and running, but have noticed that my error.log file was getting huge, over 150 MB after a couple of months of being live. Turns out a bunch of spambots are looking for well known URL vulnerabilities (or something) and hitting a bunch of sub-directories like http://mysite.com/ie or http://mysite.com/~admin.php etc. Since Django uses URL rewriting, it is looking for templates to fit these requests, which raises a TemplateDoesNotExist exception, and then a 500 message (Django does this, not me). I have debug turned off, so they only get the generic 500 message, but it's filling up my logs very quickly. Is there a way to turn this behavior off? Or perhaps just block the IP's doing this?
Spambots are cluttering my log file [Django]
0
0
0
821
315,363
2008-11-24T20:31:00.000
0
0
0
0
python,django,apache,spam-prevention
315,615
8
false
1
0
How about setting up a catch-all pattern as the last item in your urls file and directing it to a generic "no such page" or even your homepage? In other words, turn 500's into requests for your homepage.
3
4
0
I have a nice and lovely Django site up and running, but have noticed that my error.log file was getting huge, over 150 MB after a couple of months of being live. Turns out a bunch of spambots are looking for well known URL vulnerabilities (or something) and hitting a bunch of sub-directories like http://mysite.com/ie or http://mysite.com/~admin.php etc. Since Django uses URL rewriting, it is looking for templates to fit these requests, which raises a TemplateDoesNotExist exception, and then a 500 message (Django does this, not me). I have debug turned off, so they only get the generic 500 message, but it's filling up my logs very quickly. Is there a way to turn this behavior off? Or perhaps just block the IP's doing this?
Spambots are cluttering my log file [Django]
0
0
0
821
315,363
2008-11-24T20:31:00.000
-1
0
0
0
python,django,apache,spam-prevention
315,394
8
false
1
0
A programming solution would be to : open the log file read the lines in a buffer replace the lines that match the errors the bots caused seek to the beginning of the file write the new buffer truncate the file to current pointer position close Voila ! It's done !
3
4
0
I have a nice and lovely Django site up and running, but have noticed that my error.log file was getting huge, over 150 MB after a couple of months of being live. Turns out a bunch of spambots are looking for well known URL vulnerabilities (or something) and hitting a bunch of sub-directories like http://mysite.com/ie or http://mysite.com/~admin.php etc. Since Django uses URL rewriting, it is looking for templates to fit these requests, which raises a TemplateDoesNotExist exception, and then a 500 message (Django does this, not me). I have debug turned off, so they only get the generic 500 message, but it's filling up my logs very quickly. Is there a way to turn this behavior off? Or perhaps just block the IP's doing this?
Spambots are cluttering my log file [Django]
-0.024995
0
0
821
315,381
2008-11-24T20:38:00.000
1
0
1
0
python,regex
315,446
3
false
0
0
If the pattern you have to match is simple enough to grab with filesystem wildcards, I recommend you take a look at the glob module, which exists for this exact purpose.
1
3
0
I am having some difficulty writing a function that will search through a directory for a file that matches a specific regular expression (which I have compiled using 're.compile'). So my question is: How do I search through a directory (I plan to use os.walk) for a file that matches a specific regular expression? An example would be very much appreciated. Thanks in advance.
How do I search through a folder for the filename that matches a regular expression using Python?
0.066568
0
0
5,140
315,435
2008-11-24T20:53:00.000
0
0
1
0
python,reversi
527,064
6
false
0
0
You don't even need a linear array. Two 64-bit java long values suffice (one for the white pieces, one for the black. assert (white&black)==0 . You can make play stronger by counting not pieces that are joined to a corner, but pieces that cannot be taken.
3
3
0
I am trying to write Reversi game in Python. Can anyone give me some basic ideas and strategy which are simple, good and easy to use? I would appreciate for any help because I've gone to a little far but is stucked between codes and it became more complex too. I think I overdid in some part that should be fairly simple. So....
Need instructions for Reversi game
0
0
0
3,730