Dependent Origination

Archive for March 4th, 2011

print “***********************************************”
print “total: {0}”.format(total)
print “{0:<10s} {1:>10s} {2:>20s}”.format(‘version’, ‘count’, ‘percentage’)
versions = sorted(counts.keys())
for k in versions:
print “{0:<10s} {1:>10d} {2:>20.1%}”.format(k, counts[k], counts[k]/float(total))

1. a/float(b)

2. from __future__ import division

c = a/b

3. python 3.x, / is division while // is the old integer division

p = subprocess.Popen([executable, args], stdout=subprocess.PIPE)

p.wait()

this will deadlock if executable outputs fill up the in-memory buffer and thus stops until someone reads from that buffer

in essence, don’t wait on a process that can output something. use  p.communicate() for this purpose


March 2011
M T W T F S S
 123456
78910111213
14151617181920
21222324252627
28293031  

Flickr Photos

Archives