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
list
python on 32 bit
2,543,120
<p>Hi I am running Windows XP, on 32bit. How do I install python? When I run the installation file, it gives me an error saying "installation package not supported by processor type" does python need 64 bit to execute? </p>
0
2010-03-30T05:56:57Z
2,543,167
<p>Your 32-bit options (for Windows) include <a href="http://downloads.activestate.com/ActivePython/releases/2.6.5.12/ActivePython-2.6.5.12-win32-x86.msi" rel="nofollow">ActivePython 2.6.5</a> and <a href="http://downloads.activestate.com/ActivePython/releases/3.1.2.3/ActivePython-3.1.2.3-win32-x86.msi" rel="nofollow">...
4
2010-03-30T06:12:43Z
[ "python", "windows-xp" ]
Pylons: Set global variable for Authkit user
2,543,315
<p>How can I can set a global variable for the username of the logged-in user? At the moment i have the following code in all my controllers to get the username. I rather set it as a global variable if possible.</p> <p><code>request.environ.get("REMOTE_USER")</code></p> <p>I tried putting the same code in the app_glo...
0
2010-03-30T06:52:28Z
2,543,332
<p>There is no single "logged-in user" if you're serving requests on multiple threads -- by setting a single global variable the threads would trample upon each other and end up very very confused on who "the logged-in user" actually <em>is</em>. There <strong>is</strong> (at most;-) a single logged-in user <strong>pe...
1
2010-03-30T06:55:27Z
[ "python", "pylons", "authkit" ]
How to call Twitter's Streaming/Filter Feed with urllib2/httplib?
2,543,339
<p>Update: </p> <p>I switched this back from answered as I tried the solution posed in cogent Nick's answer and switched to Google's urlfetch:</p> <pre><code>logging.debug("starting urlfetch for http://%s%s" % (self.host, self.url)) result = urlfetch.fetch("http://%s%s" % (self.host, self.url), payload=self.body, met...
0
2010-03-30T06:56:26Z
2,544,144
<p>urllib on App Engine is a thin wrapper around the <a href="http://code.google.com/appengine/docs/python/urlfetch/" rel="nofollow">urlfetch API</a>. You're right about what's happening: Twitter's streaming API never terminates its response, so it times out, and urlfetch throws an exception.</p> <p>If you use urlfetc...
1
2010-03-30T09:37:10Z
[ "python", "google-app-engine", "twitter-feed" ]
Django Distinct on queryset in forms.py
2,543,672
<p>I try to get a list with distinct into the forms.py like this:</p> <p>forms.ModelMultipleChoiceField(queryset=Events.objects.values('hostname'), required=False).distinct()</p> <p>In the python shell this command works perfect, but when trying it in forms.py leaves me a blank form, so nothing appears. When i just d...
1
2010-03-30T08:11:35Z
2,544,052
<p>For a ModelMultipleChoiceField, Django expects a model object - because it stores the value of the selected item's primary key. In other words, it's meant to be used to manage ManyToMany fields.</p> <p>It sounds like you're wanting to store the actual string value, so this might not be the right choice for you. Yo...
0
2010-03-30T09:23:18Z
[ "python", "django", "forms", "distinct" ]
"No module named slimmer.middleware"
2,544,002
<p>I'm trying to setup blog engine django-mingus, but meet this obstacle:</p> <pre><code>[Tue Mar 30 04:14:02 2010] [error] [client 192.168.12.161] mod_wsgi (pid=12908): Exception occurred processing WSGI script '/home/piv/srv/python-env/myblog/project/django-mingus/mingus/deploy/django.wsgi'. [Tue Mar 30 04:14:02 201...
0
2010-03-30T09:11:57Z
2,544,752
<p>Read:</p> <p><a href="http://blog.dscpl.com.au/2010/03/improved-wsgi-script-for-use-with.html" rel="nofollow">http://blog.dscpl.com.au/2010/03/improved-wsgi-script-for-use-with.html</a></p> <p>Try the alternate WSGI script file described at the end.</p> <p>This will resolve some sys.path issues if you hadn't done...
0
2010-03-30T11:34:21Z
[ "python", "django" ]
python: what are efficient techniques to deal with deeply nested data in a flexible manner?
2,544,055
<p>My question is not about a specific code snippet but more general, so please bear with me: </p> <p>How should I organize the data I'm analyzing, and which tools should I use to manage it?</p> <p>I'm using python and numpy to analyse data. Because the python documentation indicates that dictionaries are very optimi...
7
2010-03-30T09:23:33Z
2,544,193
<p>You can make your loops look better, by replacing:</p> <pre><code>for mk in dic.keys(): for rgk in dic[mk].keys(): for nk in dic[mk][rgk].keys(): for ik in dic[mk][rgk][nk].keys(): for ek in dic[mk][rgk][nk][ik].keys(): #do something </code></pre> <p>with...
2
2010-03-30T09:45:17Z
[ "python", "dictionary", "nested" ]
python: what are efficient techniques to deal with deeply nested data in a flexible manner?
2,544,055
<p>My question is not about a specific code snippet but more general, so please bear with me: </p> <p>How should I organize the data I'm analyzing, and which tools should I use to manage it?</p> <p>I'm using python and numpy to analyse data. Because the python documentation indicates that dictionaries are very optimi...
7
2010-03-30T09:23:33Z
2,544,322
<p>You ask: <em>How should I organize the data I'm analyzing, and which tools should I use to manage it?</em></p> <p>I suspect that a dictionary, for all its optimization, is not the right answer to that question. I think you'd be better off using XML or, if there is a Python binding for it, HDF5, even NetCDF. Or, as ...
0
2010-03-30T10:08:35Z
[ "python", "dictionary", "nested" ]
python: what are efficient techniques to deal with deeply nested data in a flexible manner?
2,544,055
<p>My question is not about a specific code snippet but more general, so please bear with me: </p> <p>How should I organize the data I'm analyzing, and which tools should I use to manage it?</p> <p>I'm using python and numpy to analyse data. Because the python documentation indicates that dictionaries are very optimi...
7
2010-03-30T09:23:33Z
2,544,395
<p>You could write a generator function that allows you to iterate over all elements of a certain level:</p> <pre><code>def elementsAt(dic, level): if not hasattr(dic, 'itervalues'): return for element in dic.itervalues(): if level == 0: yield element else: for s...
0
2010-03-30T10:24:17Z
[ "python", "dictionary", "nested" ]
python: what are efficient techniques to deal with deeply nested data in a flexible manner?
2,544,055
<p>My question is not about a specific code snippet but more general, so please bear with me: </p> <p>How should I organize the data I'm analyzing, and which tools should I use to manage it?</p> <p>I'm using python and numpy to analyse data. Because the python documentation indicates that dictionaries are very optimi...
7
2010-03-30T09:23:33Z
2,544,413
<blockquote> <p>"I stored it in a deeply nested dictionary"</p> </blockquote> <p>And, as you've seen, it doesn't work out well.</p> <p>What's the alternative? </p> <ol> <li><p>Composite keys and a shallow dictionary. You have an 8-part key: ( individual, imaging session, Region imaged, timestamp of file, propertie...
11
2010-03-30T10:26:35Z
[ "python", "dictionary", "nested" ]
python: what are efficient techniques to deal with deeply nested data in a flexible manner?
2,544,055
<p>My question is not about a specific code snippet but more general, so please bear with me: </p> <p>How should I organize the data I'm analyzing, and which tools should I use to manage it?</p> <p>I'm using python and numpy to analyse data. Because the python documentation indicates that dictionaries are very optimi...
7
2010-03-30T09:23:33Z
2,544,570
<p>I will share some thoughts about this. Instead of this function:</p> <pre><code>for mk in dic.keys(): for rgk in dic[mk].keys(): for nk in dic[mk][rgk].keys(): for ik in dic[mk][rgk][nk].keys(): for ek in dic[mk][rgk][nk][ik].keys(): #do something </code><...
1
2010-03-30T10:58:35Z
[ "python", "dictionary", "nested" ]
Overwrite the Soap Envelope in Suds python
2,544,331
<p>I have a camera and I am trying to connect to it vis suds. I have tried to send raw xml and have found that the only thing stopping the xml suds from working is an incorrect Soap envelope namespace.</p> <p>The envelope namespace is:</p> <p><code>xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"</code></p>...
5
2010-03-30T10:09:20Z
2,545,937
<p>I managed to get this working, the soap envelope is hard coded into <code>bindings.py</code> that is stored in <code>suds.egg</code> installed in your site-packages. I changed the SOAP envelope address to <code>http://www.w3.org/2003/05/soap-envelope</code>. This was compatible with my camera. I was unable to find a...
1
2010-03-30T14:22:50Z
[ "python", "xml", "soap", "suds", "envelope" ]
Overwrite the Soap Envelope in Suds python
2,544,331
<p>I have a camera and I am trying to connect to it vis suds. I have tried to send raw xml and have found that the only thing stopping the xml suds from working is an incorrect Soap envelope namespace.</p> <p>The envelope namespace is:</p> <p><code>xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"</code></p>...
5
2010-03-30T10:09:20Z
2,569,746
<p>Manually updating <code>binding.py</code> definitely isn't the right way to go. You should be able to utilize the <code>ImportDoctor</code> to override your default bindings. Have a look at the documentation for <a href="https://fedorahosted.org/suds/wiki/Documentation#FIXINGBROKENSCHEMAs" rel="nofollow">fixing bro...
1
2010-04-02T23:49:51Z
[ "python", "xml", "soap", "suds", "envelope" ]
Overwrite the Soap Envelope in Suds python
2,544,331
<p>I have a camera and I am trying to connect to it vis suds. I have tried to send raw xml and have found that the only thing stopping the xml suds from working is an incorrect Soap envelope namespace.</p> <p>The envelope namespace is:</p> <p><code>xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"</code></p>...
5
2010-03-30T10:09:20Z
14,579,933
<p>I got around it by manually overriding the <code>suds.binding.envns</code> variable in the <code>bindings</code> module:</p> <pre><code>from suds.bindings import binding binding.envns=('SOAP-ENV', 'http://www.w3.org/2003/05/soap-envelope') </code></pre> <p>From here on, all goes well (with <em>my</em> service, tha...
4
2013-01-29T09:48:03Z
[ "python", "xml", "soap", "suds", "envelope" ]
Overwrite the Soap Envelope in Suds python
2,544,331
<p>I have a camera and I am trying to connect to it vis suds. I have tried to send raw xml and have found that the only thing stopping the xml suds from working is an incorrect Soap envelope namespace.</p> <p>The envelope namespace is:</p> <p><code>xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"</code></p>...
5
2010-03-30T10:09:20Z
36,646,593
<pre><code>from suds.client import Client from suds.plugin import MessagePlugin WSDL_url = "my_url?wsdl" class MyPlugin(MessagePlugin): def marshalled(self, context): #print(str(context.envelope)) context.envelope.nsprefixes['SOAP-ENV']='myText' client = Client(WSDL_url, plugins=[MyPlugin()]) </c...
0
2016-04-15T12:01:10Z
[ "python", "xml", "soap", "suds", "envelope" ]
wxPython, Threads, and PostEvent between modules
2,544,339
<p>I'm relatively new to wxPython (but not Python itself), so forgive me if I've missed something here.</p> <p>I'm writing a GUI application, which at a very basic level consists of "Start" and "Stop" buttons that start and stop a thread. This thread is an infinite loop, which only ends when the thread is stopped. The...
1
2010-03-30T10:10:26Z
2,544,515
<p>The easiest solution would be to use <a href="http://wiki.wxpython.org/CallAfter" rel="nofollow">wx.CallAfter</a></p> <pre><code>wx.CallAfter(text_control.SetValue, "some_text") </code></pre> <p>You can call <code>CallAfter</code> from any thread and the function that you pass it to be called will be called from t...
2
2010-03-30T10:46:50Z
[ "python", "user-interface", "events", "multithreading", "wxpython" ]
python mechanize.browser submit() related problem
2,544,430
<p>im making some script with mechanize.browser module.</p> <p>one of problem is all other thing is ok, but when submit() form,it not working,</p> <p>so i was found some suspicion source part.</p> <p>in the html source i was found such like following.</p> <pre><code>&lt;form method="post" onsubmit="return loginChec...
5
2010-03-30T10:29:42Z
2,544,486
<p><strong>onsubmit</strong> is just ignored by mechanize, no javascript interpretation is done.<br> You need to verify what loginCheck(); in some limited case (Validation) you can do programmatically what javascript does.</p>
1
2010-03-30T10:41:04Z
[ "python", "mechanize" ]
python mechanize.browser submit() related problem
2,544,430
<p>im making some script with mechanize.browser module.</p> <p>one of problem is all other thing is ok, but when submit() form,it not working,</p> <p>so i was found some suspicion source part.</p> <p>in the html source i was found such like following.</p> <pre><code>&lt;form method="post" onsubmit="return loginChec...
5
2010-03-30T10:29:42Z
2,544,560
<p>you will either need to make use of unmaintained module <a href="http://wwwsearch.sourceforge.net/DOMForm/" rel="nofollow">DOMForm</a> and Spidermonkey (http://pypi.python.org/pypi/python-spidermonkey) to process javascript. Or you figure out what loginCheck() is doing and perform its work prior form submission in p...
1
2010-03-30T10:57:04Z
[ "python", "mechanize" ]
python mechanize.browser submit() related problem
2,544,430
<p>im making some script with mechanize.browser module.</p> <p>one of problem is all other thing is ok, but when submit() form,it not working,</p> <p>so i was found some suspicion source part.</p> <p>in the html source i was found such like following.</p> <pre><code>&lt;form method="post" onsubmit="return loginChec...
5
2010-03-30T10:29:42Z
2,622,617
<p>mechanize doesn't support Javascript at all. If you absolutely have to run that Javascript, look into Selenium. It offers python bindings to control a real, running browser like Firefox or IE.</p>
2
2010-04-12T14:04:37Z
[ "python", "mechanize" ]
Filtering by entity key name in Google App Engine on Python
2,544,565
<p>On Google App Engine to query the data store with Python, one can use GQL or Entity.all() and then filter it. So for example these are equivalent</p> <pre><code>gql = "SELECT * FROM User WHERE age &gt;= 18" db.GqlQuery(gql) </code></pre> <p>and</p> <pre><code>query = User.all() query.filter("age &gt;=", 18) </cod...
14
2010-03-30T10:57:29Z
2,544,614
<pre><code>from google.appengine.api.datastore import Key query.filter("__key__ &gt;=", Key.from_path('User', 'abc')) </code></pre>
16
2010-03-30T11:08:23Z
[ "python", "google-app-engine", "gae-datastore" ]
Filtering by entity key name in Google App Engine on Python
2,544,565
<p>On Google App Engine to query the data store with Python, one can use GQL or Entity.all() and then filter it. So for example these are equivalent</p> <pre><code>gql = "SELECT * FROM User WHERE age &gt;= 18" db.GqlQuery(gql) </code></pre> <p>and</p> <pre><code>query = User.all() query.filter("age &gt;=", 18) </cod...
14
2010-03-30T10:57:29Z
4,670,192
<p>For me a similar way worked, while the "from_path" function did not worked in my case, this one did:</p> <pre><code>from google.appengine.api.datastore import Key key = Key(your_string_with_key) query.filter("__key__ = ", key) </code></pre>
3
2011-01-12T14:58:10Z
[ "python", "google-app-engine", "gae-datastore" ]
py2app prescripts
2,544,619
<p>The <a href="http://svn.pythonmac.org/py2app/py2app/trunk/doc/index.html" rel="nofollow">py2app documentation</a> mentions prescripts, being run by <code>__boot__.py</code> prior to the main python script. I couldn't find a way to easily specify any prescript on the setup.py file or build process.</p> <p>I did howe...
3
2010-03-30T11:10:12Z
2,546,620
<p>See <a href="http://svn.pythonmac.org/py2app/py2app/trunk/doc/index.html#developing-recipes" rel="nofollow">the docs</a>: your <code>py2app.recipes</code> package must contain a recipe whose <code>check</code> method returns a <code>dict</code> including the <code>'prescripts'</code> key whose value is, and I quote,...
0
2010-03-30T15:52:10Z
[ "python", "monkeypatching", "py2app" ]
How I can get rid of None values in dictionary?
2,544,710
<p>Something like:</p> <pre><code>for (a,b) in kwargs.iteritems(): if not b : del kwargs[a] </code></pre> <p>This code raise exception because changing of dictionary when iterating.</p> <p>I discover only non pretty solution with another dictionary:</p> <pre><code>res ={} res.update((a,b) for a,b in kwargs.iter...
7
2010-03-30T11:27:00Z
2,544,744
<p>I like the variation of your second method:</p> <pre><code> res = dict((a, b) for (a, b) in kwargs.iteritems() if b is not None) </code></pre> <p>it's Pythonic and I don't think that ugly. A variation of your first is:</p> <pre><code> for (a, b) in list(kwargs.iteritems()): if b is None: de...
5
2010-03-30T11:32:52Z
[ "python" ]
How I can get rid of None values in dictionary?
2,544,710
<p>Something like:</p> <pre><code>for (a,b) in kwargs.iteritems(): if not b : del kwargs[a] </code></pre> <p>This code raise exception because changing of dictionary when iterating.</p> <p>I discover only non pretty solution with another dictionary:</p> <pre><code>res ={} res.update((a,b) for a,b in kwargs.iter...
7
2010-03-30T11:27:00Z
2,544,761
<p>Another way to write it is</p> <pre><code>res = dict((k,v) for k,v in kwargs.iteritems() if v is not None) </code></pre> <p>In Python3, this becomes</p> <pre><code>res = {k:v for k,v in kwargs.items() if v is not None} </code></pre>
18
2010-03-30T11:35:38Z
[ "python" ]
How I can get rid of None values in dictionary?
2,544,710
<p>Something like:</p> <pre><code>for (a,b) in kwargs.iteritems(): if not b : del kwargs[a] </code></pre> <p>This code raise exception because changing of dictionary when iterating.</p> <p>I discover only non pretty solution with another dictionary:</p> <pre><code>res ={} res.update((a,b) for a,b in kwargs.iter...
7
2010-03-30T11:27:00Z
2,545,174
<p>You can also use <code>filter</code>:</p> <pre><code>d = dict(a = 1, b = None, c = 3) filtered = dict(filter(lambda item: item[1] is not None, d.items())) print(filtered) {'a': 1, 'c': 3} </code></pre>
4
2010-03-30T12:39:01Z
[ "python" ]
How I can get rid of None values in dictionary?
2,544,710
<p>Something like:</p> <pre><code>for (a,b) in kwargs.iteritems(): if not b : del kwargs[a] </code></pre> <p>This code raise exception because changing of dictionary when iterating.</p> <p>I discover only non pretty solution with another dictionary:</p> <pre><code>res ={} res.update((a,b) for a,b in kwargs.iter...
7
2010-03-30T11:27:00Z
24,663,461
<pre><code>d = {'a': None, 'b': 'myname', 'c': 122} print dict(filter(lambda x:x[1], d.items())) {'b': 'myname', 'c': 122} </code></pre>
1
2014-07-09T20:43:40Z
[ "python" ]
How to localize an app on Google App Engine?
2,544,843
<p>What options are there for localizing an app on Google App Engine? How do you do it using Webapp, Django, web2py or [insert framework here].</p> <h2>1. Readable URLs and entity key names</h2> <p>Readable URLs are good for usability and search engine optimization (Stack Overflow is a good example on how to do it). ...
4
2010-03-30T11:50:36Z
2,544,933
<p>Concerning point 2, I asked <a href="http://stackoverflow.com/questions/1946251/how-to-create-an-internationalized-google-app-engine-application">a similar question</a> a few months ago. I've managed to get the application internationalized, but just the content, not the urls (wasn't planning on doing so either).</p...
2
2010-03-30T12:06:50Z
[ "python", "django", "google-app-engine", "internationalization", "localization" ]
How to localize an app on Google App Engine?
2,544,843
<p>What options are there for localizing an app on Google App Engine? How do you do it using Webapp, Django, web2py or [insert framework here].</p> <h2>1. Readable URLs and entity key names</h2> <p>Readable URLs are good for usability and search engine optimization (Stack Overflow is a good example on how to do it). ...
4
2010-03-30T11:50:36Z
2,545,351
<p>Regarding point 1, there's really no need to go to such lengths: Simply use unicode key names. They'll be encoded as UTF-8 in the datastore for you.</p> <p>Regarding point 3, there are many ways to handle language detection. Certainly accept_language should be part of it, and you'll find <a href="http://pythonpaste...
3
2010-03-30T13:06:04Z
[ "python", "django", "google-app-engine", "internationalization", "localization" ]
How can get Python isidentifer() functionality in Python 2.6?
2,544,972
<p>Python 3 has a string method called <a href="http://docs.python.org/py3k/library/stdtypes.html#str.isidentifier"><code>str.isidentifier</code></a></p> <p>How can I get similar functionality in Python 2.6, short of rewriting my own regex, etc.?</p>
13
2010-03-30T12:14:29Z
2,544,998
<pre><code>re.match(r'[a-z_]\w*$', s, re.I) </code></pre> <p>should do nicely. As far as I know there isn't any built-in method.</p>
2
2010-03-30T12:18:41Z
[ "python", "python-3.x", "python-2.6", "identifier" ]
How can get Python isidentifer() functionality in Python 2.6?
2,544,972
<p>Python 3 has a string method called <a href="http://docs.python.org/py3k/library/stdtypes.html#str.isidentifier"><code>str.isidentifier</code></a></p> <p>How can I get similar functionality in Python 2.6, short of rewriting my own regex, etc.?</p>
13
2010-03-30T12:14:29Z
2,545,018
<p>In Python &lt; 3.0 this is quite easy, as you can't have unicode characters in identifiers. That should do the work:</p> <pre><code>import re import keyword def isidentifier(s): if s in keyword.kwlist: return False return re.match(r'^[a-z_][a-z0-9_]*$', s, re.I) is not None </code></pre>
1
2010-03-30T12:22:00Z
[ "python", "python-3.x", "python-2.6", "identifier" ]
How can get Python isidentifer() functionality in Python 2.6?
2,544,972
<p>Python 3 has a string method called <a href="http://docs.python.org/py3k/library/stdtypes.html#str.isidentifier"><code>str.isidentifier</code></a></p> <p>How can I get similar functionality in Python 2.6, short of rewriting my own regex, etc.?</p>
13
2010-03-30T12:14:29Z
2,545,164
<p>the tokenize module defines a regexp called Name</p> <pre><code>import re, tokenize, keyword re.match(tokenize.Name + '$', somestr) and not keyword.iskeyword(somestr) </code></pre>
11
2010-03-30T12:37:44Z
[ "python", "python-3.x", "python-2.6", "identifier" ]
How can get Python isidentifer() functionality in Python 2.6?
2,544,972
<p>Python 3 has a string method called <a href="http://docs.python.org/py3k/library/stdtypes.html#str.isidentifier"><code>str.isidentifier</code></a></p> <p>How can I get similar functionality in Python 2.6, short of rewriting my own regex, etc.?</p>
13
2010-03-30T12:14:29Z
2,545,166
<p>Good answers so far. I'd write it like this.</p> <pre><code>import keyword import re def isidentifier(candidate): "Is the candidate string an identifier in Python 2.x" is_not_keyword = candidate not in keyword.kwlist pattern = re.compile(r'^[a-z_][a-z0-9_]*$', re.I) matches_pattern = bool(pattern.m...
1
2010-03-30T12:37:54Z
[ "python", "python-3.x", "python-2.6", "identifier" ]
How can get Python isidentifer() functionality in Python 2.6?
2,544,972
<p>Python 3 has a string method called <a href="http://docs.python.org/py3k/library/stdtypes.html#str.isidentifier"><code>str.isidentifier</code></a></p> <p>How can I get similar functionality in Python 2.6, short of rewriting my own regex, etc.?</p>
13
2010-03-30T12:14:29Z
2,545,406
<p>What I am using:</p> <pre><code>def is_valid_keyword_arg(k): """ Return True if the string k can be used as the name of a valid Python keyword argument, otherwise return False. """ # Don't allow python reserved words as arg names if k in keyword.kwlist: return False return re.mat...
0
2010-03-30T13:12:51Z
[ "python", "python-3.x", "python-2.6", "identifier" ]
How can get Python isidentifer() functionality in Python 2.6?
2,544,972
<p>Python 3 has a string method called <a href="http://docs.python.org/py3k/library/stdtypes.html#str.isidentifier"><code>str.isidentifier</code></a></p> <p>How can I get similar functionality in Python 2.6, short of rewriting my own regex, etc.?</p>
13
2010-03-30T12:14:29Z
2,546,902
<p>I've decided to take another crack at this, since there have been several good suggestions. I'll try to consolidate them. The following can be saved as a Python module and run directly from the command-line. If run, it tests the function, so is provably correct (at least to the extent that the documentation demonstr...
0
2010-03-30T16:35:44Z
[ "python", "python-3.x", "python-2.6", "identifier" ]
How can get Python isidentifer() functionality in Python 2.6?
2,544,972
<p>Python 3 has a string method called <a href="http://docs.python.org/py3k/library/stdtypes.html#str.isidentifier"><code>str.isidentifier</code></a></p> <p>How can I get similar functionality in Python 2.6, short of rewriting my own regex, etc.?</p>
13
2010-03-30T12:14:29Z
35,825,603
<p>All solutions proposed so far do not support Unicode or allow a number in the first char <em>if run on Python 3</em>.</p> <p>Edit: the proposed solutions should only be used on Python 2, and on Python3 <code>isidentifier</code> should be used. Here is a solution that should work anywhere:</p> <pre><code>re.match(r...
0
2016-03-06T10:13:04Z
[ "python", "python-3.x", "python-2.6", "identifier" ]
Converting a string into a list in Python
2,545,397
<p>I have a text document that contains a list of numbers and I want to convert it to a list. Right now I can only get the entire list in the 0th entry of the list, but I want each number to be an element of a list. Does anyone know of an easy way to do this in Python?</p> <pre><code>1000 2000 3000 4000 </code></pre> ...
6
2010-03-30T13:11:45Z
2,545,412
<pre><code>&gt;&gt;&gt; open("myfile.txt").readlines() &gt;&gt;&gt; lines = open("myfile.txt").readlines() &gt;&gt;&gt; lines ['1000\n', '2000\n', '3000\n', '4000\n'] &gt;&gt;&gt; clean_lines = [x.strip() for x in lines] &gt;&gt;&gt; clean_lines ['1000', '2000', '3000', '4000'] </code></pre> <p>Or, if you have a strin...
1
2010-03-30T13:13:30Z
[ "python" ]
Converting a string into a list in Python
2,545,397
<p>I have a text document that contains a list of numbers and I want to convert it to a list. Right now I can only get the entire list in the 0th entry of the list, but I want each number to be an element of a list. Does anyone know of an easy way to do this in Python?</p> <pre><code>1000 2000 3000 4000 </code></pre> ...
6
2010-03-30T13:11:45Z
2,545,417
<p>To convert a Python string into a list use the <code>str.split</code> method:</p> <pre><code>&gt;&gt;&gt; '1000 2000 3000 4000'.split() ['1000', '2000', '3000', '4000'] </code></pre> <p><code>split</code> has some options: look them up for advanced uses.</p> <p>You can also read the file into a list with the <cod...
16
2010-03-30T13:14:00Z
[ "python" ]
Converting a string into a list in Python
2,545,397
<p>I have a text document that contains a list of numbers and I want to convert it to a list. Right now I can only get the entire list in the 0th entry of the list, but I want each number to be an element of a list. Does anyone know of an easy way to do this in Python?</p> <pre><code>1000 2000 3000 4000 </code></pre> ...
6
2010-03-30T13:11:45Z
2,545,420
<p>You might need to strip newlines.</p> <pre><code># list of strings [number for number in open("file.txt")] # list of integers [int(number) for number in open("file.txt")] </code></pre>
0
2010-03-30T13:14:36Z
[ "python" ]
Converting a string into a list in Python
2,545,397
<p>I have a text document that contains a list of numbers and I want to convert it to a list. Right now I can only get the entire list in the 0th entry of the list, but I want each number to be an element of a list. Does anyone know of an easy way to do this in Python?</p> <pre><code>1000 2000 3000 4000 </code></pre> ...
6
2010-03-30T13:11:45Z
2,545,438
<pre><code> $ cat &gt; t.txt 1 2 3 4 ^D $ python Python 2.6.1 (r261:67515, Jul 7 2009, 23:51:51) [GCC 4.2.1 (Apple Inc. build 5646)] on darwin Type "help", "copyright", "credits" or "license" for more information. &gt;&gt;&gt; l = [l.strip() for l in open('t.txt')] &gt;&...
1
2010-03-30T13:16:34Z
[ "python" ]
Converting a string into a list in Python
2,545,397
<p>I have a text document that contains a list of numbers and I want to convert it to a list. Right now I can only get the entire list in the 0th entry of the list, but I want each number to be an element of a list. Does anyone know of an easy way to do this in Python?</p> <pre><code>1000 2000 3000 4000 </code></pre> ...
6
2010-03-30T13:11:45Z
2,548,960
<pre><code> with open('file.txt', 'rb') as f: data = f.read() lines = [s.strip() for s in data.split('\n') if s] </code></pre>
0
2010-03-30T21:41:13Z
[ "python" ]
Python analog of natsort function (sort a list using a "natural order" algorithm)
2,545,532
<p>I would like to know if there is something similar to <a href="http://www.php.net/manual/en/function.natsort.php" rel="nofollow">PHP natsort</a> function in Python?</p> <pre><code>l = ['image1.jpg', 'image15.jpg', 'image12.jpg', 'image3.jpg'] l.sort() </code></pre> <p>gives:</p> <pre><code>['image1.jpg', 'image12...
12
2010-03-30T13:29:12Z
3,033,342
<p>From <a href="http://stackoverflow.com/questions/34518/natural-sorting-algorithm/341745#341745">my answer</a> to <a href="http://stackoverflow.com/questions/34518/natural-sorting-algorithm">Natural Sorting algorithm</a>:</p> <pre><code>import re def natural_key(string_): """See http://www.codinghorror.com/blog/...
27
2010-06-13T18:11:14Z
[ "python", "sorting", "natsort" ]
Python analog of natsort function (sort a list using a "natural order" algorithm)
2,545,532
<p>I would like to know if there is something similar to <a href="http://www.php.net/manual/en/function.natsort.php" rel="nofollow">PHP natsort</a> function in Python?</p> <pre><code>l = ['image1.jpg', 'image15.jpg', 'image12.jpg', 'image3.jpg'] l.sort() </code></pre> <p>gives:</p> <pre><code>['image1.jpg', 'image12...
12
2010-03-30T13:29:12Z
10,686,121
<p>This function can be used as the <code>key=</code> argument for <a href="http://docs.python.org/library/functions.html#sorted" rel="nofollow"><code>sorted</code></a> in Python 2.x and 3.x:</p> <pre><code>def sortkey_natural(s): return tuple(int(part) if re.match(r'[0-9]+$', part) else part for p...
2
2012-05-21T13:24:20Z
[ "python", "sorting", "natsort" ]
Python analog of natsort function (sort a list using a "natural order" algorithm)
2,545,532
<p>I would like to know if there is something similar to <a href="http://www.php.net/manual/en/function.natsort.php" rel="nofollow">PHP natsort</a> function in Python?</p> <pre><code>l = ['image1.jpg', 'image15.jpg', 'image12.jpg', 'image3.jpg'] l.sort() </code></pre> <p>gives:</p> <pre><code>['image1.jpg', 'image12...
12
2010-03-30T13:29:12Z
18,415,343
<p>You can check out the third-party <a href="https://pypi.python.org/pypi/natsort">natsort</a> library on PyPI:</p> <pre><code>&gt;&gt;&gt; import natsort &gt;&gt;&gt; l = ['image1.jpg', 'image15.jpg', 'image12.jpg', 'image3.jpg'] &gt;&gt;&gt; natsort.natsorted(l) ['image1.jpg', 'image3.jpg', 'image12.jpg', 'image15....
9
2013-08-24T05:41:05Z
[ "python", "sorting", "natsort" ]
Losing 'post' requests sent to Pylons paster server
2,545,643
<p>I'm sending post requests to a Pylons server (served by paster serve), and if I send them with any frequency many don't arrive at the server. One at a time is ok, but if I fire off a few (or more) within seconds, only a small number get dealt with. If I send with no post data, or with get, it works fine, but putting...
0
2010-03-30T13:43:40Z
2,546,775
<p>Could you add logging on paster/pylons side to find where exactly these requests get lost? Are you sure that QT app is working right, may it be limit on the number of concurrent connections in QNetworkRequest? AFAIR QT networking uses separate thread for connection allocated from thread pool. Try adding error handli...
0
2010-03-30T16:14:49Z
[ "python", "http", "qt", "pylons", "paster" ]
Losing 'post' requests sent to Pylons paster server
2,545,643
<p>I'm sending post requests to a Pylons server (served by paster serve), and if I send them with any frequency many don't arrive at the server. One at a time is ok, but if I fire off a few (or more) within seconds, only a small number get dealt with. If I send with no post data, or with get, it works fine, but putting...
0
2010-03-30T13:43:40Z
2,552,588
<p>Thanks for you reply.</p> <p>Tracked it doen to the fact that paster serve only supports HTTP 1.0, and so wasn't responding to initial requests with a 100 code.</p> <p>Switched to Apache, all working now!</p>
1
2010-03-31T11:50:42Z
[ "python", "http", "qt", "pylons", "paster" ]
xmlrpc client call in python does not come back
2,545,655
<p>Using Python 2.6.4, windows</p> <p>With the following script I want to test a certain xmlrpc server. I call a non-existent function and hope for a traceback with an error. Instead, the function does not return. What could be the cause?</p> <pre><code>import xmlrpclib s = xmlrpclib.Server("http://127.0.0.1:80", ver...
2
2010-03-30T13:44:50Z
2,545,705
<p>Most likely, the server you're testing does not close the TCP connection once it has sent the response back to your client. Thus the client hangs, waiting for the server to close the connection before it can return from the function.</p>
2
2010-03-30T13:51:27Z
[ "python", "client", "xml-rpc" ]
xmlrpc client call in python does not come back
2,545,655
<p>Using Python 2.6.4, windows</p> <p>With the following script I want to test a certain xmlrpc server. I call a non-existent function and hope for a traceback with an error. Instead, the function does not return. What could be the cause?</p> <pre><code>import xmlrpclib s = xmlrpclib.Server("http://127.0.0.1:80", ver...
2
2010-03-30T13:44:50Z
2,546,555
<p>As you noticed, this is a bug in the server (the client claims to understand 1.0 and the server ignores that and responds in 1.1 anyway, so doesn't close the socket). Python has a workaround for such buggy servers in 2.7 and 3.2, see <a href="http://bugs.python.org/issue6267" rel="nofollow">this issue</a>, but that...
5
2010-03-30T15:41:24Z
[ "python", "client", "xml-rpc" ]
Google Apps shared contacts API get a contact for python
2,545,711
<p>I'm having some issues trying to pull a shared contact using the gdata api for python that Google provides. Here is what I have to get the contacts.. but they are not all listed there</p> <pre><code>feed = gd_client.GetContactsFeed() for i, entry in enumerate(feed.entry): print entry.title </code></pre> <p>I c...
1
2010-03-30T13:52:17Z
2,552,860
<p>Google API lacks of features here.<br> You need to query all your contacts and then iter on them like this:</p> <pre><code>feedquery = gdata.contacts.service.ContactsQuery() feedquery.query.max_results = 1000 gmlf = gd_client.GetContactsFeed(feedquery.ToUri()) for index,gmc in enumerate(gmlf.entry): print s...
4
2010-03-31T12:33:12Z
[ "python", "google-api" ]
Cleaning an XML file in Python before parsing
2,545,783
<p>I'm using minidom to parse an xml file and it threw an error indicating that the data is not well formed. I figured out that some of the pages have characters like <code>ไอเฟล &amp;</code>, causing the parser to hiccup. Is there an easy way to clean the file before I start parsing it? Righ...
1
2010-03-30T14:02:59Z
2,545,835
<p>Try</p> <pre><code>xmltext = re.sub(u"[^\x20-\x7f]+",u"",xmltext) </code></pre> <p>It will get rid of everything except 0x20-0x7F range.</p> <p>You may start from \x01, if you want want to keep control characters like tab, line breaks.</p> <pre><code>xmltext = re.sub(u"[^\x01-\x7f]+",u"",xmltext) </code></pre>
3
2010-03-30T14:09:34Z
[ "python", "xml" ]
Cleaning an XML file in Python before parsing
2,545,783
<p>I'm using minidom to parse an xml file and it threw an error indicating that the data is not well formed. I figured out that some of the pages have characters like <code>ไอเฟล &amp;</code>, causing the parser to hiccup. Is there an easy way to clean the file before I start parsing it? Righ...
1
2010-03-30T14:02:59Z
2,545,863
<p>Take a look at <a href="http://utidylib.berlios.de/" rel="nofollow">µTidyLib</a>, a Python wrapper to <a href="http://tidy.sourceforge.net/" rel="nofollow">TidyLib</a>.</p>
1
2010-03-30T14:12:13Z
[ "python", "xml" ]
Cleaning an XML file in Python before parsing
2,545,783
<p>I'm using minidom to parse an xml file and it threw an error indicating that the data is not well formed. I figured out that some of the pages have characters like <code>ไอเฟล &amp;</code>, causing the parser to hiccup. Is there an easy way to clean the file before I start parsing it? Righ...
1
2010-03-30T14:02:59Z
2,545,869
<p>I'd throw out all non-ASCII characters which can be identified by having the 8th bit (0x80) set (128 .. 255 respectively 0x80 .. 0xff).</p> <ul> <li><p>You could read in the file into a Python string named <code>old_str</code></p></li> <li><p>Then perform a <code>filter</code> call in conjunction with a <code>lambd...
-1
2010-03-30T14:12:42Z
[ "python", "xml" ]
Cleaning an XML file in Python before parsing
2,545,783
<p>I'm using minidom to parse an xml file and it threw an error indicating that the data is not well formed. I figured out that some of the pages have characters like <code>ไอเฟล &amp;</code>, causing the parser to hiccup. Is there an easy way to clean the file before I start parsing it? Righ...
1
2010-03-30T14:02:59Z
2,545,916
<p>If you do need the data with the strange characters you could, in stead of just stripping them, convert them to codes the XML parser can understand.</p> <p>You could have a look at the <a href="http://docs.python.org/library/unicodedata.html#unicodedata.normalize" rel="nofollow">unicodedata</a> package, especially ...
0
2010-03-30T14:19:55Z
[ "python", "xml" ]
Cleaning an XML file in Python before parsing
2,545,783
<p>I'm using minidom to parse an xml file and it threw an error indicating that the data is not well formed. I figured out that some of the pages have characters like <code>ไอเฟล &amp;</code>, causing the parser to hiccup. Is there an easy way to clean the file before I start parsing it? Righ...
1
2010-03-30T14:02:59Z
2,546,454
<p>It looks like you're dealing with data which are saved with some kind of encoding "as if" they were ASCII. XML file should normally be UTF8, and SAX (the underlying parser used by minidom) should handle that, so it looks like something's wrong in that part of the processing chain. Instead of focusing on "cleaning u...
0
2010-03-30T15:26:31Z
[ "python", "xml" ]
Optimization Techniques in Python
2,545,820
<p>Recently i have developed a billing application for my company with Python/Django. For few months everything was fine but now i am observing that the performance is dropping because of more and more users using that applications. Now the problem is that the application is now very critical for the finance team. Now ...
9
2010-03-30T14:07:48Z
2,545,889
<p>As I said in comment, you must start by finding what part of your code is slow.</p> <p>Nobody can help you without this information.</p> <p>You can profile your code with the <a href="http://docs.python.org/library/profile.html" rel="nofollow">Python profilers</a> then go back to us with the result.</p> <p>If it'...
11
2010-03-30T14:14:43Z
[ "python" ]
Optimization Techniques in Python
2,545,820
<p>Recently i have developed a billing application for my company with Python/Django. For few months everything was fine but now i am observing that the performance is dropping because of more and more users using that applications. Now the problem is that the application is now very critical for the finance team. Now ...
9
2010-03-30T14:07:48Z
2,545,940
<p>ok, not entirely to the point, but before you go and start fixing it, make sure everyone understands the situation. it seems to me that they're putting some pressure on you to fix the "problem".</p> <p>well first of all, when you wrote the application, have they specified the performance requirements? did they tell...
6
2010-03-30T14:23:18Z
[ "python" ]
Optimization Techniques in Python
2,545,820
<p>Recently i have developed a billing application for my company with Python/Django. For few months everything was fine but now i am observing that the performance is dropping because of more and more users using that applications. Now the problem is that the application is now very critical for the finance team. Now ...
9
2010-03-30T14:07:48Z
2,546,693
<p>For the type of application you are describing (a web application probably backed by a database) your performance problems are <strong>unlikely to be language specific</strong>. They are far more likely to <strong>stem from design or architecture issues</strong>, though they could be simple coding problems too.</p> ...
0
2010-03-30T16:01:59Z
[ "python" ]
Optimization Techniques in Python
2,545,820
<p>Recently i have developed a billing application for my company with Python/Django. For few months everything was fine but now i am observing that the performance is dropping because of more and more users using that applications. Now the problem is that the application is now very critical for the finance team. Now ...
9
2010-03-30T14:07:48Z
2,546,955
<p>A surprising feature of Python is that the pythonic code is quite efficient... So a few general hints:</p> <ul> <li>Use built-ins and standard functions whenever possible, they're already quite well optimized.</li> <li>Try to use lazy generators instead one-off temporary lists.</li> <li>Use numpy for vector arithme...
3
2010-03-30T16:42:49Z
[ "python" ]
Optimization Techniques in Python
2,545,820
<p>Recently i have developed a billing application for my company with Python/Django. For few months everything was fine but now i am observing that the performance is dropping because of more and more users using that applications. Now the problem is that the application is now very critical for the finance team. Now ...
9
2010-03-30T14:07:48Z
2,546,996
<p>before you can "fix" something you need to know what is "broken". In software development that means profiling, profiling, profiling. Did I mention profiling. Without profiling you don't know where CPU cycles and wall clock time is going. Like others have said to get any more useful information you need to post the ...
2
2010-03-30T16:48:38Z
[ "python" ]
Optimization Techniques in Python
2,545,820
<p>Recently i have developed a billing application for my company with Python/Django. For few months everything was fine but now i am observing that the performance is dropping because of more and more users using that applications. Now the problem is that the application is now very critical for the finance team. Now ...
9
2010-03-30T14:07:48Z
2,547,053
<p>You may be interested in <a href="http://wiki.python.org/moin/PythonSpeed/PerformanceTips" rel="nofollow">this document</a> I've found some time ago. As personal advice, be as more pythonic as you can: <strong>lazy evaluation</strong> is the keyword, so learn to use iterators and generators.</p>
1
2010-03-30T16:58:30Z
[ "python" ]
Optimization Techniques in Python
2,545,820
<p>Recently i have developed a billing application for my company with Python/Django. For few months everything was fine but now i am observing that the performance is dropping because of more and more users using that applications. Now the problem is that the application is now very critical for the finance team. Now ...
9
2010-03-30T14:07:48Z
2,547,057
<p><a href="http://wiki.python.org/moin/PythonSpeed/PerformanceTips" rel="nofollow">http://wiki.python.org/moin/PythonSpeed/PerformanceTips</a></p> <p>I optimized some python code a while back, the most surprising thing to me was how much each function call costs. If you minimize function calls or replace loops with...
0
2010-03-30T16:59:10Z
[ "python" ]
Optimization Techniques in Python
2,545,820
<p>Recently i have developed a billing application for my company with Python/Django. For few months everything was fine but now i am observing that the performance is dropping because of more and more users using that applications. Now the problem is that the application is now very critical for the finance team. Now ...
9
2010-03-30T14:07:48Z
2,547,070
<p>There are some great suggestions here… So let me suggest an implementation detail. I have found the <code>runprofileserver</code> command found in <a href="http://code.google.com/p/django-command-extensions/" rel="nofollow">django-command-extensions</a> very convenient for profiling my Django code.</p>
0
2010-03-30T17:01:08Z
[ "python" ]
Optimization Techniques in Python
2,545,820
<p>Recently i have developed a billing application for my company with Python/Django. For few months everything was fine but now i am observing that the performance is dropping because of more and more users using that applications. Now the problem is that the application is now very critical for the finance team. Now ...
9
2010-03-30T14:07:48Z
2,547,076
<p>I am not sure if this would solve the problem but you should have a look at <a href="http://psyco.sourceforge.net/" rel="nofollow">psyco</a></p>
0
2010-03-30T17:02:00Z
[ "python" ]
How to synchronize a python dict with multiprocessing
2,545,961
<p>I am using Python 2.6 and the multiprocessing module for multi-threading. Now I would like to have a synchronized dict (where the only atomic operation I really need is the += operator on a value). </p> <p>Should I wrap the dict with a multiprocessing.sharedctypes.synchronized() call? Or is another way the way to g...
21
2010-03-30T14:26:33Z
2,546,152
<p>Is there a reason that the dictionary needs to be shared in the first place? Could you have each thread maintain their own instance of a dictionary and either merge at the end of the thread processing or periodically use a call-back to merge copies of the individual thread dictionaries together? </p> <p>I don't kno...
3
2010-03-30T14:51:01Z
[ "python", "multiprocessing", "dictionary" ]
How to synchronize a python dict with multiprocessing
2,545,961
<p>I am using Python 2.6 and the multiprocessing module for multi-threading. Now I would like to have a synchronized dict (where the only atomic operation I really need is the += operator on a value). </p> <p>Should I wrap the dict with a multiprocessing.sharedctypes.synchronized() call? Or is another way the way to g...
21
2010-03-30T14:26:33Z
2,546,355
<p>I would dedicate a separate process to maintaining the "shared dict": just use e.g. <a href="http://docs.python.org/library/xmlrpclib.html?highlight=xmlrpclib#module-xmlrpclib" rel="nofollow">xmlrpclib</a> to make that tiny amount of code available to the other processes, exposing via xmlrpclib e.g. a function takin...
3
2010-03-30T15:16:10Z
[ "python", "multiprocessing", "dictionary" ]
How to synchronize a python dict with multiprocessing
2,545,961
<p>I am using Python 2.6 and the multiprocessing module for multi-threading. Now I would like to have a synchronized dict (where the only atomic operation I really need is the += operator on a value). </p> <p>Should I wrap the dict with a multiprocessing.sharedctypes.synchronized() call? Or is another way the way to g...
21
2010-03-30T14:26:33Z
2,546,756
<p>In response to an appropriate solution to the concurrent-write issue. I did very quick research and found that <a href="http://effbot.org/zone/thread-synchronization.htm" rel="nofollow">this article</a> is suggesting a lock/semaphore solution. (<a href="http://effbot.org/zone/thread-synchronization.htm" rel="nofollo...
3
2010-03-30T16:12:04Z
[ "python", "multiprocessing", "dictionary" ]
How to synchronize a python dict with multiprocessing
2,545,961
<p>I am using Python 2.6 and the multiprocessing module for multi-threading. Now I would like to have a synchronized dict (where the only atomic operation I really need is the += operator on a value). </p> <p>Should I wrap the dict with a multiprocessing.sharedctypes.synchronized() call? Or is another way the way to g...
21
2010-03-30T14:26:33Z
2,556,974
<h2>Intro</h2> <p>There seems to be a lot of arm-chair suggestions and no working examples. None of the answers listed here even suggest using multiprocessing and this is quite a bit disappointing and disturbing. As python lovers we should support our built-in libraries, and while parallel processing and synchroniza...
47
2010-03-31T22:39:23Z
[ "python", "multiprocessing", "dictionary" ]
How should I use random.jumpahead in Python
2,546,039
<p>I have a application that does a certain experiment 1000 times (multi-threaded, so that multiple experiments are done at the same time). Every experiment needs appr. 50.000 random.random() calls.</p> <p>What is the best approach to get this really random. I could copy a random object to every experiment and do than...
3
2010-03-30T14:35:54Z
2,546,266
<p><code>jumpahead(1)</code> is indeed sufficient (and identical to <code>jumpahead(50000)</code> or any other such call, in the current implementation of <code>random</code> -- I believe that came in at the same time as the Mersenne Twister based implementation). So use whatever argument fits in well with your progra...
3
2010-03-30T15:06:05Z
[ "python", "random" ]
How should I use random.jumpahead in Python
2,546,039
<p>I have a application that does a certain experiment 1000 times (multi-threaded, so that multiple experiments are done at the same time). Every experiment needs appr. 50.000 random.random() calls.</p> <p>What is the best approach to get this really random. I could copy a random object to every experiment and do than...
3
2010-03-30T14:35:54Z
2,546,388
<blockquote> <p>I could copy a random object to every experiment and do than a jumpahead of 50.000 * expid. </p> </blockquote> <p>Approximately correct. Each thread gets their own <code>Random</code> instance.</p> <p>Seed all of them to the same seed value. Use a constant to test, use /dev/random when you "run fo...
5
2010-03-30T15:19:30Z
[ "python", "random" ]
How should I use random.jumpahead in Python
2,546,039
<p>I have a application that does a certain experiment 1000 times (multi-threaded, so that multiple experiments are done at the same time). Every experiment needs appr. 50.000 random.random() calls.</p> <p>What is the best approach to get this really random. I could copy a random object to every experiment and do than...
3
2010-03-30T14:35:54Z
2,546,490
<p>Per the <a href="http://docs.python.org/library/random.html" rel="nofollow">random module docs</a> at python.org:</p> <p>"You can instantiate your own instances of Random to get generators that don’t share state."</p> <p>And there's also a relevant-looking note on jumpahead, as you mention. But the guarantees t...
0
2010-03-30T15:31:18Z
[ "python", "random" ]
How should I use random.jumpahead in Python
2,546,039
<p>I have a application that does a certain experiment 1000 times (multi-threaded, so that multiple experiments are done at the same time). Every experiment needs appr. 50.000 random.random() calls.</p> <p>What is the best approach to get this really random. I could copy a random object to every experiment and do than...
3
2010-03-30T14:35:54Z
6,612,374
<p>You shouldn't use that function. There is no proof it can work on Mersenne Twister generator. Indeed, it was <a href="http://bugs.python.org/issue9816#msg115990" rel="nofollow">removed from Python 3 for that reason</a>.</p> <p>For more information about generation of pseudo-random numbers on parallel environments, ...
1
2011-07-07T14:37:26Z
[ "python", "random" ]
Problem with building OpenCV for Python 2.6
2,546,151
<p>I've just downloaded OpenCV's trunk and now I'm trying to build it with MinGW. I read the manual and get .dll's compiled, but that's all - "interfaces/python" contains only some .i and .cmake files. How can I really get new python interface? Where I can find new cv.pyd/libcv.dll.a (because a compiled version from of...
1
2010-03-30T14:50:27Z
2,548,257
<p>Since you downloaded the source from trunk, you will also have to build all of OpenCV before you can use it or the Python wrappers. Have you compiled it?</p> <p>If not, check the directions on <a href="http://opencv.willowgarage.com/wiki/InstallGuide" rel="nofollow">http://opencv.willowgarage.com/wiki/InstallGuide<...
0
2010-03-30T19:58:45Z
[ "python", "opencv" ]
How can I keep the system environments set by a bat file, which called by a python script
2,546,197
<p>I call .bat files in Python to set system environments, and check the system environments were set properly, and then back to run python code, the system environments are changed back to original. How can I solve this problem?</p>
4
2010-03-30T14:55:48Z
2,546,238
<p>Environment settings always happen in the child process and never directly affect the parent process. However you can run (in the same child process that has changed its environment, at the very end of that process) a command (<code>env</code> in Unix-like environment, I believe <code>set</code> in DOS where <code>...
3
2010-03-30T15:01:52Z
[ "python", "windows" ]
How can I keep the system environments set by a bat file, which called by a python script
2,546,197
<p>I call .bat files in Python to set system environments, and check the system environments were set properly, and then back to run python code, the system environments are changed back to original. How can I solve this problem?</p>
4
2010-03-30T14:55:48Z
2,546,289
<p>I suspect that you are calling the batch file from the Python program and then returning to the calling Python code. A child process - in this case your call to the batch file - does not affect the environment of the parent process (your batch file). </p> <p>Batch files that set up an environment are usually writte...
1
2010-03-30T15:08:37Z
[ "python", "windows" ]
Python and App Engine project structure
2,546,199
<p>I am relatively new to python and app engine, and I just finished my first project. It consists of several *.py files (usually py file for every page on the site) and respectively temple files for each py file. In addition, I have one big PY file that has many functions that are common to a lot of pages, in I also d...
6
2010-03-30T14:55:52Z
2,546,244
<p>I usually organize my projects in this way:</p> <pre><code>project main.py README models bar.py foo.py views foolist.hml barlist.hml controllers controller1.py controller2.py api controllerapi.py helpers utilities.py lib extfoo.py db foo....
3
2010-03-30T15:03:03Z
[ "python", "google-app-engine" ]
Python and App Engine project structure
2,546,199
<p>I am relatively new to python and app engine, and I just finished my first project. It consists of several *.py files (usually py file for every page on the site) and respectively temple files for each py file. In addition, I have one big PY file that has many functions that are common to a lot of pages, in I also d...
6
2010-03-30T14:55:52Z
2,546,349
<p>Typically I organize like so:</p> <pre><code>project/ main.py models.py app.yaml index.yaml templates/ main.html foo.html ... styles/ project.css js/ jquery.js project.js images/ icon.png something.jpg </code></pre> <p>And I have all of my handlers in main.py, all of...
3
2010-03-30T15:15:14Z
[ "python", "google-app-engine" ]
Does SQLAlchemy have an equivalent of Django's get_or_create?
2,546,207
<p>I want to get an object from the database if it already exists (based on provided parameters) or create it if it does not.</p> <p>Django's <a href="https://docs.djangoproject.com/en/1.10/ref/models/querysets/#get-or-create" rel="nofollow"><code>get_or_create</code></a> (or <a href="https://github.com/django/django/...
86
2010-03-30T14:57:31Z
2,587,041
<p>That's basically the way to do it, there is no shortcut readily available AFAIK.</p> <p>You could generalize it ofcourse:</p> <pre><code>def get_or_create(session, model, defaults=None, **kwargs): instance = session.query(model).filter_by(**kwargs).first() if instance: return instance, False el...
47
2010-04-06T17:47:06Z
[ "python", "django", "sqlalchemy" ]
Does SQLAlchemy have an equivalent of Django's get_or_create?
2,546,207
<p>I want to get an object from the database if it already exists (based on provided parameters) or create it if it does not.</p> <p>Django's <a href="https://docs.djangoproject.com/en/1.10/ref/models/querysets/#get-or-create" rel="nofollow"><code>get_or_create</code></a> (or <a href="https://github.com/django/django/...
86
2010-03-30T14:57:31Z
6,078,058
<p>Following the solution of @WoLpH, this is the code that worked for me (simple version):</p> <pre><code>def get_or_create(session, model, **kwargs): instance = session.query(model).filter_by(**kwargs).first() if instance: return instance else: instance = model(**kwargs) session.ad...
55
2011-05-20T22:08:41Z
[ "python", "django", "sqlalchemy" ]
Does SQLAlchemy have an equivalent of Django's get_or_create?
2,546,207
<p>I want to get an object from the database if it already exists (based on provided parameters) or create it if it does not.</p> <p>Django's <a href="https://docs.djangoproject.com/en/1.10/ref/models/querysets/#get-or-create" rel="nofollow"><code>get_or_create</code></a> (or <a href="https://github.com/django/django/...
86
2010-03-30T14:57:31Z
16,872,655
<p>I think I was just looking for the same thing. <a href="http://www.sqlalchemy.org/trac/wiki/UsageRecipes/UniqueObject" rel="nofollow" title="this SQLAlchemy recipe">This SQLALchemy recipe</a> does the job nice and elegant.</p>
4
2013-06-01T12:20:48Z
[ "python", "django", "sqlalchemy" ]
Does SQLAlchemy have an equivalent of Django's get_or_create?
2,546,207
<p>I want to get an object from the database if it already exists (based on provided parameters) or create it if it does not.</p> <p>Django's <a href="https://docs.djangoproject.com/en/1.10/ref/models/querysets/#get-or-create" rel="nofollow"><code>get_or_create</code></a> (or <a href="https://github.com/django/django/...
86
2010-03-30T14:57:31Z
21,146,492
<p>I've been playing with this problem and have ended up with a fairly robust solution:</p> <pre class="lang-py prettyprint-override"><code>def get_one_or_create(session, model, create_method='', create_method_kwargs=None, **kwargs...
24
2014-01-15T19:30:23Z
[ "python", "django", "sqlalchemy" ]
Does SQLAlchemy have an equivalent of Django's get_or_create?
2,546,207
<p>I want to get an object from the database if it already exists (based on provided parameters) or create it if it does not.</p> <p>Django's <a href="https://docs.djangoproject.com/en/1.10/ref/models/querysets/#get-or-create" rel="nofollow"><code>get_or_create</code></a> (or <a href="https://github.com/django/django/...
86
2010-03-30T14:57:31Z
26,078,303
<p>The closest semantically is probably:</p> <pre><code>def get_or_create(model, **kwargs): """SqlAlchemy implementation of Django's get_or_create. """ session = Session() instance = session.query(model).filter_by(**kwargs).first() if instance: return instance, False else: insta...
1
2014-09-27T19:22:54Z
[ "python", "django", "sqlalchemy" ]
Does SQLAlchemy have an equivalent of Django's get_or_create?
2,546,207
<p>I want to get an object from the database if it already exists (based on provided parameters) or create it if it does not.</p> <p>Django's <a href="https://docs.djangoproject.com/en/1.10/ref/models/querysets/#get-or-create" rel="nofollow"><code>get_or_create</code></a> (or <a href="https://github.com/django/django/...
86
2010-03-30T14:57:31Z
35,525,730
<p>Depending on the isolation level you adopted, none of the above solutions would work. The best solution I have found is a RAW SQL in the following form:</p> <pre><code>INSERT INTO table(f1, f2, unique_f3) SELECT 'v1', 'v2', 'v3' WHERE NOT EXISTS (SELECT 1 FROM table WHERE f3 = 'v3') </code></pre> <p>This is tran...
0
2016-02-20T16:16:39Z
[ "python", "django", "sqlalchemy" ]
Does SQLAlchemy have an equivalent of Django's get_or_create?
2,546,207
<p>I want to get an object from the database if it already exists (based on provided parameters) or create it if it does not.</p> <p>Django's <a href="https://docs.djangoproject.com/en/1.10/ref/models/querysets/#get-or-create" rel="nofollow"><code>get_or_create</code></a> (or <a href="https://github.com/django/django/...
86
2010-03-30T14:57:31Z
37,419,325
<p>A modified version of erik's excellent <a href="http://stackoverflow.com/a/21146492/678022">answer</a></p> <pre><code>def get_one_or_create(session, model, create_method='', create_method_kwargs=None, **kwargs): try: ...
1
2016-05-24T16:37:23Z
[ "python", "django", "sqlalchemy" ]
Python Process won't call atexit
2,546,276
<p>I'm trying to use <code>atexit</code> in a <code>Process</code>, but unfortunately it doesn't seem to work. Here's some example code:</p> <pre><code>import time import atexit import logging import multiprocessing logging.basicConfig(level=logging.DEBUG) class W(multiprocessing.Process): def run(self): ...
16
2010-03-30T15:07:18Z
2,546,397
<p>As <a href="http://docs.python.org/library/multiprocessing.html?highlight=terminate#multiprocessing.Process.terminate">the docs</a> say, </p> <blockquote> <p>On Unix this is done using the SIGTERM signal; on Windows TerminateProcess() is used. Note that exit handlers and finally clauses, etc., will not be ...
15
2010-03-30T15:20:16Z
[ "python", "multiprocessing", "terminate", "atexit" ]
How can I draw a log-normalized imshow plot with a colorbar representing the raw data in matplotlib
2,546,475
<p>I'm using matplotlib to plot log-normalized images but I would like the original raw image data to be represented in the colorbar rather than the [0-1] interval. I get the feeling there's a more matplotlib'y way of doing this by using some sort of normalization object and not transforming the data beforehand... in ...
11
2010-03-30T15:29:23Z
2,546,622
<p>Yes, there is! Use <code>LogNorm</code>. Here is a code excerpt from a utility that I wrote to display confusion matrices on a log scale.</p> <pre><code>from pylab import figure, cm from matplotlib.colors import LogNorm # C = some matrix f = figure(figsize=(6.2,5.6)) ax = f.add_axes([0.17, 0.02, 0.72, 0.79]) axcolo...
21
2010-03-30T15:52:12Z
[ "python", "matplotlib", "normalize" ]
How can I draw a log-normalized imshow plot with a colorbar representing the raw data in matplotlib
2,546,475
<p>I'm using matplotlib to plot log-normalized images but I would like the original raw image data to be represented in the colorbar rather than the [0-1] interval. I get the feeling there's a more matplotlib'y way of doing this by using some sort of normalization object and not transforming the data beforehand... in ...
11
2010-03-30T15:29:23Z
7,262,746
<p>If you just want the image to be log-normalized (to enhance details), but not the data (to preserve physical values), then you have to apply the transformation on the colormap itself. You can do that with the function cmap_map() given in the cookbook: <a href="http://www.scipy.org/Cookbook/Matplotlib/ColormapTransfo...
5
2011-08-31T20:04:29Z
[ "python", "matplotlib", "normalize" ]
How to update the filename of a Django's FileField instance?
2,546,575
<p>Here a simple django model:</p> <pre><code>class SomeModel(models.Model): title = models.CharField(max_length=100) video = models.FileField(upload_to='video') </code></pre> <p>I would like to save any instance so that the <code>video</code>'s file name would be a valid file name of the <code>title</code>.<...
2
2010-03-30T15:45:43Z
2,547,418
<p>If it just happens during save, as per the <a href="http://docs.djangoproject.com/en/1.1/ref/models/fields/#filefield">docs</a>, you can pass a function to upload_to that will get called with the instance and the original filename and needs to return a string to be used as the filename. Maybe something like:</p> <p...
5
2010-03-30T17:56:44Z
[ "python", "django", "file", "model", "field" ]
Create static instances of a class inside said class in Python
2,546,608
<p>Apologies if I've got the terminology wrong here—I can't think what this particular idiom would be called.</p> <p>I've been trying to create a Python 3 class that statically declares instances of itself inside itself—sort of like an enum would work. Here's a simplified version of the code I wrote:</p> <pre><co...
5
2010-03-30T15:49:41Z
2,546,626
<p>After you defined the class, just add these two lines:</p> <pre><code>Test.A = Test("A") Test.B = Test("B") </code></pre> <p>A class in Python is an object like any other and you can add new variables at any time. You just can't do it inside the class since it's not defined at that time (it will be added to the sy...
7
2010-03-30T15:52:50Z
[ "python" ]
Create static instances of a class inside said class in Python
2,546,608
<p>Apologies if I've got the terminology wrong here—I can't think what this particular idiom would be called.</p> <p>I've been trying to create a Python 3 class that statically declares instances of itself inside itself—sort of like an enum would work. Here's a simplified version of the code I wrote:</p> <pre><co...
5
2010-03-30T15:49:41Z
2,546,668
<p>In Python, a <code>class</code> block isn't just a declaration; it's executed at run time to build the class. Each <code>def</code> inside the class builds a function and binds the name into the class's namespace. For that reason, you can't simply do <code>A = MyClass()</code> directly inside the class block, beca...
1
2010-03-30T15:59:16Z
[ "python" ]
Create static instances of a class inside said class in Python
2,546,608
<p>Apologies if I've got the terminology wrong here—I can't think what this particular idiom would be called.</p> <p>I've been trying to create a Python 3 class that statically declares instances of itself inside itself—sort of like an enum would work. Here's a simplified version of the code I wrote:</p> <pre><co...
5
2010-03-30T15:49:41Z
2,546,692
<p>While the Aaron's answer is the preferred way you can also use metaclasses:</p> <pre><code>&gt;&gt;&gt; class TestMeta(type): ... def __init__(cls, name, bases, dct): ... cls.A = cls() ... cls.B = cls() ... &gt;&gt;&gt; class Test: ... __metaclass__ = TestMeta ... &gt;&gt;&gt; Test &lt;class __main__.Test ...
1
2010-03-30T16:01:59Z
[ "python" ]
Python - animation with matplotlib.pyplot
2,546,780
<p>How can one create animated diagrams using popular matplotlib library? I am particularly interested in animated gifs.</p>
15
2010-03-30T16:16:12Z
2,547,625
<p>The matplotlib docs provide an entire section of examples on <a href="http://matplotlib.sourceforge.net/examples/animation/index.html">animation</a> (see this <a href="http://www.scipy.org/Cookbook/Matplotlib/Animations">scipy</a> tutorial also). Most, however, involve using the various GUI widget backends. There ...
17
2010-03-30T18:28:02Z
[ "python", "matplotlib" ]
Python - animation with matplotlib.pyplot
2,546,780
<p>How can one create animated diagrams using popular matplotlib library? I am particularly interested in animated gifs.</p>
15
2010-03-30T16:16:12Z
22,010,022
<p>This question is kind of old but nevertheless I will answer just in case someone crash here and this can be useful. </p> <p>So nowadays it seems that the best way to go in matplotlib is to use the functionality that they provide:</p> <p><a href="http://matplotlib.org/api/animation_api.html#module-matplotlib.animat...
10
2014-02-25T09:37:06Z
[ "python", "matplotlib" ]
How to handle 'self' argument with Python decorators
2,546,801
<p>I am trying to setup some decorators so that I can do something like:</p> <pre><code>class Ball(object): def __init__(self, owner): self.owner = owner class Example(CommandSource): @command @when(lambda self, ball: ball.owner == self) def throwBall(self, ball): # code to throw the ...
4
2010-03-30T16:19:19Z
2,546,956
<p>Change your <code>CommandSource</code> as follow:</p> <pre><code>class CommandSource(object): def listCommands(self, *args, **kwargs): commands = [] for command in dir(self.__class__): func = getattr(self, command, None) if func == None or getattr(func, 'command', False)...
2
2010-03-30T16:42:53Z
[ "python", "decorator", "dsl" ]
How to handle 'self' argument with Python decorators
2,546,801
<p>I am trying to setup some decorators so that I can do something like:</p> <pre><code>class Ball(object): def __init__(self, owner): self.owner = owner class Example(CommandSource): @command @when(lambda self, ball: ball.owner == self) def throwBall(self, ball): # code to throw the ...
4
2010-03-30T16:19:19Z
2,546,963
<p>You need to pass an instance reference to your <code>validator</code> function:</p> <pre><code>for validator in func.validators: if not validator(self, *args, **kwargs): valid = False break </code></pre>
1
2010-03-30T16:43:32Z
[ "python", "decorator", "dsl" ]
wxPython: Sending a signal to several widgets
2,546,814
<p>I am not even sure how to ask this question. I want something that is like the wxPython event system, but a bit different. I'll try to explain.</p> <p>When there is a certain change in my program (a "tree change", never mind what that is,) I want to send a signal to all the widgets in my program, notifying them tha...
1
2010-03-30T16:21:08Z
2,550,452
<p>You can write your own publish-subscribe mechanism which can be as simple as this:</p> <pre><code>def register(self, callback): self.callbacks.append(callback) def emit(self, eventName): for callback in self.callbacks: callback(eventName) </code></pre> <p>Anybody interested in listening to event ...
6
2010-03-31T04:11:07Z
[ "python", "events", "event-handling", "wxpython", "signals" ]
wxPython: Sending a signal to several widgets
2,546,814
<p>I am not even sure how to ask this question. I want something that is like the wxPython event system, but a bit different. I'll try to explain.</p> <p>When there is a certain change in my program (a "tree change", never mind what that is,) I want to send a signal to all the widgets in my program, notifying them tha...
1
2010-03-30T16:21:08Z
2,560,189
<p>check out the observer design pattern. you need to implement the widgets as an observers . and the signal sender as the subject. so whenever it the subject sends a signal, all the observers will be notified. </p> <p><a href="http://en.wikipedia.org/wiki/Observer_pattern" rel="nofollow"> check this out for more info...
0
2010-04-01T12:14:30Z
[ "python", "events", "event-handling", "wxpython", "signals" ]
Why connection in Python's DB-API does not have "begin" operation?
2,546,926
<p>Working with cursors in mysql-python I used to call "BEGIN;", "COMMIT;", and "ROLLBACK;" explicitly as follows:</p> <pre><code>try: cursor.execute("BEGIN;") # some statements cursor.execute("COMMIT;") except: cursor.execute("ROLLBACK;") </code></pre> <p>then, I found out that the underlying connect...
5
2010-03-30T16:38:54Z
2,547,302
<p>look <a href="http://stackoverflow.com/questions/1219326/how-do-i-do-database-transactions-with-psycopg2-python-db-api">a this previously asked question</a>. Generally the "protocol" to use with transactions is:</p> <pre><code>cursor = conn.cursor() try: cursor.execute(...) except DatabaseError: cursor.roll...
6
2010-03-30T17:39:41Z
[ "python", "sql", "python-db-api" ]
Why connection in Python's DB-API does not have "begin" operation?
2,546,926
<p>Working with cursors in mysql-python I used to call "BEGIN;", "COMMIT;", and "ROLLBACK;" explicitly as follows:</p> <pre><code>try: cursor.execute("BEGIN;") # some statements cursor.execute("COMMIT;") except: cursor.execute("ROLLBACK;") </code></pre> <p>then, I found out that the underlying connect...
5
2010-03-30T16:38:54Z
2,788,237
<p>Decided to answer myself:</p> <p>A <a href="http://groups.google.ru/group/comp.lang.python/browse_thread/thread/80d0bf3bacd47400" rel="nofollow">thread about DB API 2.0 transactions</a> in python-list and the following excerpt from the noticeable book <a href="http://rads.stackoverflow.com/amzn/click/0071592555" re...
3
2010-05-07T11:42:05Z
[ "python", "sql", "python-db-api" ]
Pylibmc: ImportError: dynamic module does not define init function (init_pylibmc)
2,547,117
<pre><code>&gt;&gt;&gt; import pylibmc Traceback (most recent call last): File "&lt;stdin&gt;", line 1, in &lt;module&gt; File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/pylibmc.py", line 55, in &lt;module&gt; import _pylibmc ImportError: dynamic module does not define init ...
0
2010-03-30T17:06:49Z
2,580,007
<p>That's very odd. I (the developer of pylibmc) use Mac OS X 10.6.3 to develop pylibmc, and libmemcached 0.38 should be fine.</p> <p>Try downloading the actual tarball and unpacking it, then:</p> <pre><code>$ sudo python setup.py install --with-libmemcached=/path/to/libmemcached-0.38 (lots of output) $ python -m pyl...
2
2010-04-05T17:56:49Z
[ "python", "memcached", "python-module" ]
Why is python decode replacing more than the invalid bytes from an encoded string?
2,547,262
<p>Trying to decode an invalid encoded utf-8 html page gives different results in python, firefox and chrome.</p> <p>The invalid encoded fragment from test page looks like <code>'PREFIX\xe3\xabSUFFIX'</code></p> <pre><code>&gt;&gt;&gt; fragment = 'PREFIX\xe3\xabSUFFIX' &gt;&gt;&gt; fragment.decode('utf-8', 'strict') ...
24
2010-03-30T17:33:46Z
2,547,364
<p><strong>the 0xE3 byte is one (of the possible) first bytes indicative of a 3-bytes character.</strong></p> <p>Apparently Python's decode logic takes these three bytes and tries to decode them. They turn out to not match an actual code point ("character") and that is why Python produces a UnicodeDecodeError and emi...
8
2010-03-30T17:50:46Z
[ "python", "security", "unicode", "screen-scraping" ]
Why is python decode replacing more than the invalid bytes from an encoded string?
2,547,262
<p>Trying to decode an invalid encoded utf-8 html page gives different results in python, firefox and chrome.</p> <p>The invalid encoded fragment from test page looks like <code>'PREFIX\xe3\xabSUFFIX'</code></p> <pre><code>&gt;&gt;&gt; fragment = 'PREFIX\xe3\xabSUFFIX' &gt;&gt;&gt; fragment.decode('utf-8', 'strict') ...
24
2010-03-30T17:33:46Z
2,547,369
<p>In <code>'PREFIX\xe3\xabSUFFIX'</code>, the <code>\xe3</code> indicates that it and the next two bites form one unicode code point. (<code>\xEy</code> does for all y.) However, <code>\xe3\xabS</code> obviously does not refer to a valid code point. Since Python knows it's <em>supposed</em> to take three bytes, it suc...
4
2010-03-30T17:51:31Z
[ "python", "security", "unicode", "screen-scraping" ]
Why is python decode replacing more than the invalid bytes from an encoded string?
2,547,262
<p>Trying to decode an invalid encoded utf-8 html page gives different results in python, firefox and chrome.</p> <p>The invalid encoded fragment from test page looks like <code>'PREFIX\xe3\xabSUFFIX'</code></p> <pre><code>&gt;&gt;&gt; fragment = 'PREFIX\xe3\xabSUFFIX' &gt;&gt;&gt; fragment.decode('utf-8', 'strict') ...
24
2010-03-30T17:33:46Z
2,547,846
<blockquote> <p>Also, is there any unicode's official recommended way for handling decoding replacements?</p> </blockquote> <p>No. Unicode considers them an error condition and doesn't consider any fallback options. So none of the behaviours above are ‘right’.</p>
0
2010-03-30T18:56:22Z
[ "python", "security", "unicode", "screen-scraping" ]