Description:
The Python computer language.
|
|
|
Any elegant way to construct the complete $k$-partite graph in Python?
|
| |
I was wondering if there were any neat tools (like for instance, something from itertools) that would help me write the following function more elegantly. The return value should, of course, be the complete $k$- partite graph $K_{n_1, n_2, \dots, n_k}$: def completeGraph (*ns): ''' Returns the complete graph $K_{n_1, n_2, \dots, n_k}$ when passed... more »
|
|
sys.stdout is not flushed
|
| |
I am trying to use sys.stdout to print out "process-bar" like: -->1% Here is my program ‘test.py’: from sys import stdout for v in range(10): stdout.write('-->%d' % v) stdout.flush() else: stdout.write('done!') ...Then, I use 'python -u test.py' to run this script. But what I get is :... more »
|
|
profiling differences using an extra function call
|
| |
Hi, I was a trying to profile a small script and after shrinking the code to the minimum I got a interesting profile difference. Given two test functions test1 and test2, that only differs from an extra level of indirection (i.e. find_substr), I wonder why I got a timming difference >50%? What is the recommended way to factorize the... more »
|
|
UnicodeDecodeError? Argh! Nothing works! I'm tired and hurting and...
|
| |
This is the tragic story of this evening: 1. Aspirins to lessen the pain somewhat. 2. Over in [comp.programming] someone mentions paper on Quicksort. 3. I recall that X once sent me link to paper about how to foil Quicksort, written by was it Doug McIlroy, anyway some Bell Labs guy. Want to post that link in response to [comp.programming] article.... more »
|
|
Waiting for receiving data
|
| |
fp = urllib.urlopen(url) data = fp.read() Retrieving XML data via an XML service API. Very often network gets stuck in between. No errors / exceptions. CTRL+C File "get-xml.py", line 32, in <module> fp = urllib.urlopen(url) File "/usr/lib/python2.6/urllib.py" , line 87, in urlopen return opener.open(url)... more »
|
|
dbapi2 select where IN (...)
|
| |
hello, I couldn't find how the dbapi2 planned to handle the sql IN statement. ex : SELECT * FROM table WHERE num IN (2,3,8,9); I'd be glad to take advantage of the ? mechanism, but what about tuples ! execute("""SELECT * FROM table WHERE num IN ?;""" , ((2,3,8,9),)) ...fail... what would be the most pythonic way to do this ?... more »
|
|
sandbox python via module loader
|
| |
Greetings, in the past I wrote a sandboxing module loader for c++/ python. I am moving away from python.. I can't stand it actually. Call me blasphemous... I'm immune.. So this code is going to just find the trash.. Maybe it will be useful to someone else. Can't post it all, however, if you are trying to integrate python into a system in which you need... more »
|
|
Don't Understand Error
|
| |
...A CGI script is expected to produce output. Your script doesn't produce any output, and Apache is complaining about that.
|
|
|