title
stringlengths
10
172
question_id
int64
469
40.1M
question_body
stringlengths
22
48.2k
question_score
int64
-44
5.52k
question_date
stringlengths
20
20
answer_id
int64
497
40.1M
answer_body
stringlengths
18
33.9k
answer_score
int64
-38
8.38k
answer_date
stringlengths
20
20
tags
listlengths
1
5
python constructing functions on the fly
1,593,572
<p>I have several little functions <code>f1</code>, <code>f2</code>, <code>f3</code> and a function <code>f</code>.</p> <p>I want <code>f</code> to be a "container" to <code>f1</code>, <code>f2</code>, <code>f3</code>: to do the some of operations <code>f1</code>, <code>f2</code>, <code>f3</code>, depending on the pro...
5
2009-10-20T09:59:00Z
1,593,664
<p>There can be various ways to achieve what you want, but for that you need to fully define the problem and context</p> <p>a way could be like this, and most of the other will be variant of this, using a dict to lookup the function we need</p> <pre><code>def f1(): print "f1" def f2(): print "f2" def f3(): print "f3"...
1
2009-10-20T10:16:41Z
[ "python" ]
python constructing functions on the fly
1,593,572
<p>I have several little functions <code>f1</code>, <code>f2</code>, <code>f3</code> and a function <code>f</code>.</p> <p>I want <code>f</code> to be a "container" to <code>f1</code>, <code>f2</code>, <code>f3</code>: to do the some of operations <code>f1</code>, <code>f2</code>, <code>f3</code>, depending on the pro...
5
2009-10-20T09:59:00Z
1,593,698
<p>If you're brave, you can construct a function definition as a <em>string</em> and pass it to the <a href="http://docs.python.org/reference/simple%5Fstmts.html#the-exec-statement" rel="nofollow"><code>exec</code></a> statement. For example:</p> <pre><code>func = "def f():\n" if config_f1: func += " f1()\n" if co...
3
2009-10-20T10:24:06Z
[ "python" ]
python constructing functions on the fly
1,593,572
<p>I have several little functions <code>f1</code>, <code>f2</code>, <code>f3</code> and a function <code>f</code>.</p> <p>I want <code>f</code> to be a "container" to <code>f1</code>, <code>f2</code>, <code>f3</code>: to do the some of operations <code>f1</code>, <code>f2</code>, <code>f3</code>, depending on the pro...
5
2009-10-20T09:59:00Z
1,593,702
<p>Use objects and the Command design pattern.</p> <pre><code>class Function( object ): pass class F1( Function ): def __call__( self ): whatever `f1` used to do class F2( Function ): def __call__( self ): whatever `f1` used to do class Sequence( Function ): def __init__( self, *s...
1
2009-10-20T10:24:55Z
[ "python" ]
String replacing in a file by given position
1,593,576
<p>I have a file opened in 'ab+' mode.</p> <p>What I need to do is replacing some bytes in the file with another string's bytes such that:</p> <p>FILE:</p> <pre><code>thisissomethingasperfectlygood. </code></pre> <p>string:</p> <pre><code>01234 </code></pre> <p>So, for example, I seek for the position (4, 0) and ...
2
2009-10-20T10:00:07Z
1,593,646
<p>You could mmap() your file and then use slice notation to update specific byte ranges in the file. The example <a href="http://docs.python.org/library/mmap.html" rel="nofollow">here</a> should help.</p>
2
2009-10-20T10:13:51Z
[ "python", "string", "replace", "seek" ]
String replacing in a file by given position
1,593,576
<p>I have a file opened in 'ab+' mode.</p> <p>What I need to do is replacing some bytes in the file with another string's bytes such that:</p> <p>FILE:</p> <pre><code>thisissomethingasperfectlygood. </code></pre> <p>string:</p> <pre><code>01234 </code></pre> <p>So, for example, I seek for the position (4, 0) and ...
2
2009-10-20T10:00:07Z
1,593,658
<p>You can use mmap for that</p> <pre><code>import os,mmap f=os.open("afile",os.O_RDWR) m=mmap.mmap(f,0) m[4:9]="01234" os.close(f) </code></pre>
2
2009-10-20T10:15:52Z
[ "python", "string", "replace", "seek" ]
getpos() coding
1,593,599
<p>just wanted to know how to write the getpos() command which must return an (x,y) tuple of the current position.</p> <p>does it start like this:</p> <pre><code>def getpos(x 100, y 100) </code></pre> <p>not sure need help</p>
0
2009-10-20T10:06:01Z
1,593,637
<p>This is a bit underspecified, but this might work:</p> <pre><code>def getpos(self): return (self.x, self.y) </code></pre> <p>This is how to return a tuple, from values assumed to be instance variables.</p>
2
2009-10-20T10:12:37Z
[ "python" ]
getpos() coding
1,593,599
<p>just wanted to know how to write the getpos() command which must return an (x,y) tuple of the current position.</p> <p>does it start like this:</p> <pre><code>def getpos(x 100, y 100) </code></pre> <p>not sure need help</p>
0
2009-10-20T10:06:01Z
1,593,648
<p>In Python you can't force a return type on a function from its header. The return type can change from one call to another. When you write:</p> <pre><code>def getpos(x,y): </code></pre> <p>It means that the function receives 2 parameters, that inside the function are called x &amp; y. No type is forced on them eit...
1
2009-10-20T10:13:53Z
[ "python" ]
Python: Get name of instantiating class?
1,593,632
<p>Example:</p> <pre><code>class Class1: def __init__(self): self.x = Class2('Woo!') class Class2: def __init__(self, word): print word meow = Class1() </code></pre> <p>How do I derive the class name that created the self.x instance? In other words, if I was given the instance self.x, how do...
7
2009-10-20T10:11:42Z
1,593,652
<p>Set a variable on the class in question in your <code>__init__()</code> method that you then retrieve later on.</p> <p>You'll get better answers if you ask better questions. This one is pretty unclear.</p>
1
2009-10-20T10:14:43Z
[ "python", "class", "instance" ]
Python: Get name of instantiating class?
1,593,632
<p>Example:</p> <pre><code>class Class1: def __init__(self): self.x = Class2('Woo!') class Class2: def __init__(self, word): print word meow = Class1() </code></pre> <p>How do I derive the class name that created the self.x instance? In other words, if I was given the instance self.x, how do...
7
2009-10-20T10:11:42Z
1,593,673
<p>You can't, unless you pass an instance of the 'creator' to the Class2() constructor. e.g.</p> <pre><code>class Class1(object): def __init__(self, *args, **kw): self.x = Class2("Woo!", self) class Class2(object): def __init__(self, word, creator, *args, **kw): self._creator = creator ...
5
2009-10-20T10:18:23Z
[ "python", "class", "instance" ]
Python: Get name of instantiating class?
1,593,632
<p>Example:</p> <pre><code>class Class1: def __init__(self): self.x = Class2('Woo!') class Class2: def __init__(self, word): print word meow = Class1() </code></pre> <p>How do I derive the class name that created the self.x instance? In other words, if I was given the instance self.x, how do...
7
2009-10-20T10:11:42Z
1,593,704
<p>Your question is very similar to answered <a href="http://stackoverflow.com/questions/1497683/can-python-determine-the-class-of-a-object-accessing-a-method">here</a>. Note, that you can determine who created the instance in its constructor, but not afterwards. Anyway, the best way is to pass creator into constructor...
0
2009-10-20T10:25:37Z
[ "python", "class", "instance" ]
forward and back command
1,593,818
<p>wanted to know how to write a forward and back command in a superclass not sure but i gave it a try dont know if its right or wrong some help plz</p> <pre><code>def forward(self): return (self.100) def back(self): return (self.50) </code></pre>
-1
2009-10-20T10:56:21Z
1,593,838
<pre><code>def forward(self): self.position += self.distance return (self.position) def back(self): self.position -= self.distance return (self.position) </code></pre> <p>EDIT: I assumed you are doing something like progress bar of install app, where some operation advances progress (copying files), and if us...
1
2009-10-20T11:01:39Z
[ "python" ]
Problem with Twisted and threads
1,593,948
<p>Some of you that are more experienced using Twisted will probably judge me about using it together with threads - but I did it :). And now I am in somehow of a trouble - I am having an application server that listens for client requests and each time a new client connects it spawns another thread that I probably for...
0
2009-10-20T11:28:55Z
1,595,929
<p>"Twisted way" to do anything outside reactor loop (aka spawning threads) is twisted.internet.threads.deferToThread.</p> <p>For example:</p> <pre><code>from twisted.internet import threads def sthToDoInSeparateThread(): return 3 d = threads.deferToThread(sthToDoInSeparateThread) </code></pre> <p>deferToThrea...
4
2009-10-20T16:46:59Z
[ "python", "multithreading", "twisted" ]
Problem with Twisted and threads
1,593,948
<p>Some of you that are more experienced using Twisted will probably judge me about using it together with threads - but I did it :). And now I am in somehow of a trouble - I am having an application server that listens for client requests and each time a new client connects it spawns another thread that I probably for...
0
2009-10-20T11:28:55Z
2,317,726
<p>You probably just want to do <code>mythread.setDaemon(True)</code> so that your threads exit when the main process exits.</p>
0
2010-02-23T11:37:33Z
[ "python", "multithreading", "twisted" ]
Writing an XML file using python
1,594,052
<p>I have to write an xml file using python standard modules (not using elementtree, lxml etc) The metadata is a SAML identity provider metadata and is of the form - </p> <pre><code>&lt;?xml version="1.0"?&gt; &lt;EntityDescriptor xmlns="urn:oasis:names:tc:SAML:2.0:metadata" xmlns:saml="urn:oasis:names:tc:SAML:2.0...
1
2009-10-20T11:48:46Z
1,594,142
<p>Well? What is your question? In these two lines:</p> <pre><code>&gt;&gt;&gt; ptext = doc.createTextNode("This is a test!") &gt;&gt;&gt; x509cert.appendChild(ptext) </code></pre> <p>you are, indeed, creating a text node as a child of a node <code>"&lt;ds:X509Certificate&gt;"</code> . The contents of the text node a...
2
2009-10-20T12:06:54Z
[ "python", "xml", "saml" ]
Writing an XML file using python
1,594,052
<p>I have to write an xml file using python standard modules (not using elementtree, lxml etc) The metadata is a SAML identity provider metadata and is of the form - </p> <pre><code>&lt;?xml version="1.0"?&gt; &lt;EntityDescriptor xmlns="urn:oasis:names:tc:SAML:2.0:metadata" xmlns:saml="urn:oasis:names:tc:SAML:2.0...
1
2009-10-20T11:48:46Z
1,605,897
<p>Just for archiving, my earlier code was missing a small change, that is why the certificate was being rejected.</p> <pre><code>from xml.dom.minidom import Document doc = Document() entity_descriptor = doc.createElement("EntityDescriptor") doc.appendChild(entity_descriptor) entity_descriptor.setAttribute('xmlns', 'u...
0
2009-10-22T08:57:25Z
[ "python", "xml", "saml" ]
Writing an XML file using python
1,594,052
<p>I have to write an xml file using python standard modules (not using elementtree, lxml etc) The metadata is a SAML identity provider metadata and is of the form - </p> <pre><code>&lt;?xml version="1.0"?&gt; &lt;EntityDescriptor xmlns="urn:oasis:names:tc:SAML:2.0:metadata" xmlns:saml="urn:oasis:names:tc:SAML:2.0...
1
2009-10-20T11:48:46Z
30,003,069
<p>Yattag is could be interesting for this</p> <pre><code>from yattag import Doc, indent doc, tag, text = Doc().tagtext() doc.asis('&lt;?xml version="1.0"?&gt;') with tag('EntityDescriptor', ("xmlns:saml", "urn:oasis:names:tc:SAML:2.0:assertion"), ("xmlns:ds", "http://www.w3.org/2000/09/xmldsig#"), ...
0
2015-05-02T13:50:08Z
[ "python", "xml", "saml" ]
angles commands in superclass
1,594,090
<p>how do you write a command that turn left or right at an angle in a superclass is it like this:</p> <pre><code>def left(self): self.position += self.angle return (self.position) </code></pre> <p>is it the same as the forward and back command</p>
0
2009-10-20T11:58:01Z
1,594,175
<p>It looks like you are interested by something like the logo turtle. Look at <a href="http://docs.python.org/library/turtle.html" rel="nofollow">http://docs.python.org/library/turtle.html</a></p> <p>If so, the left function doesn't change the position of the turtle but its orientation.</p> <pre><code>def left(self,...
1
2009-10-20T12:13:53Z
[ "python" ]
Preserving extent from the old image
1,594,223
<p>I am using <a href="http://en.wikipedia.org/wiki/Python_Imaging_Library" rel="nofollow">PIL</a> 1.1.6, Python 2.5 on the Windows platform.</p> <p>In my program, I am performing a point operation (changing the pixel values) and then saving the new image.</p> <p>When I am loading the new and old image, they are not ...
0
2009-10-20T12:21:14Z
1,597,146
<p>Assuming by "extent" you mean "size" (pixels wide by pixels high), then there are several options depending on what you have as a "new" image.</p> <p>If "new" is an existing image (and you want to stretch/shrink/grow the new):</p> <pre><code>from PIL import Image &gt;&gt;&gt; im1 = Image.open('img1.jpg') &gt;&gt;&...
0
2009-10-20T20:37:12Z
[ "python", "image", "python-imaging-library" ]
Making Django admin display the Primary Key rather than each object's Object type
1,594,436
<p>In Django 1.1 admin, when I go to add or change an object, my objects are displayed as:</p> <pre><code>Select host to change * Add host Host object Host object Host object Host object Host object </code></pre> <p>This happens for all models in my site, not just Hosts.</p> <p>Rather than d...
11
2009-10-20T12:58:26Z
1,594,453
<p>Add a <a href="http://docs.djangoproject.com/en/dev/ref/models/instances/#django.db.models.Model.__unicode__"><code>__unicode__()</code></a> method to <code>Host</code>. To show the primary key of your host objects, you'd want something like:</p> <pre><code>class Host(models.Model): host = models.CharField(max_...
26
2009-10-20T13:00:35Z
[ "python", "django", "admin" ]
Making Django admin display the Primary Key rather than each object's Object type
1,594,436
<p>In Django 1.1 admin, when I go to add or change an object, my objects are displayed as:</p> <pre><code>Select host to change * Add host Host object Host object Host object Host object Host object </code></pre> <p>This happens for all models in my site, not just Hosts.</p> <p>Rather than d...
11
2009-10-20T12:58:26Z
1,594,468
<p><code>contrib.admin</code> has been reworked in 1.0, and old <code>Admin</code> classes inside models no longer work. What you need is <code>ModelAdmin</code> subclass in <code>your_application.admin</code> module, e.g.</p> <pre><code>from your_application.models import Host from django.contrib import admin class ...
10
2009-10-20T13:03:07Z
[ "python", "django", "admin" ]
Making Django admin display the Primary Key rather than each object's Object type
1,594,436
<p>In Django 1.1 admin, when I go to add or change an object, my objects are displayed as:</p> <pre><code>Select host to change * Add host Host object Host object Host object Host object Host object </code></pre> <p>This happens for all models in my site, not just Hosts.</p> <p>Rather than d...
11
2009-10-20T12:58:26Z
1,950,946
<p>It might also be worth mentioning that, if you are using an auto-incrementing primary key for your models, you will need to coerce it into a string, eg:</p> <pre><code>def __unicode__(self): return str(self.pk) </code></pre>
2
2009-12-23T06:07:08Z
[ "python", "django", "admin" ]
Unicode handling in ReportLab
1,594,470
<p>I am trying to use ReportLab with Unicode characters, but it is not working. I tried tracing through the code till I reached the following line:</p> <pre><code>class TTFont: # ... def splitString(self, text, doc, encoding='utf-8'): # ... cur.append(n &amp; 0xFF) # &lt;-- here is the problem!...
1
2009-10-20T13:03:09Z
1,594,858
<p>I'm pretty sure you'd need to change <code>0xFF</code> to <code>0xFFFF</code> to use 4-byte unicode characters, as ~unutbu suggested, hence using four bytes instead of two.</p>
0
2009-10-20T14:05:53Z
[ "python", "unicode", "reportlab" ]
Unicode handling in ReportLab
1,594,470
<p>I am trying to use ReportLab with Unicode characters, but it is not working. I tried tracing through the code till I reached the following line:</p> <pre><code>class TTFont: # ... def splitString(self, text, doc, encoding='utf-8'): # ... cur.append(n &amp; 0xFF) # &lt;-- here is the problem!...
1
2009-10-20T13:03:09Z
1,964,931
<p>What do you mean, "not working"? You have misquoted the reportlab source code. What it is actually doing is that the lower and upper byte of each 16-bit unicode character are coded separately (the upper byte is only written out when it changes, which I assume is a PDF-specific optimization to make documents smaller)...
1
2009-12-27T01:46:19Z
[ "python", "unicode", "reportlab" ]
SPARQL Query gives unexpected result
1,594,518
<p>I hope someone can help me on this probably totally easy-to-solve problem:</p> <p>I want to run a SPARQL query against the following RDF (noted in N3, the RDF/XMl sits <a href="http://rdf.schalljugend.net/umstaetter.rdf" rel="nofollow">here</a>). This is the desription of a journal article and descriptions of the j...
7
2009-10-20T13:12:33Z
1,594,959
<p>I don't think that you can use a QName in an XML attribute value; e.g. the value of <code>rdf:about</code>. So consider this line from your RDF/XML file:</p> <pre><code> &lt;bibo:Journal rdf:about="ex:bibdienst"&gt; </code></pre> <p>I think that this is actually saying that the subject URI is "ex:bibdienst". Tha...
7
2009-10-20T14:22:28Z
[ "python", "rdf", "sparql", "rdflib" ]
SPARQL Query gives unexpected result
1,594,518
<p>I hope someone can help me on this probably totally easy-to-solve problem:</p> <p>I want to run a SPARQL query against the following RDF (noted in N3, the RDF/XMl sits <a href="http://rdf.schalljugend.net/umstaetter.rdf" rel="nofollow">here</a>). This is the desription of a journal article and descriptions of the j...
7
2009-10-20T13:12:33Z
1,595,236
<p>Yep Stephen C is totally correct that you can't use QNames in XML attributes, you can use XML entities instead which you define in a DTD block at the top of your document like so:</p> <p>eg.</p> <pre><code>&lt;!DOCTYPE rdf:RDF[ &lt;!ENTITY rdf 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'&gt; &lt;!ENTITY r...
6
2009-10-20T14:55:57Z
[ "python", "rdf", "sparql", "rdflib" ]
Implement a listbox
1,594,589
<p>I need to implement a listbox for a mobile. The only relevant controls are up and down arrow keys. The listbox should display as many rows of items from a list as will fit on the screen (screen_rows), one row should be highighted (sel_row) and the display should wrap if the user hits up arrow when the first item i...
0
2009-10-20T13:24:01Z
1,595,490
<p>Few Python programs implement listboxes from scratch -- they're normally just taken from existing toolkits. That may explain why there's no real cross-toolkit "standard"!-)</p> <p>Coming to your code, I imagine <code>set_pos</code> is meant to be called right after either <code>up_key</code> or <code>down_key</cod...
1
2009-10-20T15:30:14Z
[ "python", "listbox", "pseudocode" ]
How should I optimize this filesystem I/O bound program?
1,594,604
<p>I have a python program that does something like this:</p> <ol> <li>Read a row from a csv file.</li> <li>Do some transformations on it.</li> <li>Break it up into the actual rows as they would be written to the database.</li> <li>Write those rows to individual csv files.</li> <li>Go back to step 1 unless the file ha...
2
2009-10-20T13:27:31Z
1,594,634
<p>Poor man's map-reduce:</p> <p>Use <a href="http://www.gnu.org/manual/gawk/html%5Fnode/Split-Program.html">split</a> to break the file up into as many pieces as you have CPUs.</p> <p>Use <a href="http://linux.about.com/library/cmd/blcmdl1%5Fbatch.htm">batch</a> to run your muncher in parallel.</p> <p>Use <a href="...
5
2009-10-20T13:33:19Z
[ "python", "performance", "optimization", "file-io" ]
How should I optimize this filesystem I/O bound program?
1,594,604
<p>I have a python program that does something like this:</p> <ol> <li>Read a row from a csv file.</li> <li>Do some transformations on it.</li> <li>Break it up into the actual rows as they would be written to the database.</li> <li>Write those rows to individual csv files.</li> <li>Go back to step 1 unless the file ha...
2
2009-10-20T13:27:31Z
1,594,704
<p>If you are I/O bound, the best way I have found to optimize is to read or write the <em>entire</em> file into/out of memory at once, then operate out of RAM from there on.</p> <p>With extensive testing I found that my runtime eded up bound not by the amount of data I read from/wrote to disk, but by the number of I/...
3
2009-10-20T13:42:32Z
[ "python", "performance", "optimization", "file-io" ]
How should I optimize this filesystem I/O bound program?
1,594,604
<p>I have a python program that does something like this:</p> <ol> <li>Read a row from a csv file.</li> <li>Do some transformations on it.</li> <li>Break it up into the actual rows as they would be written to the database.</li> <li>Write those rows to individual csv files.</li> <li>Go back to step 1 unless the file ha...
2
2009-10-20T13:27:31Z
1,594,935
<p>The first thing is to be certain of what you should optimize. You seem to not know precisely where your time is going. Before spending more time wondering, use a performance profiler to see exactly where the time is going.</p> <p><a href="http://docs.python.org/library/profile.html" rel="nofollow">http://docs.pyth...
-2
2009-10-20T14:18:12Z
[ "python", "performance", "optimization", "file-io" ]
How should I optimize this filesystem I/O bound program?
1,594,604
<p>I have a python program that does something like this:</p> <ol> <li>Read a row from a csv file.</li> <li>Do some transformations on it.</li> <li>Break it up into the actual rows as they would be written to the database.</li> <li>Write those rows to individual csv files.</li> <li>Go back to step 1 unless the file ha...
2
2009-10-20T13:27:31Z
1,595,358
<p>Use buffered writes for step 4.</p> <p>Write a simple function that simply appends the output onto a string, checks the string length, and only writes when you have enough which should be some multiple of 4k bytes. I would say start with 32k buffers and time it.</p> <p>You would have one buffer per file, so that m...
1
2009-10-20T15:14:06Z
[ "python", "performance", "optimization", "file-io" ]
How should I optimize this filesystem I/O bound program?
1,594,604
<p>I have a python program that does something like this:</p> <ol> <li>Read a row from a csv file.</li> <li>Do some transformations on it.</li> <li>Break it up into the actual rows as they would be written to the database.</li> <li>Write those rows to individual csv files.</li> <li>Go back to step 1 unless the file ha...
2
2009-10-20T13:27:31Z
1,595,626
<p>Python already does IO buffering and the OS <em>should</em> handle both prefetching the input file and delaying writes until it needs the RAM for something else or just gets uneasy about having dirty data in RAM for too long. Unless you force the OS to write them immediately, like closing the file after each write ...
3
2009-10-20T15:51:27Z
[ "python", "performance", "optimization", "file-io" ]
How should I optimize this filesystem I/O bound program?
1,594,604
<p>I have a python program that does something like this:</p> <ol> <li>Read a row from a csv file.</li> <li>Do some transformations on it.</li> <li>Break it up into the actual rows as they would be written to the database.</li> <li>Write those rows to individual csv files.</li> <li>Go back to step 1 unless the file ha...
2
2009-10-20T13:27:31Z
1,597,062
<p>Can you use a ramdisk for step 4? Low millions sounds doable if the rows are less than a couple of kB or so.</p>
2
2009-10-20T20:20:29Z
[ "python", "performance", "optimization", "file-io" ]
How should I optimize this filesystem I/O bound program?
1,594,604
<p>I have a python program that does something like this:</p> <ol> <li>Read a row from a csv file.</li> <li>Do some transformations on it.</li> <li>Break it up into the actual rows as they would be written to the database.</li> <li>Write those rows to individual csv files.</li> <li>Go back to step 1 unless the file ha...
2
2009-10-20T13:27:31Z
1,597,281
<p>Isn't it possible to collect a few thousand rows in ram, then go directly to the database server and execute them? </p> <p>This would remove the save to and load from the disk that step 4 entails.</p> <p>If the database server is transactional, this is also a safe way to do it - just have the database begin before...
1
2009-10-20T21:01:01Z
[ "python", "performance", "optimization", "file-io" ]
Cleaning build directory in setup.py
1,594,827
<p>How could I make my <code>setup.py</code> pre-delete and post-delete the build directory?</p>
23
2009-10-20T14:01:15Z
1,594,896
<p>Does <a href="http://docs.python.org/distutils/apiref.html#module-distutils.command.clean">this</a> answer it? IIRC, you'll need to use the <code>--all</code> flag to get rid of stuff outside of <code>build/lib</code>:</p> <pre><code>python setup.py clean --all </code></pre>
56
2009-10-20T14:12:39Z
[ "python", "build", "distutils" ]
Cleaning build directory in setup.py
1,594,827
<p>How could I make my <code>setup.py</code> pre-delete and post-delete the build directory?</p>
23
2009-10-20T14:01:15Z
1,594,902
<p>For pre-deletion, just delete it with <code>distutils.dir_util.remove_tree</code> before calling setup.</p> <p>For post-delete, I assume you only want to post-delete after selected commands. Subclass the respective command, override its run method (to invoke remove_tree after calling the base run), and pass the new...
5
2009-10-20T14:13:42Z
[ "python", "build", "distutils" ]
Cleaning build directory in setup.py
1,594,827
<p>How could I make my <code>setup.py</code> pre-delete and post-delete the build directory?</p>
23
2009-10-20T14:01:15Z
30,241,551
<p>Here's an answer that combines the programmatic approach of Martin's answer with the functionality of Matt's answer (a <code>clean</code> that takes care of all possible build areas):</p> <pre><code>from distutils.core import setup from distutils.command.clean import clean from distutils.command.install import inst...
1
2015-05-14T15:44:09Z
[ "python", "build", "distutils" ]
Why do simple math operations on floating point return unexpected (inaccurate) results in VB.Net and Python?
1,594,985
<pre><code>x = 4.2 - 0.1 </code></pre> <p>vb.net gives <code>4.1000000000000005</code><br /> python gives <code>4.1000000000000005</code></p> <p>Excel gives <code>4.1</code><br /> <a href="http://www.google.com/search?q=4.2-.1" rel="nofollow">Google calc</a> gives <code>4.1</code> </p> <p>What is the reason this ha...
2
2009-10-20T14:25:03Z
1,594,999
<p><a href="http://en.wikipedia.org/wiki/Floating%5Fpoint">Float/double precision.</a></p> <p>You must remember that in binary, 4.1 = 4 + 1/10. 1/10 is an infinitely repeating sum in binary, much like 1/9 is an infinite sum in decimal.</p>
13
2009-10-20T14:27:40Z
[ "python", "vb.net", "floating-point" ]
Why do simple math operations on floating point return unexpected (inaccurate) results in VB.Net and Python?
1,594,985
<pre><code>x = 4.2 - 0.1 </code></pre> <p>vb.net gives <code>4.1000000000000005</code><br /> python gives <code>4.1000000000000005</code></p> <p>Excel gives <code>4.1</code><br /> <a href="http://www.google.com/search?q=4.2-.1" rel="nofollow">Google calc</a> gives <code>4.1</code> </p> <p>What is the reason this ha...
2
2009-10-20T14:25:03Z
1,595,035
<p>There is no problem, really. It is just the way floats work (their internal binary representation). Anyway:</p> <pre><code>&gt;&gt;&gt; from decimal import Decimal &gt;&gt;&gt; Decimal('4.2')-Decimal('0.1') Decimal('4.1') </code></pre>
4
2009-10-20T14:31:13Z
[ "python", "vb.net", "floating-point" ]
Why do simple math operations on floating point return unexpected (inaccurate) results in VB.Net and Python?
1,594,985
<pre><code>x = 4.2 - 0.1 </code></pre> <p>vb.net gives <code>4.1000000000000005</code><br /> python gives <code>4.1000000000000005</code></p> <p>Excel gives <code>4.1</code><br /> <a href="http://www.google.com/search?q=4.2-.1" rel="nofollow">Google calc</a> gives <code>4.1</code> </p> <p>What is the reason this ha...
2
2009-10-20T14:25:03Z
1,595,041
<p>In vb.net, you can avoid this problem by using Decimal type instead:</p> <pre><code>Dim x As Decimal = 4.2D - 0.1D </code></pre> <p>The result is 4.1 .</p>
1
2009-10-20T14:31:54Z
[ "python", "vb.net", "floating-point" ]
Why do simple math operations on floating point return unexpected (inaccurate) results in VB.Net and Python?
1,594,985
<pre><code>x = 4.2 - 0.1 </code></pre> <p>vb.net gives <code>4.1000000000000005</code><br /> python gives <code>4.1000000000000005</code></p> <p>Excel gives <code>4.1</code><br /> <a href="http://www.google.com/search?q=4.2-.1" rel="nofollow">Google calc</a> gives <code>4.1</code> </p> <p>What is the reason this ha...
2
2009-10-20T14:25:03Z
1,595,044
<pre><code>&gt;&gt;&gt; x = 4.2 - 0.1 &gt;&gt;&gt; x 4.1000000000000005 &gt;&gt;&gt;&gt;print(x) 4.1 </code></pre> <p>This happens because of <a href="http://en.wikipedia.org/wiki/Floating%5Fpoint" rel="nofollow">how numbers are stored internally</a>.</p> <p>Computers represent numbers in binary, instead of decimal...
10
2009-10-20T14:32:07Z
[ "python", "vb.net", "floating-point" ]
Convert to UTC Timestamp
1,595,047
<pre><code>//parses some string into that format. datetime1 = datetime.strptime(somestring, "%Y-%m-%dT%H:%M:%S") //gets the seconds from the above date. timestamp1 = time.mktime(datetime1.timetuple()) //adds milliseconds to the above seconds. timeInMillis = int(timestamp1) * 1000 </code></pre> <p>How do I (at any po...
9
2009-10-20T14:32:35Z
1,595,081
<p><a href="http://docs.python.org/library/datetime.html#datetime.datetime.utcfromtimestamp"><code>datetime.utcfromtimestamp</code></a> is probably what you're looking for:</p> <pre><code>&gt;&gt;&gt; timestamp1 = time.mktime(datetime.now().timetuple()) &gt;&gt;&gt; timestamp1 1256049553.0 &gt;&gt;&gt; datetime.utcfro...
6
2009-10-20T14:37:12Z
[ "python", "datetime", "utc" ]
Convert to UTC Timestamp
1,595,047
<pre><code>//parses some string into that format. datetime1 = datetime.strptime(somestring, "%Y-%m-%dT%H:%M:%S") //gets the seconds from the above date. timestamp1 = time.mktime(datetime1.timetuple()) //adds milliseconds to the above seconds. timeInMillis = int(timestamp1) * 1000 </code></pre> <p>How do I (at any po...
9
2009-10-20T14:32:35Z
1,595,096
<p>I think you can use the <code>utcoffset()</code> method:</p> <pre><code>utc_time = datetime1 - datetime1.utcoffset() </code></pre> <p>The docs give an example of this using the <code>astimezone()</code> method <a href="http://docs.python.org/library/datetime.html#datetime.datetime.astimezone" rel="nofollow">here</...
3
2009-10-20T14:38:16Z
[ "python", "datetime", "utc" ]
Convert to UTC Timestamp
1,595,047
<pre><code>//parses some string into that format. datetime1 = datetime.strptime(somestring, "%Y-%m-%dT%H:%M:%S") //gets the seconds from the above date. timestamp1 = time.mktime(datetime1.timetuple()) //adds milliseconds to the above seconds. timeInMillis = int(timestamp1) * 1000 </code></pre> <p>How do I (at any po...
9
2009-10-20T14:32:35Z
1,595,195
<p>You probably want one of these two:</p> <pre><code>import time import datetime from email.Utils import formatdate rightnow = time.time() utc = datetime.datetime.utcfromtimestamp(rightnow) print utc print formatdate(rightnow) </code></pre> <p>The two outputs look like this</p> <pre><code>2009-10-20 14:46:52.72...
1
2009-10-20T14:50:53Z
[ "python", "datetime", "utc" ]
Convert to UTC Timestamp
1,595,047
<pre><code>//parses some string into that format. datetime1 = datetime.strptime(somestring, "%Y-%m-%dT%H:%M:%S") //gets the seconds from the above date. timestamp1 = time.mktime(datetime1.timetuple()) //adds milliseconds to the above seconds. timeInMillis = int(timestamp1) * 1000 </code></pre> <p>How do I (at any po...
9
2009-10-20T14:32:35Z
1,596,308
<pre><code>def getDateAndTime(seconds=None): """ Converts seconds since the Epoch to a time tuple expressing UTC. When 'seconds' is not passed in, convert the current time instead. :Parameters: - `seconds`: time in seconds from the epoch. :Return: Time in UTC format. """ return time.strftime("%Y-%m...
2
2009-10-20T18:00:42Z
[ "python", "datetime", "utc" ]
blocks - send input to python subprocess pipeline
1,595,492
<p>I'm testing subprocesses pipelines with python. I'm aware that I can do what the programs below do in python directly, but that's not the point. I just want to test the pipeline so I know how to use it.</p> <p>My system is Linux Ubuntu 9.04 with default python 2.6.</p> <p>I started with this <a href="http://docs.p...
28
2009-10-20T15:30:51Z
1,595,549
<p>You must do this in several threads. Otherwise, you'll end up in a situation where you can't send data: child p1 won't read your input since p2 doesn't read p1's output because you don't read p2's output.</p> <p>So you need a background thread that reads what p2 writes out. That will allow p2 to continue after writ...
2
2009-10-20T15:41:29Z
[ "python", "ipc", "pipe", "subprocess", "blocking" ]
blocks - send input to python subprocess pipeline
1,595,492
<p>I'm testing subprocesses pipelines with python. I'm aware that I can do what the programs below do in python directly, but that's not the point. I just want to test the pipeline so I know how to use it.</p> <p>My system is Linux Ubuntu 9.04 with default python 2.6.</p> <p>I started with this <a href="http://docs.p...
28
2009-10-20T15:30:51Z
1,610,865
<p>I think you may be examining the wrong problem. Certainly as Aaron says if you try to be both a producer to the beginning of a pipeline, and a consumer of the end of the pipeline, it is easy to get into a deadlock situation. This is the problem that communicate() solves.</p> <p>communicate() isn't exactly correct...
1
2009-10-23T00:49:36Z
[ "python", "ipc", "pipe", "subprocess", "blocking" ]
blocks - send input to python subprocess pipeline
1,595,492
<p>I'm testing subprocesses pipelines with python. I'm aware that I can do what the programs below do in python directly, but that's not the point. I just want to test the pipeline so I know how to use it.</p> <p>My system is Linux Ubuntu 9.04 with default python 2.6.</p> <p>I started with this <a href="http://docs.p...
28
2009-10-20T15:30:51Z
1,611,099
<p>What about using a SpooledTemporaryFile ? This bypasses (but perhaps doesn't solve) the issue:</p> <p><a href="http://docs.python.org/library/tempfile.html#tempfile.SpooledTemporaryFile" rel="nofollow">http://docs.python.org/library/tempfile.html#tempfile.SpooledTemporaryFile</a></p> <p>You can write to it like a...
0
2009-10-23T02:20:03Z
[ "python", "ipc", "pipe", "subprocess", "blocking" ]
blocks - send input to python subprocess pipeline
1,595,492
<p>I'm testing subprocesses pipelines with python. I'm aware that I can do what the programs below do in python directly, but that's not the point. I just want to test the pipeline so I know how to use it.</p> <p>My system is Linux Ubuntu 9.04 with default python 2.6.</p> <p>I started with this <a href="http://docs.p...
28
2009-10-20T15:30:51Z
1,616,457
<p>I found out how to do it.</p> <p>It is not about threads, and not about select().</p> <p>When I run the first process (<code>grep</code>), it creates two low-level file descriptors, one for each pipe. Lets call those <code>a</code> and <code>b</code>.</p> <p>When I run the second process, <code>b</code> gets pass...
18
2009-10-23T23:33:38Z
[ "python", "ipc", "pipe", "subprocess", "blocking" ]
blocks - send input to python subprocess pipeline
1,595,492
<p>I'm testing subprocesses pipelines with python. I'm aware that I can do what the programs below do in python directly, but that's not the point. I just want to test the pipeline so I know how to use it.</p> <p>My system is Linux Ubuntu 9.04 with default python 2.6.</p> <p>I started with this <a href="http://docs.p...
28
2009-10-20T15:30:51Z
2,173,130
<p>There are three main tricks to making pipes work as expected</p> <ol> <li><p>Make sure each end of the pipe is used in a different thread/process (some of the examples near the top suffer from this problem).</p></li> <li><p>explicitly close the unused end of the pipe in each process</p></li> <li><p>deal with buffer...
3
2010-01-31T20:12:58Z
[ "python", "ipc", "pipe", "subprocess", "blocking" ]
blocks - send input to python subprocess pipeline
1,595,492
<p>I'm testing subprocesses pipelines with python. I'm aware that I can do what the programs below do in python directly, but that's not the point. I just want to test the pipeline so I know how to use it.</p> <p>My system is Linux Ubuntu 9.04 with default python 2.6.</p> <p>I started with this <a href="http://docs.p...
28
2009-10-20T15:30:51Z
2,223,087
<p>Nosklo's offered solution will quickly break if too much data is written to the receiving end of the pipe:</p> <pre><code> from subprocess import Popen, PIPE p1 = Popen(["grep", "-v", "not"], stdin=PIPE, stdout=PIPE) p2 = Popen(["cut", "-c", "1-10"], stdin=p1.stdout, stdout=PIPE, close_fds=True) p1.stdin.write('He...
2
2010-02-08T16:30:25Z
[ "python", "ipc", "pipe", "subprocess", "blocking" ]
blocks - send input to python subprocess pipeline
1,595,492
<p>I'm testing subprocesses pipelines with python. I'm aware that I can do what the programs below do in python directly, but that's not the point. I just want to test the pipeline so I know how to use it.</p> <p>My system is Linux Ubuntu 9.04 with default python 2.6.</p> <p>I started with this <a href="http://docs.p...
28
2009-10-20T15:30:51Z
2,239,610
<p>In one of the comments above, I challenged nosklo to either post some code to back up his assertions about <code>select.select</code> or to upvote my responses he had previously down-voted. He responded with the following code:</p> <pre><code>from subprocess import Popen, PIPE import select p1 = Popen(["grep", "-...
1
2010-02-10T19:14:16Z
[ "python", "ipc", "pipe", "subprocess", "blocking" ]
blocks - send input to python subprocess pipeline
1,595,492
<p>I'm testing subprocesses pipelines with python. I'm aware that I can do what the programs below do in python directly, but that's not the point. I just want to test the pipeline so I know how to use it.</p> <p>My system is Linux Ubuntu 9.04 with default python 2.6.</p> <p>I started with this <a href="http://docs.p...
28
2009-10-20T15:30:51Z
2,240,246
<p>Responding to nosklo's assertion (see other comments to this question) that it can't be done without <code>close_fds=True</code>:</p> <p><code>close_fds=True</code> is only necessary if you've left other file descriptors open. When opening multiple child processes, it's always good to keep track of open files that...
2
2010-02-10T20:49:51Z
[ "python", "ipc", "pipe", "subprocess", "blocking" ]
blocks - send input to python subprocess pipeline
1,595,492
<p>I'm testing subprocesses pipelines with python. I'm aware that I can do what the programs below do in python directly, but that's not the point. I just want to test the pipeline so I know how to use it.</p> <p>My system is Linux Ubuntu 9.04 with default python 2.6.</p> <p>I started with this <a href="http://docs.p...
28
2009-10-20T15:30:51Z
2,245,585
<p>Here's an example of using Popen together with os.fork to accomplish the same thing. Instead of using <code>close_fds</code> it just closes the pipes at the right places. Much simpler than trying to use <code>select.select</code>, and takes full advantage of system pipe buffers.</p> <pre><code>from subprocess imp...
-1
2010-02-11T15:44:39Z
[ "python", "ipc", "pipe", "subprocess", "blocking" ]
blocks - send input to python subprocess pipeline
1,595,492
<p>I'm testing subprocesses pipelines with python. I'm aware that I can do what the programs below do in python directly, but that's not the point. I just want to test the pipeline so I know how to use it.</p> <p>My system is Linux Ubuntu 9.04 with default python 2.6.</p> <p>I started with this <a href="http://docs.p...
28
2009-10-20T15:30:51Z
14,061,132
<h2>Working with large files</h2> <p>Two principles need to be applied uniformly when working with large files in Python.</p> <ol> <li>Since any IO routine can block, we must <strong>keep each stage of the pipeline in a different thread</strong> or process. We use threads in this example, but subprocesses would let y...
5
2012-12-27T20:49:46Z
[ "python", "ipc", "pipe", "subprocess", "blocking" ]
Threading in a PyQt application: Use Qt threads or Python threads?
1,595,649
<p>I'm writing a GUI application that regularly retrieves data through a web connection. Since this retrieval takes a while, this causes the UI to be unresponsive during the retrieval process (it cannot be split into smaller parts). This is why I'd like to outsource the web connection to a separate worker thread.</p> ...
74
2009-10-20T15:54:19Z
1,595,690
<p>Python's threads will be simpler and safer, and since it is for an I/O-based application, they are able to bypass the GIL. That said, have you considered non-blocking I/O using Twisted or non-blocking sockets/select?</p> <p><strong>EDIT: more on threads</strong></p> <p><strong>Python threads</strong></p> <p>Pytho...
23
2009-10-20T15:59:08Z
[ "python", "multithreading", "pyqt" ]
Threading in a PyQt application: Use Qt threads or Python threads?
1,595,649
<p>I'm writing a GUI application that regularly retrieves data through a web connection. Since this retrieval takes a while, this causes the UI to be unresponsive during the retrieval process (it cannot be split into smaller parts). This is why I'd like to outsource the web connection to a separate worker thread.</p> ...
74
2009-10-20T15:54:19Z
1,595,752
<p>Jeff has some good points. Only one main thread can do any GUI updates. If you do need to update the GUI from within the thread, Qt-4's <a href="http://doc.trolltech.com/4.5/qobject.html#connect-2">queued connection</a> signals make it easy to send data across threads and will automatically be invoked if you're us...
6
2009-10-20T16:10:59Z
[ "python", "multithreading", "pyqt" ]
Threading in a PyQt application: Use Qt threads or Python threads?
1,595,649
<p>I'm writing a GUI application that regularly retrieves data through a web connection. Since this retrieval takes a while, this causes the UI to be unresponsive during the retrieval process (it cannot be split into smaller parts). This is why I'd like to outsource the web connection to a separate worker thread.</p> ...
74
2009-10-20T15:54:19Z
1,595,754
<p>The advantage of <code>QThread</code> is that it's integrated with the rest of the Qt library. That is, thread-aware methods in Qt will need to know in which thread they run, and to move objects between threads, you will need to use <code>QThread</code>. Another useful feature is running your own event loop in a thr...
19
2009-10-20T16:11:23Z
[ "python", "multithreading", "pyqt" ]
Threading in a PyQt application: Use Qt threads or Python threads?
1,595,649
<p>I'm writing a GUI application that regularly retrieves data through a web connection. Since this retrieval takes a while, this causes the UI to be unresponsive during the retrieval process (it cannot be split into smaller parts). This is why I'd like to outsource the web connection to a separate worker thread.</p> ...
74
2009-10-20T15:54:19Z
1,620,078
<p>I can't comment on the exact differences between Python and PyQt threads, but I've been doing what you're attempting to do using <code>QThread</code>, <code>QNetworkAcessManager</code> and making sure to call <code>QApplication.processEvents()</code> while the thread is alive. If GUI responsiveness is really the is...
0
2009-10-25T05:24:57Z
[ "python", "multithreading", "pyqt" ]
Threading in a PyQt application: Use Qt threads or Python threads?
1,595,649
<p>I'm writing a GUI application that regularly retrieves data through a web connection. Since this retrieval takes a while, this causes the UI to be unresponsive during the retrieval process (it cannot be split into smaller parts). This is why I'd like to outsource the web connection to a separate worker thread.</p> ...
74
2009-10-20T15:54:19Z
1,628,262
<p>I asked myself the same question when I was working to <a href="http://pytalk.trunat.fr/">PyTalk</a>.</p> <p>If you are using Qt, you need to use <code>QThread</code> to be able to use the Qt framework and expecially the signal/slot system.</p> <p>With the signal/slot engine, you will be able to talk from a thread...
11
2009-10-27T01:17:08Z
[ "python", "multithreading", "pyqt" ]
Threading in a PyQt application: Use Qt threads or Python threads?
1,595,649
<p>I'm writing a GUI application that regularly retrieves data through a web connection. Since this retrieval takes a while, this causes the UI to be unresponsive during the retrieval process (it cannot be split into smaller parts). This is why I'd like to outsource the web connection to a separate worker thread.</p> ...
74
2009-10-20T15:54:19Z
1,636,035
<p>I can't really recommend either, but I can try describing differences between CPython and Qt threads.</p> <p>First of all, CPython threads do not run concurrently, at least not Python code. Yes, they do create system threads for each Python thread, however only the thread currently holding Global Interpreter Lock i...
4
2009-10-28T09:15:37Z
[ "python", "multithreading", "pyqt" ]
Threading in a PyQt application: Use Qt threads or Python threads?
1,595,649
<p>I'm writing a GUI application that regularly retrieves data through a web connection. Since this retrieval takes a while, this causes the UI to be unresponsive during the retrieval process (it cannot be split into smaller parts). This is why I'd like to outsource the web connection to a separate worker thread.</p> ...
74
2009-10-20T15:54:19Z
1,645,666
<p>This was <a href="http://www.mail-archive.com/pyqt@riverbankcomputing.com/msg16050.html">discussed</a> not too long ago in PyQt mailing list. Quoting Giovanni Bajo's <a href="http://www.mail-archive.com/pyqt@riverbankcomputing.com/msg16052.html">comments</a> on the subject:</p> <blockquote> <p>It's mostly the sam...
72
2009-10-29T18:28:21Z
[ "python", "multithreading", "pyqt" ]
Adding and subtracting dates without Standard Library
1,595,704
<p>I am working in a limited environment developing a python script. </p> <p>My issue is I must be able to accomplish datetime addition and subtractions.</p> <p>For example I get the following string:</p> <pre><code>"09/10/20,09:59:47-16" </code></pre> <p>Which is formatted as year/month/day,hour:minute:second-ms.<...
0
2009-10-20T16:02:46Z
1,595,720
<p>You are doing math in different bases. You need to parse the string and come up with a list of values, for example (year, month, day, hour, minute, second), and then do other-base math to add and subtract. For example, hours are base-24, so you need to use modulus to perform the calculations. This sounds suspiciousl...
2
2009-10-20T16:06:21Z
[ "python", "datetime" ]
Adding and subtracting dates without Standard Library
1,595,704
<p>I am working in a limited environment developing a python script. </p> <p>My issue is I must be able to accomplish datetime addition and subtractions.</p> <p>For example I get the following string:</p> <pre><code>"09/10/20,09:59:47-16" </code></pre> <p>Which is formatted as year/month/day,hour:minute:second-ms.<...
0
2009-10-20T16:02:46Z
1,595,725
<p>For completeness, datetime.datetime.strptime and datetime.timedelta are included in default python distribution.</p> <pre><code>from datetime import datetime, timedelta got = "09/10/20,09:59:47-16" dt = datetime.strptime(got, '%y/%m/%d,%H:%M:%S-%f') dt = dt + timedelta(seconds=30) print dt.strftime('%y/%m/%d,%H:%...
2
2009-10-20T16:06:40Z
[ "python", "datetime" ]
Adding and subtracting dates without Standard Library
1,595,704
<p>I am working in a limited environment developing a python script. </p> <p>My issue is I must be able to accomplish datetime addition and subtractions.</p> <p>For example I get the following string:</p> <pre><code>"09/10/20,09:59:47-16" </code></pre> <p>Which is formatted as year/month/day,hour:minute:second-ms.<...
0
2009-10-20T16:02:46Z
1,595,739
<p>The easiest way to perform date arithmetic is to not actually perform that arithmetic on the dates, but to do it to a simpler quantity.</p> <p>Typically, that simpler quantity is the number of seconds since a certain epoch. Jan 1, 1970 works out nicely. Knowing the epoch, and the number of days in each month, and w...
2
2009-10-20T16:09:10Z
[ "python", "datetime" ]
Adding and subtracting dates without Standard Library
1,595,704
<p>I am working in a limited environment developing a python script. </p> <p>My issue is I must be able to accomplish datetime addition and subtractions.</p> <p>For example I get the following string:</p> <pre><code>"09/10/20,09:59:47-16" </code></pre> <p>Which is formatted as year/month/day,hour:minute:second-ms.<...
0
2009-10-20T16:02:46Z
1,596,247
<p>Here's my solution to the problem:</p> <pre><code>year = int(s[0:2]) month = int(s[3:5]) day = int(s[6:8]) hour = int(s[9:11]) minute = int(s[12:14]) second = int(s[15:17]) amount_to_add = 30 second = second + amount_to_add days_in_month = 30 if(month == 1 or month == 3 or month == 5 or month ==7 or month == 8 or...
0
2009-10-20T17:49:25Z
[ "python", "datetime" ]
Spawning more than one thread in Python causes RuntimeError
1,595,772
<p>I'm trying to add multithreading to a Python app, and thus started with some toy examples :</p> <pre><code>import threading def myfunc(arg1, arg2): print 'In thread' print 'args are', arg1, arg2 thread = threading.Thread(target=myfunc, args=('asdf', 'jkle')) thread.start() thread.join() </code></pre> ...
0
2009-10-20T16:13:53Z
1,595,790
<pre><code>thread2 = threading.Thread(target=myfunc, args=('1234', '3763763é')) </code></pre> <p>Are you declaring the file as UTF-8?-----------------------------------------------------^</p>
1
2009-10-20T16:16:39Z
[ "python", "multithreading", "runtime-error" ]
Spawning more than one thread in Python causes RuntimeError
1,595,772
<p>I'm trying to add multithreading to a Python app, and thus started with some toy examples :</p> <pre><code>import threading def myfunc(arg1, arg2): print 'In thread' print 'args are', arg1, arg2 thread = threading.Thread(target=myfunc, args=('asdf', 'jkle')) thread.start() thread.join() </code></pre> ...
0
2009-10-20T16:13:53Z
1,595,814
<p>Can you post the exact error you get?</p> <p>Runs fine for me (after replacing the <code>é</code> character with an <code>e</code>):</p> <pre><code>In thread args areIn thread asdfargs are jkle1234 3763763e </code></pre> <p>If I leave the original script you posted and save the file as UTF-8 with BOM on Window...
1
2009-10-20T16:20:37Z
[ "python", "multithreading", "runtime-error" ]
Spawning more than one thread in Python causes RuntimeError
1,595,772
<p>I'm trying to add multithreading to a Python app, and thus started with some toy examples :</p> <pre><code>import threading def myfunc(arg1, arg2): print 'In thread' print 'args are', arg1, arg2 thread = threading.Thread(target=myfunc, args=('asdf', 'jkle')) thread.start() thread.join() </code></pre> ...
0
2009-10-20T16:13:53Z
1,690,410
<p>As said in the comments, I think that the problem comes from IDLE itself, and not from my code. Thanks for your help anyway !</p> <p>I upvoted your answers but will be accepting mine, as there is no real solution to this problem.</p>
0
2009-11-06T21:00:01Z
[ "python", "multithreading", "runtime-error" ]
Spawning more than one thread in Python causes RuntimeError
1,595,772
<p>I'm trying to add multithreading to a Python app, and thus started with some toy examples :</p> <pre><code>import threading def myfunc(arg1, arg2): print 'In thread' print 'args are', arg1, arg2 thread = threading.Thread(target=myfunc, args=('asdf', 'jkle')) thread.start() thread.join() </code></pre> ...
0
2009-10-20T16:13:53Z
3,466,269
<p>Maybe it is because you have the same filename or project name like "threading" or "Thread" under some directory and you have runned it once since this bootup. </p>
0
2010-08-12T09:24:33Z
[ "python", "multithreading", "runtime-error" ]
Read a single registry key value on a remote machine
1,595,806
<p>I am having a very tough time achieving this one seemingly very simple goal...</p> <p>I have to gather the value of a single registry key on several machines for the sake of auditing whether the machines scanned need to be patched with newer versions of software. I am only permitted to use python 3 as per our comp...
2
2009-10-20T16:19:17Z
1,611,880
<p>Can you show the code which you are writing? Have you opened the key? Many people do get problems since they have not opened it? This is just a guess, hope it works</p> <pre><code>key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, r'SYSTEM\CurrentControlSet\Enum\Root') </code></pre>
1
2009-10-23T07:33:38Z
[ "python", "windows", "python-3.x", "winreg", "remote-registry" ]
Django forms: making a disabled field persist between validations
1,596,054
<p>At some point I need to display a <code>"disabled"</code> (greyed out by <code>disabled="disabled"</code> attribute) input of type <code>"select"</code>. As specified in the standard (xhtml and html4), inputs of type <code>"select"</code> can not have the <code>"readonly"</code> attribute. Note that this is for pres...
6
2009-10-20T17:11:09Z
1,599,190
<p>Browsers don't POST disabled fields.</p> <p>You can try to copy <code>field</code>s initial value to <code>mock_field</code> in your Form's <code>__init__</code></p> <pre><code>def __init__(self, *args, **kwargs): super(SomeForm, self).__init__(*args, **kwargs) mock_initial = self.fields['field'].initial ...
3
2009-10-21T07:07:06Z
[ "python", "django", "django-forms" ]
Django forms: making a disabled field persist between validations
1,596,054
<p>At some point I need to display a <code>"disabled"</code> (greyed out by <code>disabled="disabled"</code> attribute) input of type <code>"select"</code>. As specified in the standard (xhtml and html4), inputs of type <code>"select"</code> can not have the <code>"readonly"</code> attribute. Note that this is for pres...
6
2009-10-20T17:11:09Z
1,635,901
<p>Well, this will be the first time I answer my question, but I've found a solution and (while it cerainly is a hack) it works.</p> <p>Instead of getting the initial value from the form instance, - <code>self.fields['whatever'].initial</code> seems to be <code>None</code> inside the constructor, I am getting the valu...
1
2009-10-28T08:44:21Z
[ "python", "django", "django-forms" ]
Python not sorting Unicode correctly
1,596,091
<pre><code>data = [unicode('č', "cp1250"), unicode('d', "cp1250"), unicode('a', "cp1250")] data.sort(key=unicode.lower) for x in range(0,len(data)): print data[x].encode("cp1250") </code></pre> <p>and I get:</p> <pre> a d č </pre> <p>It should be:</p> <pre> a č d </pre> <p>Slovenia Alphab...
2
2009-10-20T17:18:46Z
1,596,154
<p>See the <code>locale</code> module for language-aware sorting. Especially the <code>strcoll</code> and <code>strxfrm</code> functions.</p>
1
2009-10-20T17:32:16Z
[ "python" ]
Python not sorting Unicode correctly
1,596,091
<pre><code>data = [unicode('č', "cp1250"), unicode('d', "cp1250"), unicode('a', "cp1250")] data.sort(key=unicode.lower) for x in range(0,len(data)): print data[x].encode("cp1250") </code></pre> <p>and I get:</p> <pre> a d č </pre> <p>It should be:</p> <pre> a č d </pre> <p>Slovenia Alphab...
2
2009-10-20T17:18:46Z
1,716,705
<p>I solved this problem an now have a working program:</p> <pre><code>import locale locale.setlocale(locale.LC_ALL, 'slovenian') data = ['č', 'ab', 'aa', 'a', 'd', 'ć', 'B', 'c'] data.sort(key=locale.strxfrm) print "Sorted..." for x in range(0,len(data)): print data[x] </code></pre>
2
2009-11-11T17:17:25Z
[ "python" ]
Can I execute an SQL Server DTS package from a Python script?
1,596,270
<p>I currently have a number of Python scripts that help prep a staging area for testing. One thing that the scripts do not handle is executing DTS packages on MS SQL Server. Is there a way to execute these packages using Python?</p>
2
2009-10-20T17:53:08Z
1,596,281
<p>Is calling the DTS run from the command line an option. If so here is an example for that.</p> <p><a href="http://www.mssqltips.com/tip.asp?tip=1007" rel="nofollow">http://www.mssqltips.com/tip.asp?tip=1007</a></p>
1
2009-10-20T17:56:15Z
[ "python", "sql-server" ]
Can I execute an SQL Server DTS package from a Python script?
1,596,270
<p>I currently have a number of Python scripts that help prep a staging area for testing. One thing that the scripts do not handle is executing DTS packages on MS SQL Server. Is there a way to execute these packages using Python?</p>
2
2009-10-20T17:53:08Z
1,596,450
<p>The answer is yes. As mentioned by lansinwd, you'd want to use the command line tool <a href="http://msdn.microsoft.com/en-us/library/aa224467%28SQL.80%29.aspx" rel="nofollow">DTSRun</a>. SQL Server tools will need to be installed on the machine executing the Python script. I'm not sure what percentage or which pack...
1
2009-10-20T18:25:48Z
[ "python", "sql-server" ]
filtering lists in python
1,596,390
<p>I want to filter repeated elements in my list for instance</p> <pre><code>foo = ['a','b','c','a','b','d','a','d'] </code></pre> <p>I am only interested with:</p> <pre><code>['a','b','c','d'] </code></pre> <p>What would be the efficient way to do achieve this ? Cheers</p>
4
2009-10-20T18:12:40Z
1,596,399
<p>Cast foo to a <a href="http://docs.python.org/library/stdtypes.html#set">set</a>, if you don't care about element order. </p>
12
2009-10-20T18:14:26Z
[ "python", "list", "unique" ]
filtering lists in python
1,596,390
<p>I want to filter repeated elements in my list for instance</p> <pre><code>foo = ['a','b','c','a','b','d','a','d'] </code></pre> <p>I am only interested with:</p> <pre><code>['a','b','c','d'] </code></pre> <p>What would be the efficient way to do achieve this ? Cheers</p>
4
2009-10-20T18:12:40Z
1,596,400
<p><code>list(</code><a href="http://docs.python.org/library/stdtypes.html#set"><code>set</code></a><code>(foo))</code> if you are using Python 2.5 or greater, but that doesn't maintain order.</p>
20
2009-10-20T18:14:27Z
[ "python", "list", "unique" ]
filtering lists in python
1,596,390
<p>I want to filter repeated elements in my list for instance</p> <pre><code>foo = ['a','b','c','a','b','d','a','d'] </code></pre> <p>I am only interested with:</p> <pre><code>['a','b','c','d'] </code></pre> <p>What would be the efficient way to do achieve this ? Cheers</p>
4
2009-10-20T18:12:40Z
1,596,435
<p>If you care about order a readable way is the following</p> <pre><code>def filter_unique(a_list): characters = set() result = [] for c in a_list: if not c in characters: characters.add(c) result.append(c) return result </code></pre> <p>Depending on your requirements ...
2
2009-10-20T18:21:41Z
[ "python", "list", "unique" ]
filtering lists in python
1,596,390
<p>I want to filter repeated elements in my list for instance</p> <pre><code>foo = ['a','b','c','a','b','d','a','d'] </code></pre> <p>I am only interested with:</p> <pre><code>['a','b','c','d'] </code></pre> <p>What would be the efficient way to do achieve this ? Cheers</p>
4
2009-10-20T18:12:40Z
1,596,471
<pre><code>&gt;&gt;&gt; bar = [] &gt;&gt;&gt; for i in foo: if i not in bar: bar.append(i) &gt;&gt;&gt; bar ['a', 'b', 'c', 'd'] </code></pre> <p>this would be the most straightforward way of removing duplicates from the list and preserving the order as much as possible (even though "order" here is inherentl...
3
2009-10-20T18:29:51Z
[ "python", "list", "unique" ]
filtering lists in python
1,596,390
<p>I want to filter repeated elements in my list for instance</p> <pre><code>foo = ['a','b','c','a','b','d','a','d'] </code></pre> <p>I am only interested with:</p> <pre><code>['a','b','c','d'] </code></pre> <p>What would be the efficient way to do achieve this ? Cheers</p>
4
2009-10-20T18:12:40Z
1,598,114
<p>If you write a function to do this i would use a generator, it just wants to be used in this case.</p> <pre>def unique(iterable): yielded = set() for item in iterable: if item not in yielded: yield item yielded.add(item) </pre>
2
2009-10-21T00:33:40Z
[ "python", "list", "unique" ]
filtering lists in python
1,596,390
<p>I want to filter repeated elements in my list for instance</p> <pre><code>foo = ['a','b','c','a','b','d','a','d'] </code></pre> <p>I am only interested with:</p> <pre><code>['a','b','c','d'] </code></pre> <p>What would be the efficient way to do achieve this ? Cheers</p>
4
2009-10-20T18:12:40Z
1,598,161
<p>Since there isn't an order-preserving answer with a list comprehension, I propose the following:</p> <pre><code>&gt;&gt;&gt; temp = set() &gt;&gt;&gt; [c for c in foo if c not in temp and (temp.add(c) or True)] ['a', 'b', 'c', 'd'] </code></pre> <p>which could also be written as</p> <pre><code>&gt;&gt;&gt; temp =...
5
2009-10-21T00:47:04Z
[ "python", "list", "unique" ]
filtering lists in python
1,596,390
<p>I want to filter repeated elements in my list for instance</p> <pre><code>foo = ['a','b','c','a','b','d','a','d'] </code></pre> <p>I am only interested with:</p> <pre><code>['a','b','c','d'] </code></pre> <p>What would be the efficient way to do achieve this ? Cheers</p>
4
2009-10-20T18:12:40Z
1,598,187
<p>Inspired by <a href="http://stackoverflow.com/questions/1596390/filtering-lists-in-python/1596435#1596435">Francesco's answer</a>, rather than making our own <code>filter()</code>-type function, let's make the builtin do some work for us:</p> <pre><code>def unique(a, s=set()): if a not in s: s.add(a) ...
1
2009-10-21T00:55:38Z
[ "python", "list", "unique" ]
filtering lists in python
1,596,390
<p>I want to filter repeated elements in my list for instance</p> <pre><code>foo = ['a','b','c','a','b','d','a','d'] </code></pre> <p>I am only interested with:</p> <pre><code>['a','b','c','d'] </code></pre> <p>What would be the efficient way to do achieve this ? Cheers</p>
4
2009-10-20T18:12:40Z
1,598,668
<p>This is what you want if you need a sorted list at the end:</p> <pre><code>&gt;&gt;&gt; foo = ['a','b','c','a','b','d','a','d'] &gt;&gt;&gt; bar = sorted(set(foo)) &gt;&gt;&gt; bar ['a', 'b', 'c', 'd'] </code></pre>
1
2009-10-21T04:06:16Z
[ "python", "list", "unique" ]
filtering lists in python
1,596,390
<p>I want to filter repeated elements in my list for instance</p> <pre><code>foo = ['a','b','c','a','b','d','a','d'] </code></pre> <p>I am only interested with:</p> <pre><code>['a','b','c','d'] </code></pre> <p>What would be the efficient way to do achieve this ? Cheers</p>
4
2009-10-20T18:12:40Z
13,634,235
<pre><code>import numpy as np np.unique(foo) </code></pre>
0
2012-11-29T20:32:22Z
[ "python", "list", "unique" ]
filtering lists in python
1,596,390
<p>I want to filter repeated elements in my list for instance</p> <pre><code>foo = ['a','b','c','a','b','d','a','d'] </code></pre> <p>I am only interested with:</p> <pre><code>['a','b','c','d'] </code></pre> <p>What would be the efficient way to do achieve this ? Cheers</p>
4
2009-10-20T18:12:40Z
23,282,658
<p>You could do a sort of ugly list comprehension hack.</p> <pre><code>[l[i] for i in range(len(l)) if l.index(l[i]) == i] </code></pre>
0
2014-04-25T01:23:29Z
[ "python", "list", "unique" ]
Which Python client library should I use for CouchdB?
1,596,440
<p>I'm starting to experiment with CouchDB because it looks like the perfect solution for certain problems we have. Given that all work will be on a brand new project with no legacy dependencies, which client library would you suggest that I use, and why?</p> <p>This would be easier if there was any overlap on the OS...
14
2009-10-20T18:23:05Z
1,597,169
<p>I have been using <a href="http://code.google.com/p/couchdb-python/">couchdb-python</a> with quite a lot of success and as far as I know the guys of desktopcouch use it in ubuntu. The prerequisites are very basic and you should have not problems:</p> <ul> <li>httplib2</li> <li>simplejson or cjson</li> <li>Python</l...
5
2009-10-20T20:41:02Z
[ "python", "couchdb" ]
Which Python client library should I use for CouchdB?
1,596,440
<p>I'm starting to experiment with CouchDB because it looks like the perfect solution for certain problems we have. Given that all work will be on a brand new project with no legacy dependencies, which client library would you suggest that I use, and why?</p> <p>This would be easier if there was any overlap on the OS...
14
2009-10-20T18:23:05Z
1,597,325
<p>Considering the task you are trying to solve (distributed task processing) you should consider using one of the many tools designed for message passing rather than using a database. See for instance <a href="http://stackoverflow.com/questions/1516960/anatomy-of-a-distributed-system-in-php">this SO question on runnin...
0
2009-10-20T21:10:03Z
[ "python", "couchdb" ]
Which Python client library should I use for CouchdB?
1,596,440
<p>I'm starting to experiment with CouchDB because it looks like the perfect solution for certain problems we have. Given that all work will be on a brand new project with no legacy dependencies, which client library would you suggest that I use, and why?</p> <p>This would be easier if there was any overlap on the OS...
14
2009-10-20T18:23:05Z
1,721,072
<p>If you're still considering CouchDB then I'll recommend Couchdbkit (<a href="http://www.couchdbkit.org" rel="nofollow">http://www.couchdbkit.org</a>). It's simple enough to quickly get a hang on and runs fine on my machine running Karmic Koala. Prior to that I've tried couchdb-python but some bugs (maybe ironed out ...
2
2009-11-12T09:41:58Z
[ "python", "couchdb" ]
Which Python client library should I use for CouchdB?
1,596,440
<p>I'm starting to experiment with CouchDB because it looks like the perfect solution for certain problems we have. Given that all work will be on a brand new project with no legacy dependencies, which client library would you suggest that I use, and why?</p> <p>This would be easier if there was any overlap on the OS...
14
2009-10-20T18:23:05Z
15,859,496
<h1>spycouch</h1> <p>Simple Python API for CouchDB </p> <p>Python library for easily manage CouchDB.</p> <p>Compared to ordinarily available libraries on web, works with the latest version CouchDB - 1.2.1</p> <h2>Functionality</h2> <blockquote> <p>Create a new database on the server</p> <p>Deleting a databa...
1
2013-04-07T06:12:21Z
[ "python", "couchdb" ]
Which Python client library should I use for CouchdB?
1,596,440
<p>I'm starting to experiment with CouchDB because it looks like the perfect solution for certain problems we have. Given that all work will be on a brand new project with no legacy dependencies, which client library would you suggest that I use, and why?</p> <p>This would be easier if there was any overlap on the OS...
14
2009-10-20T18:23:05Z
17,788,369
<p>I have written a couchdb client library built on python-requests (which is in most distributions). We use this library in production. </p> <p><a href="https://github.com/adamlofts/couchdb-requests" rel="nofollow">https://github.com/adamlofts/couchdb-requests</a></p> <blockquote> <p>Robust CouchDB Python interfac...
0
2013-07-22T13:04:41Z
[ "python", "couchdb" ]
Which Python client library should I use for CouchdB?
1,596,440
<p>I'm starting to experiment with CouchDB because it looks like the perfect solution for certain problems we have. Given that all work will be on a brand new project with no legacy dependencies, which client library would you suggest that I use, and why?</p> <p>This would be easier if there was any overlap on the OS...
14
2009-10-20T18:23:05Z
28,433,350
<p>After skimming through the docs of many couchdb python libraries, my choice went to <strong>pycouchdb</strong>.</p> <p>All I needed to know was very quick to grasp from the doc: <a href="https://py-couchdb.readthedocs.org/en/latest/" rel="nofollow">https://py-couchdb.readthedocs.org/en/latest/</a> and it works like...
0
2015-02-10T13:52:28Z
[ "python", "couchdb" ]
django urls without a trailing slash do not redirect
1,596,552
<p>I've got two applications located on two separate computers. On computer A, in the <code>urls.py</code> file I have a line like the following: </p> <pre><code>(r'^cast/$', 'mySite.simulate.views.cast') </code></pre> <p>And that url will work for both <code>mySite.com/cast/</code> and <code>mySite.com/cast</code>. ...
42
2009-10-20T18:41:56Z
1,596,600
<p>check your <code>APPEND_SLASH</code> setting in the settings.py file</p> <p><a href="http://docs.djangoproject.com/en/dev/ref/settings/#append-slash">more info in the django docs</a></p>
58
2009-10-20T18:49:39Z
[ "python", "django", "django-urls" ]
django urls without a trailing slash do not redirect
1,596,552
<p>I've got two applications located on two separate computers. On computer A, in the <code>urls.py</code> file I have a line like the following: </p> <pre><code>(r'^cast/$', 'mySite.simulate.views.cast') </code></pre> <p>And that url will work for both <code>mySite.com/cast/</code> and <code>mySite.com/cast</code>. ...
42
2009-10-20T18:41:56Z
11,690,144
<p>Or you can write your urls like this:</p> <pre><code>(r'^login/?$', 'mySite.myUser.views.login') </code></pre> <p>The question sign after the trailing slash makes it optional in regexp. Use it if for some reasons you don't want to use APPEND_SLASH setting.</p>
100
2012-07-27T14:44:14Z
[ "python", "django", "django-urls" ]
django urls without a trailing slash do not redirect
1,596,552
<p>I've got two applications located on two separate computers. On computer A, in the <code>urls.py</code> file I have a line like the following: </p> <pre><code>(r'^cast/$', 'mySite.simulate.views.cast') </code></pre> <p>And that url will work for both <code>mySite.com/cast/</code> and <code>mySite.com/cast</code>. ...
42
2009-10-20T18:41:56Z
30,736,341
<p>I've had the same problem. In my case it was a stale leftover from some old version in urls.py, from before staticfiles:</p> <pre><code>url(r'^%s(?P&lt;path&gt;.*)$' % settings.MEDIA_URL.lstrip('/'), 'django.views.static.serve', kwargs={'document_root': settings.MEDIA_ROOT}), </code></pre> <p>MEDIA_URL was...
0
2015-06-09T15:23:42Z
[ "python", "django", "django-urls" ]
django urls without a trailing slash do not redirect
1,596,552
<p>I've got two applications located on two separate computers. On computer A, in the <code>urls.py</code> file I have a line like the following: </p> <pre><code>(r'^cast/$', 'mySite.simulate.views.cast') </code></pre> <p>And that url will work for both <code>mySite.com/cast/</code> and <code>mySite.com/cast</code>. ...
42
2009-10-20T18:41:56Z
32,078,961
<p>I've had the same problem too. My solution was put an (|/) before the end line of my regular expression.</p> <p><code>url(r'^artists/(?P[\d]+)(|/)$', ArtistDetailView.as_view()),</code></p>
1
2015-08-18T17:30:07Z
[ "python", "django", "django-urls" ]
django urls without a trailing slash do not redirect
1,596,552
<p>I've got two applications located on two separate computers. On computer A, in the <code>urls.py</code> file I have a line like the following: </p> <pre><code>(r'^cast/$', 'mySite.simulate.views.cast') </code></pre> <p>And that url will work for both <code>mySite.com/cast/</code> and <code>mySite.com/cast</code>. ...
42
2009-10-20T18:41:56Z
37,603,563
<p>This improves on @Michael Gendin's answer. His answer serves the identical page with two separate URLs. It would be better to have <code>login</code> automatically redirect to <code>login/</code>, and then serve the latter as the main page:</p> <pre><code>from django.conf.urls import patterns from django.views.gene...
0
2016-06-02T23:11:40Z
[ "python", "django", "django-urls" ]
XML Parsing with Python and minidom
1,596,829
<p>I'm using Python (minidom) to parse an XML file that prints a hierarchical structure that looks something like this (indentation is used here to show the significant hierarchical relationship):</p> <pre><code>My Document Overview Basic Features About This Software Platforms Supported </code></pre> ...
12
2009-10-20T19:36:07Z
1,597,645
<p>getElementsByTagName is recursive, you'll get <em>all</em> descendents with a matching tagName. Because your Topics contain other Topics that also have Titles, the call will get the lower-down Titles many times.</p> <p>If you want to ask for all matching direct children only, and you don't have XPath available, you...
6
2009-10-20T22:17:38Z
[ "python", "xml", "minidom" ]
XML Parsing with Python and minidom
1,596,829
<p>I'm using Python (minidom) to parse an XML file that prints a hierarchical structure that looks something like this (indentation is used here to show the significant hierarchical relationship):</p> <pre><code>My Document Overview Basic Features About This Software Platforms Supported </code></pre> ...
12
2009-10-20T19:36:07Z
1,598,016
<p>Let me put that comment here ...</p> <p>Thanks for the attempt. It didn't work but it gave me some ideas. The following works (the same general idea; FWIW, the nodeType is ELEMENT_NODE):</p> <pre><code>import xml.dom.minidom from xml.dom.minidom import Node dom = xml.dom.minidom.parse("docmap.xml") def getChildr...
7
2009-10-21T00:04:10Z
[ "python", "xml", "minidom" ]
XML Parsing with Python and minidom
1,596,829
<p>I'm using Python (minidom) to parse an XML file that prints a hierarchical structure that looks something like this (indentation is used here to show the significant hierarchical relationship):</p> <pre><code>My Document Overview Basic Features About This Software Platforms Supported </code></pre> ...
12
2009-10-20T19:36:07Z
1,602,792
<p>You could use the following generator to run through the list and get titles with indentation levels:</p> <pre><code>def f(elem, level=-1): if elem.nodeName == "Title": yield elem.childNodes[0].nodeValue, level elif elem.nodeType == elem.ELEMENT_NODE: for child in elem.childNodes: ...
3
2009-10-21T18:45:23Z
[ "python", "xml", "minidom" ]