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
How to install pycairo on osx?
1,500,866
<p>I am trying to install the <a href="http://cairographics.org/pycairo/">pycairo</a> (Python bindings for the <a href="http://cairographics.org/">cairo graphics library</a>) under OSX.</p> <p>I started with</p> <pre><code>easy_install pycairo </code></pre> <p>and got: </p> <pre><code>Requested 'cairo &gt;= 1.8.8' ...
6
2009-09-30T21:53:36Z
1,500,978
<p>Ok. I solved it. Putting solution here for future reference, it might help someone.</p> <p>Basically, the whole ports/fink system is a bit messed up, and osx doesn't really play nice with the linux-y world.</p> <p>So, the steps I needed to install pycairo on OSX were:</p> <ul> <li>download the latest source ver...
6
2009-09-30T22:29:17Z
[ "python", "osx", "installation", "makefile", "cairo" ]
How to install pycairo on osx?
1,500,866
<p>I am trying to install the <a href="http://cairographics.org/pycairo/">pycairo</a> (Python bindings for the <a href="http://cairographics.org/">cairo graphics library</a>) under OSX.</p> <p>I started with</p> <pre><code>easy_install pycairo </code></pre> <p>and got: </p> <pre><code>Requested 'cairo &gt;= 1.8.8' ...
6
2009-09-30T21:53:36Z
1,811,820
<p>The <code>port</code> command installs the library for the darwinports python installation, which is different to the framework build (so steps 2 and 3 shouldn't work). Try <code>sudo easy_install pycairo</code> instead (although your step 4 should be equivalent to this).</p> <p>Look at <code>which python</code> to...
3
2009-11-28T06:52:25Z
[ "python", "osx", "installation", "makefile", "cairo" ]
How to install pycairo on osx?
1,500,866
<p>I am trying to install the <a href="http://cairographics.org/pycairo/">pycairo</a> (Python bindings for the <a href="http://cairographics.org/">cairo graphics library</a>) under OSX.</p> <p>I started with</p> <pre><code>easy_install pycairo </code></pre> <p>and got: </p> <pre><code>Requested 'cairo &gt;= 1.8.8' ...
6
2009-09-30T21:53:36Z
1,811,869
<p>It appears you are mixing various install options here. The MacPorts package system <code>port install</code> command should automatically pull in all the dependencies needed for a particular package so the trick is to start with the right top-level project. For python packages, MacPorts has a general convention c...
6
2009-11-28T07:26:38Z
[ "python", "osx", "installation", "makefile", "cairo" ]
How to install pycairo on osx?
1,500,866
<p>I am trying to install the <a href="http://cairographics.org/pycairo/">pycairo</a> (Python bindings for the <a href="http://cairographics.org/">cairo graphics library</a>) under OSX.</p> <p>I started with</p> <pre><code>easy_install pycairo </code></pre> <p>and got: </p> <pre><code>Requested 'cairo &gt;= 1.8.8' ...
6
2009-09-30T21:53:36Z
2,045,043
<p>On Mac OS you can have multiple Python versions installed. You can have even more if you decide to install Python via Fink or MacPorts. When you compile libraries from the source, you should make sure they point to the correct installation.</p> <p>I currently have Python 2.5.1 and Python 2.6.4 installed on my machi...
2
2010-01-11T21:22:21Z
[ "python", "osx", "installation", "makefile", "cairo" ]
How to install pycairo on osx?
1,500,866
<p>I am trying to install the <a href="http://cairographics.org/pycairo/">pycairo</a> (Python bindings for the <a href="http://cairographics.org/">cairo graphics library</a>) under OSX.</p> <p>I started with</p> <pre><code>easy_install pycairo </code></pre> <p>and got: </p> <pre><code>Requested 'cairo &gt;= 1.8.8' ...
6
2009-09-30T21:53:36Z
30,089,130
<p>I found <a href="http://www.pydanny.com/installing-pycairo-on-mountain-lion.html">this</a> instruction very helpful and much less confusing. I am on Yosemite and it worked very well for me. This instruction uses homebrew to install. So if you already have homebrew, these two commands should be helpful:</p> <pre><co...
6
2015-05-06T23:02:42Z
[ "python", "osx", "installation", "makefile", "cairo" ]
Python Decorator for GAE Web-Service Security Check
1,500,982
<p>In this post, Nick suggested a decoartor: </p> <p><a href="http://stackoverflow.com/questions/1499832/python-webapp-google-app-engine-testing-for-user-pass-in-the-headers/1500047#1500047">http://stackoverflow.com/questions/1499832/python-webapp-google-app-engine-testing-for-user-pass-in-the-headers/1500047#1500047<...
0
2009-09-30T22:31:37Z
1,501,036
<p>Class decorators were added in <a href="http://docs.python.org/whatsnew/2.6.html#pep-3129-class-decorators" rel="nofollow">Python 2.6</a>.</p> <p>You'll have to manually wrap the class or think of another solution to work under 2.5. How about writing a decorator for the <code>get</code> method instead?</p>
2
2009-09-30T22:42:36Z
[ "python", "google-app-engine", "decorator", "web-services" ]
Python Decorator for GAE Web-Service Security Check
1,500,982
<p>In this post, Nick suggested a decoartor: </p> <p><a href="http://stackoverflow.com/questions/1499832/python-webapp-google-app-engine-testing-for-user-pass-in-the-headers/1500047#1500047">http://stackoverflow.com/questions/1499832/python-webapp-google-app-engine-testing-for-user-pass-in-the-headers/1500047#1500047<...
0
2009-09-30T22:31:37Z
1,502,482
<p>You need to write a method decorator, not a class decorator: As lost-theory points out, class decorators don't exist in Python 2.5, and they wouldn't work very well in any case, because the RequestHandler class isn't initialized with request data until <em>after</em> it's constructed. A method decorator also gives y...
2
2009-10-01T07:50:44Z
[ "python", "google-app-engine", "decorator", "web-services" ]
Find current geographic coordinates from Python script
1,501,008
<p>I'm tying to get a certain Python script (although I guess it isn't really the language that's going to matter here) to find out the current geographic location of the machine running it. As you might have guessed, it's a little script that reports my laptop's location when it boots and stuff :)<br/> Is there any fr...
2
2009-09-30T22:36:43Z
1,501,106
<p>I came across this Python script <a href="http://netsekure.org/wp-content/uploads/ip2loc.py" rel="nofollow">http://netsekure.org/wp-content/uploads/ip2loc.py</a> which might be something similar to what you are looking for.</p>
3
2009-09-30T23:01:49Z
[ "python", "api", "geolocation", "location" ]
Find current geographic coordinates from Python script
1,501,008
<p>I'm tying to get a certain Python script (although I guess it isn't really the language that's going to matter here) to find out the current geographic location of the machine running it. As you might have guessed, it's a little script that reports my laptop's location when it boots and stuff :)<br/> Is there any fr...
2
2009-09-30T22:36:43Z
1,501,178
<p>You may be able to use Google's GeoLocation API (API docs <a href="http://code.google.com/apis/gears/geolocation%5Fnetwork%5Fprotocol.html" rel="nofollow">here</a>). From the docs:</p> <p>"Communication is done over HTTP, with Gears making the request using HTTP POST. Both request and response are formatted as JSON...
1
2009-09-30T23:23:02Z
[ "python", "api", "geolocation", "location" ]
What's the most pythonic way to ensure that all elements of a list are different?
1,501,118
<p>I have a list in Python that I generate as part of the program. I have a strong assumption that these are all different, and I check this with an assertion.</p> <p>This is the way I do it now:</p> <p>If there are two elements:</p> <pre><code>try: assert(x[0] != x[1]) except: print debug_info raise Ex...
8
2009-09-30T23:07:02Z
1,501,133
<p>Maybe something like this:</p> <pre><code>if len(x) == len(set(x)): print "all elements are unique" else: print "elements are not unique" </code></pre>
26
2009-09-30T23:09:26Z
[ "python", "list", "unique" ]
What's the most pythonic way to ensure that all elements of a list are different?
1,501,118
<p>I have a list in Python that I generate as part of the program. I have a strong assumption that these are all different, and I check this with an assertion.</p> <p>This is the way I do it now:</p> <p>If there are two elements:</p> <pre><code>try: assert(x[0] != x[1]) except: print debug_info raise Ex...
8
2009-09-30T23:07:02Z
1,501,141
<p>How about this:</p> <pre><code>if len(x) != len(set(x)): raise Exception("throw to caller") </code></pre> <p>This assumes that elements in <code>x</code> are hashable.</p>
7
2009-09-30T23:11:09Z
[ "python", "list", "unique" ]
What's the most pythonic way to ensure that all elements of a list are different?
1,501,118
<p>I have a list in Python that I generate as part of the program. I have a strong assumption that these are all different, and I check this with an assertion.</p> <p>This is the way I do it now:</p> <p>If there are two elements:</p> <pre><code>try: assert(x[0] != x[1]) except: print debug_info raise Ex...
8
2009-09-30T23:07:02Z
1,501,202
<p>Hopefully all the items in your sequence are immutable -- if not, you will not be able to call <code>set</code> on the sequence.</p> <pre><code>&gt;&gt;&gt; set( ([1,2], [3,4]) ) Traceback (most recent call last): File "&lt;stdin&gt;", line 1, in &lt;module&gt; TypeError: unhashable type: 'list' </code></pre> <p...
2
2009-09-30T23:31:47Z
[ "python", "list", "unique" ]
What's the most pythonic way to ensure that all elements of a list are different?
1,501,118
<p>I have a list in Python that I generate as part of the program. I have a strong assumption that these are all different, and I check this with an assertion.</p> <p>This is the way I do it now:</p> <p>If there are two elements:</p> <pre><code>try: assert(x[0] != x[1]) except: print debug_info raise Ex...
8
2009-09-30T23:07:02Z
1,501,231
<p>As you build the list you can check to see if the value already exists, e.g:</p> <pre><code>if x in y: raise Exception("Value %s already in y" % x) else: y.append(x) </code></pre> <p>the benefit of this is that the clashing variable will be reported.</p>
1
2009-09-30T23:40:31Z
[ "python", "list", "unique" ]
What's the most pythonic way to ensure that all elements of a list are different?
1,501,118
<p>I have a list in Python that I generate as part of the program. I have a strong assumption that these are all different, and I check this with an assertion.</p> <p>This is the way I do it now:</p> <p>If there are two elements:</p> <pre><code>try: assert(x[0] != x[1]) except: print debug_info raise Ex...
8
2009-09-30T23:07:02Z
1,501,460
<p>You could process the list to create a known-to-be-unique copy:</p> <pre><code>def make_unique(seq): t = type(seq) seen = set() return t(c for c in seq if not (c in seen or seen.add(c))) </code></pre> <p>Or if the seq elements are not hashable:</p> <pre><code>def unique1(seq): t = type(seq) ...
0
2009-10-01T01:22:28Z
[ "python", "list", "unique" ]
What's the most pythonic way to ensure that all elements of a list are different?
1,501,118
<p>I have a list in Python that I generate as part of the program. I have a strong assumption that these are all different, and I check this with an assertion.</p> <p>This is the way I do it now:</p> <p>If there are two elements:</p> <pre><code>try: assert(x[0] != x[1]) except: print debug_info raise Ex...
8
2009-09-30T23:07:02Z
1,501,503
<p>The most popular answers are O(N) (good!-) but, as @Paul and @Mark point out, they require the list's items to be hashable. Both @Paul and @Mark's proposed approaches for unhashable items are general but take O(N squared) -- i.e., a lot.</p> <p>If your list's items are not hashable but <em>are</em> comparable, you ...
18
2009-10-01T01:45:12Z
[ "python", "list", "unique" ]
What's the most pythonic way to ensure that all elements of a list are different?
1,501,118
<p>I have a list in Python that I generate as part of the program. I have a strong assumption that these are all different, and I check this with an assertion.</p> <p>This is the way I do it now:</p> <p>If there are two elements:</p> <pre><code>try: assert(x[0] != x[1]) except: print debug_info raise Ex...
8
2009-09-30T23:07:02Z
1,503,165
<p>I would use this:</p> <pre><code>mylist = [1,2,3,4] is_unique = all(mylist.count(x) == 1 for x in mylist) </code></pre>
0
2009-10-01T10:32:14Z
[ "python", "list", "unique" ]
Named and default arguments class arguments in Python
1,501,208
<p>In PHP, I have to pass the arguments in the same order as the arguments are in the constructor.</p> <p>Now, in Python, take</p> <pre><code>listbox = Listbox(root, yscrollcommand=scrollbar.set) </code></pre> <p>for example.</p> <p>If I had passed yscrollcommand=scrollbar.set as the third argument and yscrollcomma...
1
2009-09-30T23:33:56Z
1,501,246
<p>Named arguments don't have to be in order.</p> <pre><code>class xyz: def __init__ (self, a='1', b='2'): print a,b xyz(b=3,a=4) xyz(a=5,b=6) &gt;&gt;4 3 &gt;&gt;5 6 </code></pre>
4
2009-09-30T23:44:47Z
[ "python", "arguments", "default", "named" ]
Named and default arguments class arguments in Python
1,501,208
<p>In PHP, I have to pass the arguments in the same order as the arguments are in the constructor.</p> <p>Now, in Python, take</p> <pre><code>listbox = Listbox(root, yscrollcommand=scrollbar.set) </code></pre> <p>for example.</p> <p>If I had passed yscrollcommand=scrollbar.set as the third argument and yscrollcomma...
1
2009-09-30T23:33:56Z
1,501,253
<p>It is explained <a href="http://diveintopython.net/power_of_introspection/and_or.html" rel="nofollow">here</a>.</p>
1
2009-09-30T23:47:28Z
[ "python", "arguments", "default", "named" ]
Log output of multiprocessing.Process
1,501,651
<p>Is there a way to log the stdout output from a given Process when using the multiprocessing.Process class in python?</p>
43
2009-10-01T02:44:03Z
1,501,756
<p>You can set <code>sys.stdout = Logger()</code> where <code>Logger</code> is a class whose <code>write</code> method (immediately, or accumulating until a <code>\n</code> is detected) calls <code>logging.info</code> (or any other way you want to log). <a href="https://github.com/jdloft/multiprocess-logging/blob/maste...
9
2009-10-01T03:29:57Z
[ "python", "logging", "concurrency", "multiprocessing" ]
Log output of multiprocessing.Process
1,501,651
<p>Is there a way to log the stdout output from a given Process when using the multiprocessing.Process class in python?</p>
43
2009-10-01T02:44:03Z
1,501,757
<p>The easiest way might be to just override <code>sys.stdout</code>. Slightly modifying an example from <a href="http://docs.python.org/library/multiprocessing.html#the-process-class">the multiprocessing manual</a>:</p> <pre><code>from multiprocessing import Process import os import sys def info(title): print t...
32
2009-10-01T03:30:09Z
[ "python", "logging", "concurrency", "multiprocessing" ]
Log output of multiprocessing.Process
1,501,651
<p>Is there a way to log the stdout output from a given Process when using the multiprocessing.Process class in python?</p>
43
2009-10-01T02:44:03Z
23,937,468
<p>There are only two things I would add to @Mark Rushakoff answer. When debugging, I found it really useful to change the <code>buffering</code> parameter of my <code>open()</code> calls to 0.</p> <pre><code>sys.stdout = open(str(os.getpid()) + ".out", "a", buffering=0) </code></pre> <p>Otherwise, <strong>madness</s...
7
2014-05-29T15:51:01Z
[ "python", "logging", "concurrency", "multiprocessing" ]
Parsing out data using BeautifulSoup in Python
1,501,690
<p>I am attempting to use BeautifulSoup to parse through a DOM tree and extract the names of authors. Below is a snippet of HTML to show the structure of the code I'm going to scrape. </p> <pre><code>&lt;html&gt; &lt;body&gt; &lt;div class="list-authors"&gt; &lt;span class="descriptor"&gt;Authors:&lt;/span&gt; &lt;a ...
9
2009-10-01T02:59:32Z
1,501,715
<p>Since <code>link</code> is already taken from an iterable, you don't need to subindex <code>link</code> -- you can just do <code>link.contents[0]</code>.</p> <p><code>print link.contents[0]</code> with your new example with two separate <code>&lt;div class="list-authors"&gt;</code> yields:</p> <pre>Dacheng Lin Ron...
1
2009-10-01T03:14:19Z
[ "python", "html", "parsing", "beautifulsoup" ]
Parsing out data using BeautifulSoup in Python
1,501,690
<p>I am attempting to use BeautifulSoup to parse through a DOM tree and extract the names of authors. Below is a snippet of HTML to show the structure of the code I'm going to scrape. </p> <pre><code>&lt;html&gt; &lt;body&gt; &lt;div class="list-authors"&gt; &lt;span class="descriptor"&gt;Authors:&lt;/span&gt; &lt;a ...
9
2009-10-01T02:59:32Z
1,501,755
<p>just use findAll for the divs link you do for the links</p> <p>for authordiv in soup.findAll('div', attrs={'class': 'list-authors'}):</p>
12
2009-10-01T03:29:56Z
[ "python", "html", "parsing", "beautifulsoup" ]
Python regex question
1,501,772
<p>I am wondering what would be a pythonic solution for this question.</p> <p><a href="http://stackoverflow.com/questions/1483757/in-aa67bc54c9-is-there-any-way-to-print-aa-67-times-bc-54-times-and-so-on">http://stackoverflow.com/questions/1483757/in-aa67bc54c9-is-there-any-way-to-print-aa-67-times-bc-54-times-and-so-...
2
2009-10-01T03:37:11Z
1,501,815
<p>This would be a concise way:</p> <pre><code>import re s = "aa67bc54c9" print ''.join(t * int(n) for t, n in re.findall(r"([a-z]+)([0-9]+)", s)) </code></pre> <p>This solution uses a regular expression to match "one or more letters followed by one or more numbers", searching for all of them in the input string. Th...
3
2009-10-01T03:53:22Z
[ "python", "regex" ]
Python regex question
1,501,772
<p>I am wondering what would be a pythonic solution for this question.</p> <p><a href="http://stackoverflow.com/questions/1483757/in-aa67bc54c9-is-there-any-way-to-print-aa-67-times-bc-54-times-and-so-on">http://stackoverflow.com/questions/1483757/in-aa67bc54c9-is-there-any-way-to-print-aa-67-times-bc-54-times-and-so-...
2
2009-10-01T03:37:11Z
1,502,139
<p>Here is my Python solution.</p> <pre><code>import re pat = re.compile("^(\D+)(\d+)(.*)$") def rle_expand(s): lst = [] while True: m = pat.match(s) if m: n = int(m.group(2)) lst.append(m.group(1) * n) else: lst.append(s) break s...
3
2009-10-01T06:04:30Z
[ "python", "regex" ]
Run a task every hour on the hour with App Engine's cron API
1,501,907
<p>I need to run a task every hour on the hour (00:00, 01:00, 02:00, ..., 23:00) every day of the week, but can't seem to find an example in App Engine's docs of how to do this.</p> <p>There is an example of running at ask every hour, but this doesn't fit because the "start" of that hour depends on when you deploy the...
3
2009-10-01T04:36:27Z
1,501,925
<p>Looking over the docs, I agree that your 24 cron entry idea is the only documented way that would work. Not ideal, but should work.</p>
-1
2009-10-01T04:45:51Z
[ "python", "google-app-engine", "cron" ]
Run a task every hour on the hour with App Engine's cron API
1,501,907
<p>I need to run a task every hour on the hour (00:00, 01:00, 02:00, ..., 23:00) every day of the week, but can't seem to find an example in App Engine's docs of how to do this.</p> <p>There is an example of running at ask every hour, but this doesn't fit because the "start" of that hour depends on when you deploy the...
3
2009-10-01T04:36:27Z
1,501,960
<p>The docs say you can have 20 cron entries, so you can't have one for every hour of the day.</p> <p>You could run your task every minute and check if it is the first minute of the hour - exit otherwise.</p>
0
2009-10-01T04:56:24Z
[ "python", "google-app-engine", "cron" ]
Run a task every hour on the hour with App Engine's cron API
1,501,907
<p>I need to run a task every hour on the hour (00:00, 01:00, 02:00, ..., 23:00) every day of the week, but can't seem to find an example in App Engine's docs of how to do this.</p> <p>There is an example of running at ask every hour, but this doesn't fit because the "start" of that hour depends on when you deploy the...
3
2009-10-01T04:36:27Z
1,502,516
<p>Unfortunately, the cron syntax doesn't let you specify the time for intervals less than a day. What you can do, however, is use the <a href="http://code.google.com/appengine/docs/python/taskqueue/" rel="nofollow">Task Queue</a> for this. Either:</p> <ol> <li>Have a single task queue entry that, when it runs, enqueu...
3
2009-10-01T07:58:54Z
[ "python", "google-app-engine", "cron" ]
Run a task every hour on the hour with App Engine's cron API
1,501,907
<p>I need to run a task every hour on the hour (00:00, 01:00, 02:00, ..., 23:00) every day of the week, but can't seem to find an example in App Engine's docs of how to do this.</p> <p>There is an example of running at ask every hour, but this doesn't fit because the "start" of that hour depends on when you deploy the...
3
2009-10-01T04:36:27Z
7,402,852
<p>You could do this, and give up the exactly on the hour, but it will be close...</p> <p>(Example came from a app I was debuging)</p> <pre><code>cron: - description: Description of what you want done... url: /script/path/goes/here schedule: every 60 minutes synchronized timezone: America/New_York </code></pre>...
3
2011-09-13T13:40:38Z
[ "python", "google-app-engine", "cron" ]
Using CherryPy as a blocking/non-threading server for easier debugging
1,502,431
<p>Is it possible to use the CherrPy server as a blocking/non-threading server (for easier debugging?)</p>
0
2009-10-01T07:37:59Z
1,502,612
<p>No. Not only does the wsgiserver start its own set of worker threads (10 by default, but even if you only specified 1 that's still 1 thread for the listening socket and 1 worker thread). Even if that were not true, if you use the rest of CherryPy (i.e. the engine), it runs that 1 listener thread in a separate thread...
2
2009-10-01T08:24:58Z
[ "python", "debugging", "cherrypy" ]
How to pick certain elements of x-tuple returned by a function?
1,502,470
<p>I am a newbie to Python. Consider the function <code>str.partition()</code> which returns a 3-tuple. If I am interested in only elements 0 and 2 of this tuple, what is the best way to pick only certain elements out of such a tuple?</p> <p>I can currently do either:</p> <pre><code># Introduces "part1" variable, whi...
2
2009-10-01T07:47:46Z
1,502,486
<p>I think a question I asked some time ago could help you:</p> <p><a href="http://stackoverflow.com/questions/1105101/pythonic-way-to-get-some-rows-of-a-matrix">http://stackoverflow.com/questions/1105101/pythonic-way-to-get-some-rows-of-a-matrix</a></p> <p>NumPy gives you the slice syntax you want to extract various...
2
2009-10-01T07:52:31Z
[ "python", "list", "tuples", "iterable-unpacking" ]
How to pick certain elements of x-tuple returned by a function?
1,502,470
<p>I am a newbie to Python. Consider the function <code>str.partition()</code> which returns a 3-tuple. If I am interested in only elements 0 and 2 of this tuple, what is the best way to pick only certain elements out of such a tuple?</p> <p>I can currently do either:</p> <pre><code># Introduces "part1" variable, whi...
2
2009-10-01T07:47:46Z
1,502,487
<p>Correct, you can not take several ad hoc elements out of a list of tuple in one go.</p> <pre><code>part0, part1, part2 = str.partition(' ') </code></pre> <p>Is the way to go. Don't worry about part1, if you don't need it, you don't need it. It's common to call it "dummy" or "unused" to show that it's not used.</p>...
4
2009-10-01T07:52:34Z
[ "python", "list", "tuples", "iterable-unpacking" ]
How to pick certain elements of x-tuple returned by a function?
1,502,470
<p>I am a newbie to Python. Consider the function <code>str.partition()</code> which returns a 3-tuple. If I am interested in only elements 0 and 2 of this tuple, what is the best way to pick only certain elements out of such a tuple?</p> <p>I can currently do either:</p> <pre><code># Introduces "part1" variable, whi...
2
2009-10-01T07:47:46Z
1,502,488
<p>Underscore is often used as a name for stuff you do not need, so something like this would work:</p> <pre><code>part0, _, part2 = str.partition(' ') </code></pre> <p>In this particular case, you could do this, but it isn't a pretty solution:</p> <pre><code>part0, part2 = str.partition(' ')[::2] </code></pre> <p>...
13
2009-10-01T07:52:38Z
[ "python", "list", "tuples", "iterable-unpacking" ]
How to pick certain elements of x-tuple returned by a function?
1,502,470
<p>I am a newbie to Python. Consider the function <code>str.partition()</code> which returns a 3-tuple. If I am interested in only elements 0 and 2 of this tuple, what is the best way to pick only certain elements out of such a tuple?</p> <p>I can currently do either:</p> <pre><code># Introduces "part1" variable, whi...
2
2009-10-01T07:47:46Z
1,504,687
<p>you could also use <code>str.split(' ', 1)</code> instead of <code>str.partition(' ')</code></p> <p>you'll get back a list instead of a tuple, but you won't get the separator back</p>
1
2009-10-01T15:35:51Z
[ "python", "list", "tuples", "iterable-unpacking" ]
How to pick certain elements of x-tuple returned by a function?
1,502,470
<p>I am a newbie to Python. Consider the function <code>str.partition()</code> which returns a 3-tuple. If I am interested in only elements 0 and 2 of this tuple, what is the best way to pick only certain elements out of such a tuple?</p> <p>I can currently do either:</p> <pre><code># Introduces "part1" variable, whi...
2
2009-10-01T07:47:46Z
1,506,065
<p>This is how I would do it:</p> <pre><code>all_parts = str.partition(' ') part0, part2 = all_parts[0], all_parts[2] </code></pre>
0
2009-10-01T19:49:32Z
[ "python", "list", "tuples", "iterable-unpacking" ]
Paster cannot stop daemon
1,502,568
<p>I'm using the following command in my pylons app in an attempt to stop the daemon on the server:</p> <pre><code>paster serve --daemon dev.ini stop </code></pre> <p>This is the error I get:</p> <pre><code>No PID file exists in paster.pid Could not stop daemon; aborting </code></pre> <p>Wondering how I can stop th...
3
2009-10-01T08:14:41Z
1,502,706
<p>kill the process.</p>
0
2009-10-01T08:46:38Z
[ "python", "command-line", "ssh", "pylons", "paster" ]
Does keyczar python library provide functionality to verify signatures signed using x509 PEM certificates?
1,502,682
<p>I could not find a method to parse x509 pem files. I tried using ParseX509 of utils module which threw up. </p>
0
2009-10-01T08:41:57Z
30,472,624
<p>There is <a href="https://pypi.python.org/pypi/pycrypto" rel="nofollow"><code>pycrypto</code></a> with its <a href="http://pythonhosted.org/pycrypto/" rel="nofollow">old school docs</a>:</p> <blockquote> <p>This is a collection of both secure hash functions (such as SHA256 and RIPEMD160), and various encryption a...
0
2015-05-27T03:27:52Z
[ "python", "openssl", "keyczar" ]
basic unique ModelForm field for Google App Engine
1,502,818
<p>I do not care about concurrency issues.</p> <p>It is relatively easy to build unique form field:</p> <pre><code>from django import forms class UniqueUserEmailField(forms.CharField): def clean(self, value): self.check_uniqueness(super(UniqueUserEmailField, self).clean(value)) def check_uniqueness(se...
0
2009-10-01T09:06:20Z
1,503,024
<p>quick and dirty way would be:</p> <ol> <li>make check_uniqueness classmethod</li> <li><p>use custom field check in ModelForm, like this:</p> <pre><code>class User(forms.ModelForm): email = forms.EmailField() def clean_email(self): data = self.cleaned_data['email'] original = self.instance.email...
1
2009-10-01T10:00:58Z
[ "python", "django", "google-app-engine", "app-engine-patch" ]
How to check if permutations have equal parity?
1,503,072
<p>I am looking for a way to check if 2 <strong>permutations</strong> (represented by lists) are of the <strong>same <a href="http://en.wikipedia.org/wiki/Parity%5Fof%5Fa%5Fpermutation">parity</a></strong>. Note that I am not interested if they are <em>even</em> or <em>odd</em> parity, just the equality.</p> <p>I am n...
9
2009-10-01T10:11:59Z
1,503,075
<p>My naive solution:</p> <pre><code>def arePermsEqualParity(perm0, perm1): """Check if 2 permutations are of equal parity. Assume that both permutation lists are of equal length and have the same elements. No need to check for these conditions. """ transCount = 0 for loc in range(len(per...
4
2009-10-01T10:12:53Z
[ "python", "list", "permutation", "parity" ]
How to check if permutations have equal parity?
1,503,072
<p>I am looking for a way to check if 2 <strong>permutations</strong> (represented by lists) are of the <strong>same <a href="http://en.wikipedia.org/wiki/Parity%5Fof%5Fa%5Fpermutation">parity</a></strong>. Note that I am not interested if they are <em>even</em> or <em>odd</em> parity, just the equality.</p> <p>I am n...
9
2009-10-01T10:11:59Z
1,503,144
<p>A minor variant of the previous answer - copy perm1, and save array lookups.</p> <pre><code>def arePermsEqualParity(perm0, perm1): """Check if 2 permutations are of equal parity. Assume that both permutation lists are of equal length and have the same elements. No need to check for these conditions...
4
2009-10-01T10:26:33Z
[ "python", "list", "permutation", "parity" ]
How to check if permutations have equal parity?
1,503,072
<p>I am looking for a way to check if 2 <strong>permutations</strong> (represented by lists) are of the <strong>same <a href="http://en.wikipedia.org/wiki/Parity%5Fof%5Fa%5Fpermutation">parity</a></strong>. Note that I am not interested if they are <em>even</em> or <em>odd</em> parity, just the equality.</p> <p>I am n...
9
2009-10-01T10:11:59Z
1,503,487
<p>My intuition tells me that, just counting the differences between the two permutations will give you one more than the number of swaps need to get from one to the other. This in turn will give you the parity.</p> <p>This means that you don't need to do the swaps in your code at all.</p> <p>For example:</p> <pre>...
0
2009-10-01T11:46:40Z
[ "python", "list", "permutation", "parity" ]
How to check if permutations have equal parity?
1,503,072
<p>I am looking for a way to check if 2 <strong>permutations</strong> (represented by lists) are of the <strong>same <a href="http://en.wikipedia.org/wiki/Parity%5Fof%5Fa%5Fpermutation">parity</a></strong>. Note that I am not interested if they are <em>even</em> or <em>odd</em> parity, just the equality.</p> <p>I am n...
9
2009-10-01T10:11:59Z
1,503,598
<p>Here is my tweak of your code</p> <ul> <li>Use list() to copy perm1 - this means you can pass tuples, etc into the function, making it more generic</li> <li>Use enumerate() in the for loop instead of len(..) and array lookups for neater code</li> <li>Make a perm1_map and keep it up to date to stop an expensive O(N)...
6
2009-10-01T12:14:01Z
[ "python", "list", "permutation", "parity" ]
How to check if permutations have equal parity?
1,503,072
<p>I am looking for a way to check if 2 <strong>permutations</strong> (represented by lists) are of the <strong>same <a href="http://en.wikipedia.org/wiki/Parity%5Fof%5Fa%5Fpermutation">parity</a></strong>. Note that I am not interested if they are <em>even</em> or <em>odd</em> parity, just the equality.</p> <p>I am n...
9
2009-10-01T10:11:59Z
1,504,565
<p>If we combine both permutations, the result will have even parity when each permutation has the same parity, and odd parity if they have different parity. So if we solve the <strong>parity problem</strong> it's trivial to compare two different permutations.</p> <p><strong>Parity</strong> can be determined as follow...
6
2009-10-01T15:15:13Z
[ "python", "list", "permutation", "parity" ]
How to check if permutations have equal parity?
1,503,072
<p>I am looking for a way to check if 2 <strong>permutations</strong> (represented by lists) are of the <strong>same <a href="http://en.wikipedia.org/wiki/Parity%5Fof%5Fa%5Fpermutation">parity</a></strong>. Note that I am not interested if they are <em>even</em> or <em>odd</em> parity, just the equality.</p> <p>I am n...
9
2009-10-01T10:11:59Z
1,512,146
<p>Here's slightly refactored <a href="http://stackoverflow.com/questions/1503072/how-to-check-if-permutations-have-equal-parity/1504565#1504565">Weeble's answer</a>:</p> <pre><code>def arePermsEqualParity(perm0, perm1): """Whether permutations are of equal parity.""" return parity(combine(perm0, perm1)) def ...
2
2009-10-02T22:41:14Z
[ "python", "list", "permutation", "parity" ]
How to check if permutations have equal parity?
1,503,072
<p>I am looking for a way to check if 2 <strong>permutations</strong> (represented by lists) are of the <strong>same <a href="http://en.wikipedia.org/wiki/Parity%5Fof%5Fa%5Fpermutation">parity</a></strong>. Note that I am not interested if they are <em>even</em> or <em>odd</em> parity, just the equality.</p> <p>I am n...
9
2009-10-01T10:11:59Z
4,215,652
<p>The solution with the dictionary is bugged. This is the debug version:</p> <pre><code>def arePermsEqualParity(perm0, perm1): """Check if 2 permutations are of equal parity. Assume that both permutation lists are of equal length and have the same elements. No need to check for these conditions. ...
2
2010-11-18T14:13:08Z
[ "python", "list", "permutation", "parity" ]
How to check if permutations have equal parity?
1,503,072
<p>I am looking for a way to check if 2 <strong>permutations</strong> (represented by lists) are of the <strong>same <a href="http://en.wikipedia.org/wiki/Parity%5Fof%5Fa%5Fpermutation">parity</a></strong>. Note that I am not interested if they are <em>even</em> or <em>odd</em> parity, just the equality.</p> <p>I am n...
9
2009-10-01T10:11:59Z
6,271,461
<pre><code>def equalparity(p,q): return sum([p[q[i]] &gt; p[q[j]] for i in range(len(p)) for j in range(i)]) % 2 == 0 </code></pre>
0
2011-06-07T20:49:32Z
[ "python", "list", "permutation", "parity" ]
Dynamic column formatting in SQL - and a backend to store the formatting
1,503,621
<p>I'm trying to create a system in Python in which one can select a number of rows from a set of tables, which are to be formatted in a user-defined way. Let's say the table <code>a</code> has a set of columns, some of which include a <code>date</code> or <code>timestamp</code> value. The user-defined format for each ...
1
2009-10-01T12:16:58Z
1,504,004
<p>It seems to me a <a href="http://www.google.com/search?q=postgresql+stored+procedures" rel="nofollow">stored procedure</a> or a sub-select would work well here, though I haven't tested it. Let's say you store a <code>date_format</code> for each user in the <code>users</code> table.</p> <pre><code>SELECT to_char((SE...
0
2009-10-01T13:34:32Z
[ "python", "sql", "database", "database-design", "postgresql" ]
Dynamic column formatting in SQL - and a backend to store the formatting
1,503,621
<p>I'm trying to create a system in Python in which one can select a number of rows from a set of tables, which are to be formatted in a user-defined way. Let's say the table <code>a</code> has a set of columns, some of which include a <code>date</code> or <code>timestamp</code> value. The user-defined format for each ...
1
2009-10-01T12:16:58Z
1,504,076
<p>Pull the dates out as Unix timestamps and format them in Python:</p> <pre><code>SELECT DATE_PART('epoch', TIMESTAMP(my_col)) FROM my_table; my_date = datetime.datetime.fromtimestamp(row[0]) # Or equivalent for your toolkit </code></pre> <p>I've found a couple of advantages to this approach: unix timestamps are th...
0
2009-10-01T13:48:26Z
[ "python", "sql", "database", "database-design", "postgresql" ]
Fixture loading works with loaddata but fails silently in unit test in Django
1,504,255
<p>I can load the fixture file in my django application by using loaddata:</p> <pre><code>manage.py loaddata palamut </code></pre> <p>The fixture <code>palamut.yaml</code> is in the directory <code>palamut/fixtures/</code> </p> <p>I have a unit test module <code>service_tests.py</code> in <code>palamut/tests/</code>...
4
2009-10-01T14:21:21Z
1,504,290
<p>Your TestCase should be an instance of django.test.TestCase, not unittest.TestCase</p>
9
2009-10-01T14:26:14Z
[ "python", "django", "unit-testing", "fixtures" ]
Fitting a bimodal distribution to a set of values
1,504,378
<p>Given a 1D array of values, what is the simplest way to figure out what the best fit bimodal distribution to it is, where each 'mode' is a normal distribution? Or in other words, how can you find the combination of two normal distributions that bests reproduces the 1D array of values?</p> <p>Specifically, I'm inter...
6
2009-10-01T14:43:09Z
1,504,481
<p>I suggest using the awesome <a href="http://www.scipy.org/" rel="nofollow">scipy</a> package. It provides a few methods for optimisation.</p> <p>There's a big fat caveat with simply applying a pre-defined least square fit or something along those lines. </p> <p>Here are a few problems you will run into:</p> <ol> ...
0
2009-10-01T15:01:33Z
[ "python", "algorithm" ]
Fitting a bimodal distribution to a set of values
1,504,378
<p>Given a 1D array of values, what is the simplest way to figure out what the best fit bimodal distribution to it is, where each 'mode' is a normal distribution? Or in other words, how can you find the combination of two normal distributions that bests reproduces the 1D array of values?</p> <p>Specifically, I'm inter...
6
2009-10-01T14:43:09Z
1,504,590
<p>What you are trying to do is called a Gaussian Mixture model. The standard approach to solving this is using Expectation Maximization, scipy svn includes a section on machine learning and em called <a href="http://scipy.org/scikits.html" rel="nofollow">scikits</a>. I use it a a fair bit.</p>
4
2009-10-01T15:20:00Z
[ "python", "algorithm" ]
Fitting a bimodal distribution to a set of values
1,504,378
<p>Given a 1D array of values, what is the simplest way to figure out what the best fit bimodal distribution to it is, where each 'mode' is a normal distribution? Or in other words, how can you find the combination of two normal distributions that bests reproduces the 1D array of values?</p> <p>Specifically, I'm inter...
6
2009-10-01T14:43:09Z
4,597,393
<p>I am just trying to understand why one needs to fit a bimodal distributing for a 1D array? What are the advantages of doing this?</p>
0
2011-01-04T19:11:06Z
[ "python", "algorithm" ]
Why does comparing strings in Python using either '==' or 'is' sometimes produce a different result?
1,504,717
<p>I've got a Python program where two variables are set to the value <code>'public'</code>. In a conditional expression I have the comparison <code>var1 is var2</code> which fails, but if I change it to <code>var1 == var2</code> it returns <code>True</code>.</p> <p>Now if I open my Python interpreter and do the same ...
593
2009-10-01T15:40:14Z
1,504,739
<p>The <code>is</code> keyword is a test for object identity while <code>==</code> is a value comparison.</p> <p>If you use <code>is</code>, the result will be true if and only if the object is the same object. However, <code>==</code> will be true any time the values of the object are the same.</p>
77
2009-10-01T15:45:02Z
[ "python", "string", "comparison" ]
Why does comparing strings in Python using either '==' or 'is' sometimes produce a different result?
1,504,717
<p>I've got a Python program where two variables are set to the value <code>'public'</code>. In a conditional expression I have the comparison <code>var1 is var2</code> which fails, but if I change it to <code>var1 == var2</code> it returns <code>True</code>.</p> <p>Now if I open my Python interpreter and do the same ...
593
2009-10-01T15:40:14Z
1,504,740
<p>I think it has to do with the fact that, when the 'is' comparison evaluates to false, two distinct objects are used. If it evaluates to true, that means internally it's using the same exact object and not creating a new one, possibly because you created them within a fraction of 2 or so seconds and because there isn...
9
2009-10-01T15:45:07Z
[ "python", "string", "comparison" ]
Why does comparing strings in Python using either '==' or 'is' sometimes produce a different result?
1,504,717
<p>I've got a Python program where two variables are set to the value <code>'public'</code>. In a conditional expression I have the comparison <code>var1 is var2</code> which fails, but if I change it to <code>var1 == var2</code> it returns <code>True</code>.</p> <p>Now if I open my Python interpreter and do the same ...
593
2009-10-01T15:40:14Z
1,504,742
<p><code>is</code> is identity testing, <code>==</code> is equality testing. what happens in your code would be emulated in the interpreter like this:</p> <pre><code>&gt;&gt;&gt; a = 'pub' &gt;&gt;&gt; b = ''.join(['p', 'u', 'b']) &gt;&gt;&gt; a == b True &gt;&gt;&gt; a is b False </code></pre> <p>so, no wonder they'...
857
2009-10-01T15:45:20Z
[ "python", "string", "comparison" ]
Why does comparing strings in Python using either '==' or 'is' sometimes produce a different result?
1,504,717
<p>I've got a Python program where two variables are set to the value <code>'public'</code>. In a conditional expression I have the comparison <code>var1 is var2</code> which fails, but if I change it to <code>var1 == var2</code> it returns <code>True</code>.</p> <p>Now if I open my Python interpreter and do the same ...
593
2009-10-01T15:40:14Z
1,504,756
<p>From my limited experience with python, <code>is</code> is used to compare two objects to see if they are the same object as opposed to two different objects with the same value. <code>==</code> is used to determine if the values are identical. </p> <p>Here is a good example:</p> <pre><code>&gt;&gt;&gt; s1 = u'pu...
13
2009-10-01T15:48:07Z
[ "python", "string", "comparison" ]
Why does comparing strings in Python using either '==' or 'is' sometimes produce a different result?
1,504,717
<p>I've got a Python program where two variables are set to the value <code>'public'</code>. In a conditional expression I have the comparison <code>var1 is var2</code> which fails, but if I change it to <code>var1 == var2</code> it returns <code>True</code>.</p> <p>Now if I open my Python interpreter and do the same ...
593
2009-10-01T15:40:14Z
1,504,829
<p>I believe that this is known as "interned" strings. Python does this, so does Java, and so do C and C++ when compiling in optimized modes.</p> <p>If you use two identical strings, instead of wasting memory by creating two string objects, all interned strings with the same contents point to the same memory.</p> <p>...
7
2009-10-01T15:59:38Z
[ "python", "string", "comparison" ]
Why does comparing strings in Python using either '==' or 'is' sometimes produce a different result?
1,504,717
<p>I've got a Python program where two variables are set to the value <code>'public'</code>. In a conditional expression I have the comparison <code>var1 is var2</code> which fails, but if I change it to <code>var1 == var2</code> it returns <code>True</code>.</p> <p>Now if I open my Python interpreter and do the same ...
593
2009-10-01T15:40:14Z
1,504,848
<p>SilentGhost and others are correct here. <code>is</code> is used for <em>identity</em> comparison, while <code>==</code> is used for <em>equality</em> comparison.</p> <p>The reason this works interactively is that (most) string literals are <a href="http://en.wikipedia.org/wiki/String_interning">interned</a> by de...
285
2009-10-01T16:02:14Z
[ "python", "string", "comparison" ]
Why does comparing strings in Python using either '==' or 'is' sometimes produce a different result?
1,504,717
<p>I've got a Python program where two variables are set to the value <code>'public'</code>. In a conditional expression I have the comparison <code>var1 is var2</code> which fails, but if I change it to <code>var1 == var2</code> it returns <code>True</code>.</p> <p>Now if I open my Python interpreter and do the same ...
593
2009-10-01T15:40:14Z
1,504,870
<p>One last thing to note, you may use the intern function to ensure that you're getting a reference to the same string:</p> <pre><code>&gt;&gt;&gt; a = intern('a') &gt;&gt;&gt; a2 = intern('a') &gt;&gt;&gt; a is a2 True </code></pre> <p>As pointed out above, you should probably not be doing is to determine equality ...
34
2009-10-01T16:04:48Z
[ "python", "string", "comparison" ]
Why does comparing strings in Python using either '==' or 'is' sometimes produce a different result?
1,504,717
<p>I've got a Python program where two variables are set to the value <code>'public'</code>. In a conditional expression I have the comparison <code>var1 is var2</code> which fails, but if I change it to <code>var1 == var2</code> it returns <code>True</code>.</p> <p>Now if I open my Python interpreter and do the same ...
593
2009-10-01T15:40:14Z
1,505,189
<p>If you're not sure what you're doing, use the '=='. If you have a little more knowledge about it you can use 'is' for known objects like 'None'.</p> <p>Otherwise you'll end up wondering why things doesn't work and why this happens:</p> <pre><code>&gt;&gt;&gt; a = 1 &gt;&gt;&gt; b = 1 &gt;&gt;&gt; b is a True &gt;&...
17
2009-10-01T16:57:09Z
[ "python", "string", "comparison" ]
Why does comparing strings in Python using either '==' or 'is' sometimes produce a different result?
1,504,717
<p>I've got a Python program where two variables are set to the value <code>'public'</code>. In a conditional expression I have the comparison <code>var1 is var2</code> which fails, but if I change it to <code>var1 == var2</code> it returns <code>True</code>.</p> <p>Now if I open my Python interpreter and do the same ...
593
2009-10-01T15:40:14Z
1,505,779
<p>This is a side note, but in idiomatic python, you will often see things like:</p> <pre><code>if x is None: # some clauses </code></pre> <p>This is safe, because <a href="http://docs.python.org/library/stdtypes.html#the-null-object">there is guaranteed to be one instance of the Null Object (i.e., None)</a>.</p...
18
2009-10-01T18:51:32Z
[ "python", "string", "comparison" ]
Why does comparing strings in Python using either '==' or 'is' sometimes produce a different result?
1,504,717
<p>I've got a Python program where two variables are set to the value <code>'public'</code>. In a conditional expression I have the comparison <code>var1 is var2</code> which fails, but if I change it to <code>var1 == var2</code> it returns <code>True</code>.</p> <p>Now if I open my Python interpreter and do the same ...
593
2009-10-01T15:40:14Z
16,269,793
<p><code>is</code> is identity testing, <code>==</code> is equality testing. What this means is that <code>is</code> is a way to check whether two things are the <em>same</em> things, or just equivalent. </p> <p>Say you've got a simple <code>person</code> object. If it is named 'Jack' and is '23' years old, it's equiv...
18
2013-04-29T00:56:52Z
[ "python", "string", "comparison" ]
Why does comparing strings in Python using either '==' or 'is' sometimes produce a different result?
1,504,717
<p>I've got a Python program where two variables are set to the value <code>'public'</code>. In a conditional expression I have the comparison <code>var1 is var2</code> which fails, but if I change it to <code>var1 == var2</code> it returns <code>True</code>.</p> <p>Now if I open my Python interpreter and do the same ...
593
2009-10-01T15:40:14Z
25,208,597
<p>I am answering the question even though the question is to old because no answers above quotes the language reference</p> <p>Actually the is operator checks for identity and == operator checks for equality,</p> <p><strong><em>From Language Reference:</em></strong></p> <p>Types affect almost all aspects of object ...
7
2014-08-08T17:04:58Z
[ "python", "string", "comparison" ]
Automatically remove *.pyc files and otherwise-empty directories when I check out a new branch
1,504,724
<p>So here's an interesting situation when using git and python, and I'm sure it happens for other situations as well.</p> <p>Let's say I make a git repo with a folder /foo/. In that folder I put /foo/program.py. I run program.py and program.pyc is created. I have *.pyc in the .gitignore file, so git doesn't track it....
48
2009-10-01T15:41:22Z
1,504,760
<p>There is a <code>post-checkout</code> hook, to be placed in .git/hooks/post-checkout. There's probably a sample there, possibly named .sample or possibly not executable, depending on your git version. Short description: it gets three parameters, the previous HEAD, the new HEAD, and a flag which is 1 if the branch ch...
40
2009-10-01T15:48:41Z
[ "git", "python", "bash" ]
Automatically remove *.pyc files and otherwise-empty directories when I check out a new branch
1,504,724
<p>So here's an interesting situation when using git and python, and I'm sure it happens for other situations as well.</p> <p>Let's say I make a git repo with a folder /foo/. In that folder I put /foo/program.py. I run program.py and program.pyc is created. I have *.pyc in the .gitignore file, so git doesn't track it....
48
2009-10-01T15:41:22Z
1,810,193
<p>Just copying and updating a good solution by Apreche that was buried in the comments:</p> <p>Save this shell script to the file <code>/path/to/repo/.git/hooks/post-checkout</code>, and make it executable.</p> <pre><code>#! /bin/sh # Start from the repository root. cd ./$(git rev-parse --show-cdup) # Delete .pyc ...
33
2009-11-27T18:46:39Z
[ "git", "python", "bash" ]
Automatically remove *.pyc files and otherwise-empty directories when I check out a new branch
1,504,724
<p>So here's an interesting situation when using git and python, and I'm sure it happens for other situations as well.</p> <p>Let's say I make a git repo with a folder /foo/. In that folder I put /foo/program.py. I run program.py and program.pyc is created. I have *.pyc in the .gitignore file, so git doesn't track it....
48
2009-10-01T15:41:22Z
26,320,535
<p>My solution is <strong>more compatible with git</strong>: Git removes only enpty directories where any file has been deleted by checkout. It doesn't search the complete workcopy tree. That is useful for big repositories or repositories with a very big ignored tree, like virtual environments by <a href="https://testr...
2
2014-10-12T00:09:39Z
[ "git", "python", "bash" ]
Automatically remove *.pyc files and otherwise-empty directories when I check out a new branch
1,504,724
<p>So here's an interesting situation when using git and python, and I'm sure it happens for other situations as well.</p> <p>Let's say I make a git repo with a folder /foo/. In that folder I put /foo/program.py. I run program.py and program.pyc is created. I have *.pyc in the .gitignore file, so git doesn't track it....
48
2009-10-01T15:41:22Z
26,325,326
<p>Another option is to not solve this as a git problem at all, but as a Python problem. You can use the <code>PYTHONDONTWRITEBYTECODE</code> environment variable to prevent Python from writing .pyc files in the first place. Then you won't have anything to clean up when you switch branches.</p>
3
2014-10-12T12:54:09Z
[ "git", "python", "bash" ]
Communicate with backend job from web server or web page
1,504,729
<p>I have an "appliance" (for lack of better description) running linux.</p> <p>Currently I ssh into the box to launch jobs. This isn't friendly enough for my users, so I'm putting together a simple web UI to launch the script. A job runs for anywhere from 10 seconds to several hours. The web UI needs to reflect the s...
0
2009-10-01T15:42:48Z
1,504,839
<p>I'm not sure if I understood your problem correctly, but I assume you have multiple "jobs" that can run simultaneously and want them to show on web page whether they are complete or not?</p> <p>When launching a job the web page (python &amp; mod_wsgi for example) would launch a python script that would enter the jo...
0
2009-10-01T16:00:52Z
[ "python", "linux", "backend" ]
Communicate with backend job from web server or web page
1,504,729
<p>I have an "appliance" (for lack of better description) running linux.</p> <p>Currently I ssh into the box to launch jobs. This isn't friendly enough for my users, so I'm putting together a simple web UI to launch the script. A job runs for anywhere from 10 seconds to several hours. The web UI needs to reflect the s...
0
2009-10-01T15:42:48Z
1,504,890
<p>I do this in a number of projects. A web-app (mostly Python/CGI) that spawns a separate python script (using subprocess) which instantly <a href="http://pypi.python.org/pypi/python-daemon/1.5" rel="nofollow">daemonizes itself</a> to do the work. The web-app then continues to issue AJAX requests to check on the daem...
2
2009-10-01T16:07:06Z
[ "python", "linux", "backend" ]
Python as a Windows Watchdog
1,504,794
<p>Hi I'm considering using Python to make a watchdog app on Windows XP that will perform the following actions:</p> <ul> <li>Restart Windows at a given time.</li> <li>Start an exe application.</li> <li>Run a timer to check: is an application still running</li> </ul> <p>I know of the existence of PyWin32, but I hear ...
2
2009-10-01T15:54:13Z
1,504,889
<p>Since you only want this to work on Windows, the easiest way to do that is to use <a href="http://docs.python.org/library/os.html" rel="nofollow">os.system</a> and make system-specific calls from within a Python program. </p> <p>Use the built in Windows tool to run programs at a particular time.</p> <p>Use shutdow...
2
2009-10-01T16:07:03Z
[ "python", "winapi" ]
Visual representation of nodes in Python
1,505,131
<p>I have data that I want to represent visually. The actual data is a tree made up of nodes. Each node has a bunch of data associated with it, but as far as this question goes, I just want a way to represent a tree visually using Python. Any ideas?</p> <p>The different solutions that popped in my head were to use a G...
1
2009-10-01T16:48:05Z
1,505,155
<p>Not sure if this is applicable to your situation, but have you looked at <a href="http://www.graphviz.org/" rel="nofollow">graphviz</a>? It has decent python bindings for it and I've used it for visualizing dependencies which sometimes end up looking like trees.</p>
5
2009-10-01T16:52:52Z
[ "python" ]
Visual representation of nodes in Python
1,505,131
<p>I have data that I want to represent visually. The actual data is a tree made up of nodes. Each node has a bunch of data associated with it, but as far as this question goes, I just want a way to represent a tree visually using Python. Any ideas?</p> <p>The different solutions that popped in my head were to use a G...
1
2009-10-01T16:48:05Z
1,505,330
<p>Consider using a textual representation of the tree. Otherwise, I'd go with graphviz (dotty, actually).</p> <pre><code>[root] +------child1 +------child2 +-------child3 +-------child4 </code></pre> <p>To show the same tree in graphviz, put this in a text file:</p> <pre><code>digraph graphname { root -...
0
2009-10-01T17:31:43Z
[ "python" ]
Visual representation of nodes in Python
1,505,131
<p>I have data that I want to represent visually. The actual data is a tree made up of nodes. Each node has a bunch of data associated with it, but as far as this question goes, I just want a way to represent a tree visually using Python. Any ideas?</p> <p>The different solutions that popped in my head were to use a G...
1
2009-10-01T16:48:05Z
1,505,746
<p>Instead of using graphviz directly, consider using the visualization tools included in <a href="http://networkx.lanl.gov/" rel="nofollow">NetworkX</a>. The graph objects there are excellent for many purposes.</p>
2
2009-10-01T18:45:42Z
[ "python" ]
Python: json.loads chokes on escapes
1,505,454
<p>I have an application that is sending a JSON object (formatted with Prototype) to an ASP server. On the server, the Python 2.6 "json" module tries to loads() the JSON, but it's choking on some combination of backslashes. Observe:</p> <pre><code>&gt;&gt;&gt; s '{"FileExists": true, "Version": "4.3.2.1", "Path": "\...
11
2009-10-01T17:53:17Z
1,505,477
<p>The correct json is:</p> <pre><code>r'{"FileExists": true, "Version": "4.3.2.1", "Path": "\\\\host\\dir\\file.exe"}' </code></pre> <p>Note the letter <code>r</code> if you omit it you need to escape <code>\</code> for Python too.</p> <pre><code>&gt;&gt;&gt; import json &gt;&gt;&gt; d = json.loads(s) &gt;&gt;&gt; ...
16
2009-10-01T17:58:41Z
[ "python", "json", "escaping" ]
Python: json.loads chokes on escapes
1,505,454
<p>I have an application that is sending a JSON object (formatted with Prototype) to an ASP server. On the server, the Python 2.6 "json" module tries to loads() the JSON, but it's choking on some combination of backslashes. Observe:</p> <pre><code>&gt;&gt;&gt; s '{"FileExists": true, "Version": "4.3.2.1", "Path": "\...
11
2009-10-01T17:53:17Z
1,505,593
<pre><code>&gt;&gt;&gt; s '{"FileExists": true, "Version": "4.3.2.1", "Path": "\\\\host\\dir\\file.exe"}' &gt;&gt;&gt; print s {"FileExists": true, "Version": "4.3.2.1", "Path": "\\host\dir\file.exe"} </code></pre> <p>You've not actually escaped the string, so it's trying to parse invalid escape codes like <code>\d</c...
1
2009-10-01T18:19:26Z
[ "python", "json", "escaping" ]
Python: json.loads chokes on escapes
1,505,454
<p>I have an application that is sending a JSON object (formatted with Prototype) to an ASP server. On the server, the Python 2.6 "json" module tries to loads() the JSON, but it's choking on some combination of backslashes. Observe:</p> <pre><code>&gt;&gt;&gt; s '{"FileExists": true, "Version": "4.3.2.1", "Path": "\...
11
2009-10-01T17:53:17Z
37,805,536
<p>Since the exception gives you the index of the offending escape character, this little hack I developed might be nice :)</p> <pre><code>def fix_JSON(json_message=None): result = None try: result = json.loads(json_message) except Exception as e: # Find the offending characte...
1
2016-06-14T07:25:18Z
[ "python", "json", "escaping" ]
PHP Import Foreign Class' Method into MyClass
1,505,621
<p>Wondering if this is possible in PHP Land:</p> <p>Let's say I have a class as follows:</p> <pre><code>class myClass{ var $myVar; ... myMethod(){ $this-&gt;myVar = 10; } } </code></pre> <p>and another class:</p> <pre><code>class anotherClass { ... addFive(){ $this-&gt;myVar += 5; }...
0
2009-10-01T18:24:25Z
1,505,645
<p>If your myClass <a href="http://uk.php.net/manual/en/language.oop5.inheritance.php" rel="nofollow">extends</a> anotherClass it inherits all the methods and properties of anotherClass (except those marked private).</p> <pre><code>class AnotherClass { protected $myVar; public function addFive(){ $this-&gt;myV...
0
2009-10-01T18:29:38Z
[ "php", "python", "oop", "closures", "anonymous-methods" ]
PHP Import Foreign Class' Method into MyClass
1,505,621
<p>Wondering if this is possible in PHP Land:</p> <p>Let's say I have a class as follows:</p> <pre><code>class myClass{ var $myVar; ... myMethod(){ $this-&gt;myVar = 10; } } </code></pre> <p>and another class:</p> <pre><code>class anotherClass { ... addFive(){ $this-&gt;myVar += 5; }...
0
2009-10-01T18:24:25Z
1,505,668
<p>A better approach would be to move the complex method into its own class. Then both of your classes can instantiate it, pass any necessary data, and call the method.</p>
2
2009-10-01T18:33:06Z
[ "php", "python", "oop", "closures", "anonymous-methods" ]
PHP Import Foreign Class' Method into MyClass
1,505,621
<p>Wondering if this is possible in PHP Land:</p> <p>Let's say I have a class as follows:</p> <pre><code>class myClass{ var $myVar; ... myMethod(){ $this-&gt;myVar = 10; } } </code></pre> <p>and another class:</p> <pre><code>class anotherClass { ... addFive(){ $this-&gt;myVar += 5; }...
0
2009-10-01T18:24:25Z
1,505,727
<p>The easiest way to do this is have one class extend the other</p> <pre><code>class myClass extends anotherClass { } </code></pre> <p>The myClass class now has access to all the methods of anotherClass that are public or protected.</p> <p>If you only want the class to have <strong>one</strong> method of the other,...
2
2009-10-01T18:41:57Z
[ "php", "python", "oop", "closures", "anonymous-methods" ]
Network programming abstraction, decomposition
1,505,744
<p>I have a problem as follows:</p> <p>Server process 1</p> <ul> <li>Constantly sends updates that occur to a datastore</li> </ul> <p>Server process 2</p> <ul> <li>Clients contact the server, which queries the datastore, and returns a result</li> </ul> <p>The thing is, the results that process 1 and process 2 are ...
0
2009-10-01T18:45:27Z
1,506,213
<p>Why not use a database instead of "just a structure"? Both relational and non-relational DBs offer many practical advantages (separate processes using them, take care of replication [[and/or snapshots, backups, ...]], rich functionality if you need it for the "queries", and so on, and so forth).</p> <p>Worst case,...
0
2009-10-01T20:16:28Z
[ "python", "networking", "network-programming", "twisted" ]
Network programming abstraction, decomposition
1,505,744
<p>I have a problem as follows:</p> <p>Server process 1</p> <ul> <li>Constantly sends updates that occur to a datastore</li> </ul> <p>Server process 2</p> <ul> <li>Clients contact the server, which queries the datastore, and returns a result</li> </ul> <p>The thing is, the results that process 1 and process 2 are ...
0
2009-10-01T18:45:27Z
1,506,347
<p>If you can restrict yourself to Twisted, I recommend to use <a href="http://twistedmatrix.com/projects/core/documentation/howto/pb-intro.html" rel="nofollow">Perspective Broker</a>. It's essentially an RPC system, and doesn't care much about the notion of "client" and "server" - either the initiator of a TCP connect...
1
2009-10-01T20:41:30Z
[ "python", "networking", "network-programming", "twisted" ]
Network programming abstraction, decomposition
1,505,744
<p>I have a problem as follows:</p> <p>Server process 1</p> <ul> <li>Constantly sends updates that occur to a datastore</li> </ul> <p>Server process 2</p> <ul> <li>Clients contact the server, which queries the datastore, and returns a result</li> </ul> <p>The thing is, the results that process 1 and process 2 are ...
0
2009-10-01T18:45:27Z
1,507,023
<p>It sounds like you want to stream your series of ints "somewhere" and also collect them in a datastore. In my system I am streaming sensor readings into a database and also allowing them to go directly to web clients, giving them live power readings. I've written a blog entry on why a <a href="http://blog.gridspy.co...
1
2009-10-01T23:28:36Z
[ "python", "networking", "network-programming", "twisted" ]
Making a portable (exe) with Python 3.1?
1,505,783
<p>Is there a way to make a portable/stand-alone exe for python apps? </p> <p>I've read about p2exe but it doesn't support the latest version. I'm reluctant to go to 2.6 because I'd rather stay with the latest version instead of worrying about incompatibilities as soon as 2.6 becomes too outdated.</p>
7
2009-10-01T18:52:02Z
1,505,819
<p>cx_freeze has worked for me. Here's a link. The page claims to support 3.1. Good luck!</p> <p><a href="http://cx-freeze.sourceforge.net/">http://cx-freeze.sourceforge.net/</a></p>
13
2009-10-01T19:00:18Z
[ "python", "py2exe" ]
blackle.com queries
1,505,958
<p>I'm trying to query blackle.com for searches, but I get an 403 HTTP error. Can somebody point out what is wrong here?</p> <pre><code>#!/usr/bin/env python import urllib2 ss = raw_input('Please enter search string: ') response = "http://www.google.com/cse?cx=013269018370076798483:gg7jrrhpsy4&amp;cof=FORID:1&amp;q="...
0
2009-10-01T19:26:21Z
1,506,257
<p>HTTP 403 means "forbidden" (see <a href="http://www.checkupdown.com/status/E403.html" rel="nofollow">here</a> for a good explanation): google.com doesn't want to let you access that resource. Since it does let <em>browsers</em> access it, presumably it's identifying you as a robot (automated code, not interactive us...
2
2009-10-01T20:26:06Z
[ "python", "search" ]
How to use export with Python on Linux
1,506,010
<p>I need to make an export like this in Python :</p> <pre><code># export MY_DATA="my_export" </code></pre> <p>I've tried to do :</p> <pre><code># -*- python-mode -*- # -*- coding: utf-8 -*- import os os.system('export MY_DATA="my_export"') </code></pre> <p>But when I list export, "MY_DATA" not appear :</p> <pre><...
26
2009-10-01T19:39:35Z
1,506,022
<p>You could try os.environ["MY_DATA"] instead.</p>
2
2009-10-01T19:41:35Z
[ "python", "linux", "export" ]
How to use export with Python on Linux
1,506,010
<p>I need to make an export like this in Python :</p> <pre><code># export MY_DATA="my_export" </code></pre> <p>I've tried to do :</p> <pre><code># -*- python-mode -*- # -*- coding: utf-8 -*- import os os.system('export MY_DATA="my_export"') </code></pre> <p>But when I list export, "MY_DATA" not appear :</p> <pre><...
26
2009-10-01T19:39:35Z
1,506,046
<p>You actually want to do</p> <pre><code>import os os.environ["MY_DATA"] = "my_export" </code></pre>
38
2009-10-01T19:46:21Z
[ "python", "linux", "export" ]
How to use export with Python on Linux
1,506,010
<p>I need to make an export like this in Python :</p> <pre><code># export MY_DATA="my_export" </code></pre> <p>I've tried to do :</p> <pre><code># -*- python-mode -*- # -*- coding: utf-8 -*- import os os.system('export MY_DATA="my_export"') </code></pre> <p>But when I list export, "MY_DATA" not appear :</p> <pre><...
26
2009-10-01T19:39:35Z
1,506,108
<p>Not that simple:</p> <pre><code>python -c "import os; os.putenv('MY_DATA','1233')" $ echo $MY_DATA # &lt;- empty </code></pre> <p>But:</p> <pre><code>python -c "import os; os.putenv('MY_DATA','123'); os.system('bash')" $ echo $MY_DATA #&lt;- 123 </code></pre>
7
2009-10-01T19:58:30Z
[ "python", "linux", "export" ]
How to use export with Python on Linux
1,506,010
<p>I need to make an export like this in Python :</p> <pre><code># export MY_DATA="my_export" </code></pre> <p>I've tried to do :</p> <pre><code># -*- python-mode -*- # -*- coding: utf-8 -*- import os os.system('export MY_DATA="my_export"') </code></pre> <p>But when I list export, "MY_DATA" not appear :</p> <pre><...
26
2009-10-01T19:39:35Z
1,506,185
<p><code>export</code> is a command that you give directly to the shell (e.g. <code>bash</code>), to tell it to add or modify one of its environment variables. You can't change your shell's environment from a child process (such as Python), it's just not possible.</p> <p>Here's what's happening with you try <code>os.s...
42
2009-10-01T20:11:47Z
[ "python", "linux", "export" ]
How to use export with Python on Linux
1,506,010
<p>I need to make an export like this in Python :</p> <pre><code># export MY_DATA="my_export" </code></pre> <p>I've tried to do :</p> <pre><code># -*- python-mode -*- # -*- coding: utf-8 -*- import os os.system('export MY_DATA="my_export"') </code></pre> <p>But when I list export, "MY_DATA" not appear :</p> <pre><...
26
2009-10-01T19:39:35Z
8,938,108
<p>os.system ('/home/user1/exportPath.ksh')</p> <p>exportPath.ksh:</p> <p><code>export PATH=MY_DATA="my_export"</code></p>
-6
2012-01-20T07:33:14Z
[ "python", "linux", "export" ]
How to use export with Python on Linux
1,506,010
<p>I need to make an export like this in Python :</p> <pre><code># export MY_DATA="my_export" </code></pre> <p>I've tried to do :</p> <pre><code># -*- python-mode -*- # -*- coding: utf-8 -*- import os os.system('export MY_DATA="my_export"') </code></pre> <p>But when I list export, "MY_DATA" not appear :</p> <pre><...
26
2009-10-01T19:39:35Z
21,412,705
<p>Another way to do this, if you're in a hurry and don't mind the hacky-aftertaste, is to execute the output of the python script in your bash environment and print out the commands to execute setting the environment in python. Not ideal but it can get the job done in a pinch. It's not very portable across shells, so ...
4
2014-01-28T17:35:41Z
[ "python", "linux", "export" ]
Duplicate Insertions in Database using sqlite, sqlalchemy, python
1,506,023
<p>I am learning Python and, through the help of online resources and people on this site, am getting the hang of it. In this first script of mine, in which I'm parsing Twitter RSS feed entries and inserting the results into a database, there is one remaining problem that I cannot fix. Namely, duplicate entries are bei...
0
2009-10-01T19:41:41Z
1,506,453
<p>It looks like you included SQLAlchemy into a previously existing script that didn't use SQLAlchemy. There are too many moving parts here that none of us apparently understand well enough.</p> <p>I would recommend starting from scratch. Don't use threading. Don't use sqlalchemy. To start maybe don't even use an ...
2
2009-10-01T20:59:02Z
[ "python", "sqlite", "twitter", "sqlalchemy", "duplicates" ]
Delete all visible cookies raises an exception
1,506,315
<p>I am using selenium with a python client. When doing selenium.delete_all_visible_cookies I get the exception: <br></p> <blockquote> <p>ERROR: Command execution failure. Please search the forum at <a href="http://clearspace.openqa.org" rel="nofollow">http://clearspace.openqa.org</a> for error details from th...
2
2009-10-01T20:35:03Z
1,511,139
<p>This is a bug, see here: <a href="http://clearspace.openqa.org/message/68779" rel="nofollow">http://clearspace.openqa.org/message/68779</a></p>
1
2009-10-02T18:33:08Z
[ "python", "exception", "selenium", "cookies" ]
Delete all visible cookies raises an exception
1,506,315
<p>I am using selenium with a python client. When doing selenium.delete_all_visible_cookies I get the exception: <br></p> <blockquote> <p>ERROR: Command execution failure. Please search the forum at <a href="http://clearspace.openqa.org" rel="nofollow">http://clearspace.openqa.org</a> for error details from th...
2
2009-10-01T20:35:03Z
7,144,722
<p>To see the bug: <a href="http://jira.openqa.org/browse/SEL-712" rel="nofollow">http://jira.openqa.org/browse/SEL-712</a></p>
1
2011-08-22T08:19:52Z
[ "python", "exception", "selenium", "cookies" ]
Need a HTTPS-capable Python XML-RPC server
1,506,379
<p>I already have a very simple threading XML-RPC server in Python:</p> <pre><code>from SocketServer import ThreadingMixIn class AsyncXMLRPCServer(ThreadingMixIn, SimpleXMLRPCServer): pass server = AsyncXMLRPCServer(('localhost', 9999)) server.register_instance(some_object()) server.serve_forever() </code></pre> ...
0
2009-10-01T20:47:00Z
1,506,438
<p>The standard library doesn't support HTTPS servers. There is a <a href="http://code.activestate.com/recipes/496786/">Cookbook Recipe</a> using an OpenSSL module. There is also a <a href="http://www.etopian.com/portfolio/https-python-xmlrpc-server-w-authentication">Twisted solution</a>.</p>
5
2009-10-01T20:57:06Z
[ "python", "ssl", "https", "xml-rpc" ]
How to run multiple Tornado processes/threads/frontends?
1,506,463
<p>In the tornado documentation they show how they can have a very large through-put from <a href="http://www.tornadoweb.org/documentation#performance">4 frontends</a>. I'd like to run an app in the same way, and would like to have the frontends running as daemon processes managed with an init.d script*. </p> <p>I'm f...
5
2009-10-01T21:00:17Z
1,506,654
<p>Try <a href="http://supervisord.org/">Supervisor</a>. It's great for managing multiple daemon processes. You configure your applications in the supervisord.conf file and supervisord itself is launched from an init.d script.</p>
6
2009-10-01T21:38:58Z
[ "python", "deployment", "tornado" ]
How to run multiple Tornado processes/threads/frontends?
1,506,463
<p>In the tornado documentation they show how they can have a very large through-put from <a href="http://www.tornadoweb.org/documentation#performance">4 frontends</a>. I'd like to run an app in the same way, and would like to have the frontends running as daemon processes managed with an init.d script*. </p> <p>I'm f...
5
2009-10-01T21:00:17Z
1,751,660
<p>I can vouch for Supervisor too. We have been using tornado in production with 4 instances using supervisor and it is working uber smooth</p>
1
2009-11-17T20:48:08Z
[ "python", "deployment", "tornado" ]
Validating Google Optimizer javascript code via HTMLParser
1,506,496
<p>I'm trying to include the Google Website Optimizer JavaScript code, below, in a Zope3 page template. It's used for for A/B testing.</p> <p>However, the template html parser, which I believe is the standard Python HTMLParser module, throws the following error:</p> <pre><code>raise PTRuntimeError(str(self._v_errors)...
1
2009-10-01T21:06:21Z
1,506,561
<p>Given the parser's weakness, you could try breaking up the parts of the CDATA that it's trying to interpret as tags, e.g. where you now have <code>&lt;/sc'+'ript&gt;'</code> try <code>&lt;'+'/sc'+'ript&gt;'</code> etc (<code>+</code> does string catenation in JS, just like in Python, so it will put back together aga...
1
2009-10-01T21:18:25Z
[ "javascript", "python", "zope", "google-website-optimizer", "zpt" ]
Validating Google Optimizer javascript code via HTMLParser
1,506,496
<p>I'm trying to include the Google Website Optimizer JavaScript code, below, in a Zope3 page template. It's used for for A/B testing.</p> <p>However, the template html parser, which I believe is the standard Python HTMLParser module, throws the following error:</p> <pre><code>raise PTRuntimeError(str(self._v_errors)...
1
2009-10-01T21:06:21Z
1,506,571
<p>My guess is the parser doesn't like the fact that </p> <pre><code>&lt;/sc'+'ript&gt; </code></pre> <p>is split in two. Which is perfectly valid javascript but may confuse the htmlparser?</p> <p>Might want to try </p> <pre><code>&lt;'+'/sc'+'ript&gt;' </code></pre>
0
2009-10-01T21:19:37Z
[ "javascript", "python", "zope", "google-website-optimizer", "zpt" ]
Validating Google Optimizer javascript code via HTMLParser
1,506,496
<p>I'm trying to include the Google Website Optimizer JavaScript code, below, in a Zope3 page template. It's used for for A/B testing.</p> <p>However, the template html parser, which I believe is the standard Python HTMLParser module, throws the following error:</p> <pre><code>raise PTRuntimeError(str(self._v_errors)...
1
2009-10-01T21:06:21Z
4,036,242
<p>One other option you have is to place the code in an external file and reference it instead of embedding it directly into the code. I've done this and it works well. That's always an easier way if you don't want the validator to crawl any javascript or css.</p>
-1
2010-10-27T18:05:26Z
[ "javascript", "python", "zope", "google-website-optimizer", "zpt" ]
Validating Google Optimizer javascript code via HTMLParser
1,506,496
<p>I'm trying to include the Google Website Optimizer JavaScript code, below, in a Zope3 page template. It's used for for A/B testing.</p> <p>However, the template html parser, which I believe is the standard Python HTMLParser module, throws the following error:</p> <pre><code>raise PTRuntimeError(str(self._v_errors)...
1
2009-10-01T21:06:21Z
5,025,484
<p>Actually, this problem is trivial to solve by avoiding the HTML parser all together. Simply put the google Control Script into a separate file or object as Javascript and pull it into the page with a TAL include.</p> <p>The HTML parser is not used when the file is brought in as Javascript.</p>
1
2011-02-17T05:43:17Z
[ "javascript", "python", "zope", "google-website-optimizer", "zpt" ]