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
Script to connect to a web page
1,401,941
<p>Looking for a python script that would simply connect to a web page (maybe some querystring parameters).</p> <p>I am going to run this script as a batch job in unix.</p>
1
2009-09-09T20:35:44Z
1,401,955
<p>What are you trying to do? If you're just trying to fetch a web page, <a href="http://en.wikipedia.org/wiki/CURL" rel="nofollow">cURL</a> is a pre-existing (and very common) tool that does exactly that.</p> <p>Basic usage is very simple:</p> <pre><code>curl www.example.com </code></pre>
0
2009-09-09T20:39:39Z
[ "python" ]
Script to connect to a web page
1,401,941
<p>Looking for a python script that would simply connect to a web page (maybe some querystring parameters).</p> <p>I am going to run this script as a batch job in unix.</p>
1
2009-09-09T20:35:44Z
1,401,960
<p>You might want to simply use httplib from the standard library.</p> <pre><code>myConnection = httplib.HTTPConnection('http://www.example.com') </code></pre> <p>you can find the official reference here: <a href="http://docs.python.org/library/httplib.html" rel="nofollow">http://docs.python.org/library/httplib.html<...
0
2009-09-09T20:40:31Z
[ "python" ]
Script to connect to a web page
1,401,941
<p>Looking for a python script that would simply connect to a web page (maybe some querystring parameters).</p> <p>I am going to run this script as a batch job in unix.</p>
1
2009-09-09T20:35:44Z
1,401,972
<p>A simple <a href="http://linux.die.net/man/1/wget" rel="nofollow" title="wget">wget</a> called from a shell script might suffice.</p>
2
2009-09-09T20:42:54Z
[ "python" ]
Script to connect to a web page
1,401,941
<p>Looking for a python script that would simply connect to a web page (maybe some querystring parameters).</p> <p>I am going to run this script as a batch job in unix.</p>
1
2009-09-09T20:35:44Z
1,401,976
<p>Try this:</p> <pre><code>aResp = urllib2.urlopen("http://google.com/"); print aResp.read(); </code></pre>
2
2009-09-09T20:43:30Z
[ "python" ]
Script to connect to a web page
1,401,941
<p>Looking for a python script that would simply connect to a web page (maybe some querystring parameters).</p> <p>I am going to run this script as a batch job in unix.</p>
1
2009-09-09T20:35:44Z
1,402,538
<p>If you need your script to actually function as a user of the site (clicking links, etc.) then you're probably looking for the python mechanize library.</p> <p><a href="http://wwwsearch.sourceforge.net/mechanize/" rel="nofollow">Python Mechanize</a></p>
3
2009-09-09T22:48:05Z
[ "python" ]
Why can't I upload jpg files to my Django app via admin/?
1,402,002
<p>I'm trying to add images to my models in my Django app.</p> <p>models.py</p> <pre><code>class ImageMain(models.Model): product = models.ForeignKey(Product) photo = models.ImageField(upload_to='products') </code></pre> <p>In development mode, every time I try to upload the image via Django admin, I keep gettin...
17
2009-09-09T20:48:09Z
1,402,225
<p>Did you install libjpeg after PIL was already compiled/installed on the system? Maybe it can't find the decoder properly?</p> <p>Here's one set of instructions I found on getting libjpeg and PIL playing nicely on MacOS (see towards the end; looks like you may need to explicitly set the dir of the decoder):</p> <p>...
17
2009-09-09T21:35:09Z
[ "python", "django" ]
Why can't I upload jpg files to my Django app via admin/?
1,402,002
<p>I'm trying to add images to my models in my Django app.</p> <p>models.py</p> <pre><code>class ImageMain(models.Model): product = models.ForeignKey(Product) photo = models.ImageField(upload_to='products') </code></pre> <p>In development mode, every time I try to upload the image via Django admin, I keep gettin...
17
2009-09-09T20:48:09Z
1,404,521
<p>I had this problem although on Linux not Mac, so might not be able to give too specific info. However you might need libjpeg-devel too (if there is a correspondent for Mac).</p> <p>Also make sure to purge your current PIL installation completely from the system. And after you are sure libjpeg is installed properly ...
0
2009-09-10T10:35:04Z
[ "python", "django" ]
Why can't I upload jpg files to my Django app via admin/?
1,402,002
<p>I'm trying to add images to my models in my Django app.</p> <p>models.py</p> <pre><code>class ImageMain(models.Model): product = models.ForeignKey(Product) photo = models.ImageField(upload_to='products') </code></pre> <p>In development mode, every time I try to upload the image via Django admin, I keep gettin...
17
2009-09-09T20:48:09Z
2,682,892
<p>just do <br/> sudo easy_install PIL</p> <p>this will install PIL specific to your os. please make sure that the egg file generated in /usr/local/lib/python2.6/dist-packages/ is having egg information (because when i did the same, egg file was not correct). If not then just rename the PIL-build-specific-name to PIL...
1
2010-04-21T12:39:27Z
[ "python", "django" ]
Why can't I upload jpg files to my Django app via admin/?
1,402,002
<p>I'm trying to add images to my models in my Django app.</p> <p>models.py</p> <pre><code>class ImageMain(models.Model): product = models.ForeignKey(Product) photo = models.ImageField(upload_to='products') </code></pre> <p>In development mode, every time I try to upload the image via Django admin, I keep gettin...
17
2009-09-09T20:48:09Z
4,366,389
<p>I met the same problem in Ubuntu server, then you can fix it by installing libjpeg-dev before PIL.</p> <pre><code>sudo apt-get install libjpeg-dev sudo pip install PIL --upgrade </code></pre> <p>and if you already installed libjpeg-dev after PIL. then you can remove PIL first, and try to reinstall PIL as following...
16
2010-12-06T12:29:47Z
[ "python", "django" ]
Why can't I upload jpg files to my Django app via admin/?
1,402,002
<p>I'm trying to add images to my models in my Django app.</p> <p>models.py</p> <pre><code>class ImageMain(models.Model): product = models.ForeignKey(Product) photo = models.ImageField(upload_to='products') </code></pre> <p>In development mode, every time I try to upload the image via Django admin, I keep gettin...
17
2009-09-09T20:48:09Z
7,287,078
<p>Django is trying to import PIL from a folder called <code>PIL</code>, but PIL installs itself in a folder called e.g. <code>PIL-1.1.7-py2.6-macosx-10.6-universal.egg</code>, so the import fails - which Django (or PIL ?) seem to interpret as corrupt image.</p> <p>A simple symlink</p> <pre><code>host:~ user$ cd /Lib...
0
2011-09-02T17:23:30Z
[ "python", "django" ]
Why can't I upload jpg files to my Django app via admin/?
1,402,002
<p>I'm trying to add images to my models in my Django app.</p> <p>models.py</p> <pre><code>class ImageMain(models.Model): product = models.ForeignKey(Product) photo = models.ImageField(upload_to='products') </code></pre> <p>In development mode, every time I try to upload the image via Django admin, I keep gettin...
17
2009-09-09T20:48:09Z
10,073,020
<p>'python -v' then 'import _imaging' is useful for figuring out where _imaging.so is loaded from. If you reinstall PIL without cleaning out the PIL dir in site-packages you may still be running with an old _imaging.so under the Python package dir. PIL's selftest.py will pass, because you've got a new _imaging.so in yo...
0
2012-04-09T12:14:56Z
[ "python", "django" ]
Why can't I upload jpg files to my Django app via admin/?
1,402,002
<p>I'm trying to add images to my models in my Django app.</p> <p>models.py</p> <pre><code>class ImageMain(models.Model): product = models.ForeignKey(Product) photo = models.ImageField(upload_to='products') </code></pre> <p>In development mode, every time I try to upload the image via Django admin, I keep gettin...
17
2009-09-09T20:48:09Z
11,164,549
<p>I had a similar problem on Ubuntu 11.04. Apparently in Ubuntu 11, it seems that you need libjpeg8-dev, rather than libjpeg or libjpeg62. Thankyou to Guillaumes post <a href="http://gpiot.com/ubuntu-9-10-install-pil-in-virtualenv/" rel="nofollow">http://gpiot.com/ubuntu-9-10-install-pil-in-virtualenv/</a></p>
1
2012-06-22T21:45:04Z
[ "python", "django" ]
Why can't I upload jpg files to my Django app via admin/?
1,402,002
<p>I'm trying to add images to my models in my Django app.</p> <p>models.py</p> <pre><code>class ImageMain(models.Model): product = models.ForeignKey(Product) photo = models.ImageField(upload_to='products') </code></pre> <p>In development mode, every time I try to upload the image via Django admin, I keep gettin...
17
2009-09-09T20:48:09Z
13,053,041
<p>Note, for anyone getting this error with a virtualenv on Ubuntu, <a href="http://ubuntuforums.org/showthread.php?t=1751455" rel="nofollow">this</a> post is helpful.</p> <p>Basically, Ubuntu installs shared objects to locations that pip doesn't know about. In this case, pip expects system libraries to be in /usr/lib...
2
2012-10-24T16:01:56Z
[ "python", "django" ]
Why can't I upload jpg files to my Django app via admin/?
1,402,002
<p>I'm trying to add images to my models in my Django app.</p> <p>models.py</p> <pre><code>class ImageMain(models.Model): product = models.ForeignKey(Product) photo = models.ImageField(upload_to='products') </code></pre> <p>In development mode, every time I try to upload the image via Django admin, I keep gettin...
17
2009-09-09T20:48:09Z
19,587,749
<p>I had a similar problem and i had cleared it with referring below link:</p> <p><a href="http://osqa.sjsoft.com/questions/96/why-is-there-no-jpegpng-decoder-when-i-pip-install-pil-on-ubuntu" rel="nofollow">http://osqa.sjsoft.com/questions/96/why-is-there-no-jpegpng-decoder-when-i-pip-install-pil-on-ubuntu</a></p>
0
2013-10-25T10:48:26Z
[ "python", "django" ]
How do I right-align numeric data in Python?
1,402,048
<p>I have some data that I am displaying in 3 column format, of the form "key: value key: key: value key: value". Here's an example:</p> <pre><code>p: 1 sl: 10 afy: 4 q: 12 lg: 10 kla: 3 r: 0 kl: 10 klw: 3 s: 67 vw: 9 jes: 3 t: 16 uw: 9 skw: 3 u: 47 ug: 9 mjl: 3 v: 37 mj: 8 lza: 3 w: 119 ...
24
2009-09-09T20:56:57Z
1,402,081
<p>In Python 2.5 use rjust (on strings). Also, try to get used to <a href="http://www.diveintopython.net/native_data_types/formatting_strings.html">string formatting</a> in python instead of just concatenating strings. Simple example for rjust and string formatting below:</p> <pre><code>width = 10 str_number = str(ord...
30
2009-09-09T21:03:02Z
[ "python", "string", "text", "formatting" ]
How do I right-align numeric data in Python?
1,402,048
<p>I have some data that I am displaying in 3 column format, of the form "key: value key: key: value key: value". Here's an example:</p> <pre><code>p: 1 sl: 10 afy: 4 q: 12 lg: 10 kla: 3 r: 0 kl: 10 klw: 3 s: 67 vw: 9 jes: 3 t: 16 uw: 9 skw: 3 u: 47 ug: 9 mjl: 3 v: 37 mj: 8 lza: 3 w: 119 ...
24
2009-09-09T20:56:57Z
1,402,086
<p>If you know aa upper bound for your numbers, you can format with <code>"%&lt;lenght&gt;d" % n</code>. Given all those calculations are done and in a list of (char, num):</p> <pre><code>mapping = ((chr(i+ord('a')), singleArray[i]), (doubleArray[i][0],doubleArray[i][1]), (tripleArray[i][0],tri...
3
2009-09-09T21:04:01Z
[ "python", "string", "text", "formatting" ]
How do I right-align numeric data in Python?
1,402,048
<p>I have some data that I am displaying in 3 column format, of the form "key: value key: key: value key: value". Here's an example:</p> <pre><code>p: 1 sl: 10 afy: 4 q: 12 lg: 10 kla: 3 r: 0 kl: 10 klw: 3 s: 67 vw: 9 jes: 3 t: 16 uw: 9 skw: 3 u: 47 ug: 9 mjl: 3 v: 37 mj: 8 lza: 3 w: 119 ...
24
2009-09-09T20:56:57Z
1,402,091
<p>Use python string formatting: <code>'%widths'</code> where width is an integer</p> <pre><code>&gt;&gt;&gt; '%10s' % 10 ' 10' &gt;&gt;&gt; '%10s' % 100000 ' 100000' </code></pre>
21
2009-09-09T21:04:34Z
[ "python", "string", "text", "formatting" ]
How do I right-align numeric data in Python?
1,402,048
<p>I have some data that I am displaying in 3 column format, of the form "key: value key: key: value key: value". Here's an example:</p> <pre><code>p: 1 sl: 10 afy: 4 q: 12 lg: 10 kla: 3 r: 0 kl: 10 klw: 3 s: 67 vw: 9 jes: 3 t: 16 uw: 9 skw: 3 u: 47 ug: 9 mjl: 3 v: 37 mj: 8 lza: 3 w: 119 ...
24
2009-09-09T20:56:57Z
1,402,453
<p>In python 2.6+ (and it's the standard method in 3), the "preferred" method for string formatting is to use string.format() (the complete docs for which can be found <a href="http://docs.python.org/library/string.html?highlight=string%20common%20string%20operations#format-string-syntax">here</a>). right justification...
59
2009-09-09T22:21:59Z
[ "python", "string", "text", "formatting" ]
How do I right-align numeric data in Python?
1,402,048
<p>I have some data that I am displaying in 3 column format, of the form "key: value key: key: value key: value". Here's an example:</p> <pre><code>p: 1 sl: 10 afy: 4 q: 12 lg: 10 kla: 3 r: 0 kl: 10 klw: 3 s: 67 vw: 9 jes: 3 t: 16 uw: 9 skw: 3 u: 47 ug: 9 mjl: 3 v: 37 mj: 8 lza: 3 w: 119 ...
24
2009-09-09T20:56:57Z
10,718,559
<p>IMO the simplest way would be to:</p> <pre><code>print(str(chr(i+ord('a'))) + ": " + '%#d' % singleArray[i] + "\t" + str(doubleArray[i][0]) + ": " + '%#d' % doubleArray[i][1] + "\t" + str(tripleArray[i][0]) + ": " + '%#d' % tripleArray[i][1] </code></pre> <p>see the <a href="http://docs.python.org/library/...
0
2012-05-23T10:58:42Z
[ "python", "string", "text", "formatting" ]
Fix permissions for rpm/setuptools packaging
1,402,224
<p>I have a project that requires post-install hooks for deployment. My method is to use setuptools to generate the skeleton rpm spec file and tar the source files.</p> <p>The problem is that I don't know how to control permissions with this method. The spec file looks like:</p> <pre><code>%install python setup.py ...
1
2009-09-09T21:34:35Z
1,597,765
<blockquote> <p>%defattr(755,%{user},%{user})</p> </blockquote> <p>That line sets the default permissions, user, and group ownership on all files. You can override the default with something like:</p> <pre><code>%attr(644, &lt;username&gt;, &lt;username&gt;) &lt;/path/to/file&gt; </code></pre> <p>If you want the ...
3
2009-10-20T22:58:34Z
[ "python", "packaging", "setuptools", "rpm" ]
Python on an Real-Time Operation System (RTOS)
1,402,933
<p>I am planning to implement a small-scale data acquisition system on an RTOS platform. (Either on a QNX or an RT-Linux system.)</p> <p>As far as I know, these jobs are performed using C / C++ to get the most out of the system. However I am curious to know and want to learn some experienced people's opinions before I...
13
2009-09-10T01:12:23Z
1,403,078
<p>Our team have done some work combining multiple languages on QNX and had quite a lot of success with the approach. Using python can have a big impact on productivity, and tools like <a href="http://www.swig.org/" rel="nofollow">SWIG</a> and ctypes make it really easy to optimize code and combine features from the di...
3
2009-09-10T02:16:02Z
[ "python", "rtos", "python-stackless", "qnx" ]
Python on an Real-Time Operation System (RTOS)
1,402,933
<p>I am planning to implement a small-scale data acquisition system on an RTOS platform. (Either on a QNX or an RT-Linux system.)</p> <p>As far as I know, these jobs are performed using C / C++ to get the most out of the system. However I am curious to know and want to learn some experienced people's opinions before I...
13
2009-09-10T01:12:23Z
1,403,080
<p>I can't speak for <em>every</em> data acquisition setup out there, but <em>most</em> of them spend most of their "real-time operations" <em>waiting</em> for data to come in -- at least the ones I've worked on.</p> <p>Then when the data <em>does</em> come in, you need to immediately record the event or respond to it...
14
2009-09-10T02:17:38Z
[ "python", "rtos", "python-stackless", "qnx" ]
Python on an Real-Time Operation System (RTOS)
1,402,933
<p>I am planning to implement a small-scale data acquisition system on an RTOS platform. (Either on a QNX or an RT-Linux system.)</p> <p>As far as I know, these jobs are performed using C / C++ to get the most out of the system. However I am curious to know and want to learn some experienced people's opinions before I...
13
2009-09-10T01:12:23Z
1,403,099
<p>Generally the reason advanced against using a high-level language in a real-time context is <em>uncertainty</em> -- when you run a routine one time it might take 100us; the next time you run the same routine it might decide to extend a hash table, calling malloc, then malloc asks the kernel for more memory, which co...
6
2009-09-10T02:28:08Z
[ "python", "rtos", "python-stackless", "qnx" ]
Python on an Real-Time Operation System (RTOS)
1,402,933
<p>I am planning to implement a small-scale data acquisition system on an RTOS platform. (Either on a QNX or an RT-Linux system.)</p> <p>As far as I know, these jobs are performed using C / C++ to get the most out of the system. However I am curious to know and want to learn some experienced people's opinions before I...
13
2009-09-10T01:12:23Z
2,953,750
<p>One important note: Python for QNX is generally available only for x86.</p> <p>I'm sure you can compile it for ppc and other archs, but that's not going to work out of the box.</p>
0
2010-06-01T22:12:53Z
[ "python", "rtos", "python-stackless", "qnx" ]
Python on an Real-Time Operation System (RTOS)
1,402,933
<p>I am planning to implement a small-scale data acquisition system on an RTOS platform. (Either on a QNX or an RT-Linux system.)</p> <p>As far as I know, these jobs are performed using C / C++ to get the most out of the system. However I am curious to know and want to learn some experienced people's opinions before I...
13
2009-09-10T01:12:23Z
15,011,981
<p>I've built several all-Python soft real-time (RT) systems, with primary cycle times from 1 ms to 1 second. There are some basic strategies and tactics I've learned along the way:</p> <ol> <li><p>Use threading/multiprocessing <strong><em>only</em></strong> to offload non-RT work from the primary thread, where queue...
16
2013-02-21T20:52:00Z
[ "python", "rtos", "python-stackless", "qnx" ]
Setting up/Inserting into Many-to-Many Database with Python, SQLALchemy, Sqlite
1,403,084
<p>I am learning Python, and as a first project am taking Twitter RSS feeds, parsing the data, and inserting the data into a sqlite database. I have been able to successfully parse each feed entry into a <em>content</em> variable (e.g., "You should buy low..."), a <em>url</em> variable (e.g., u'<a href="http://petes2ce...
7
2009-09-10T02:20:11Z
1,404,379
<p>First, you should use the SQLAlchemy SQL builder for the inserts to give SQLAlcehemy more insight into what you're doing.</p> <pre><code> result = conn.execute(RSSEntries.insert(), {'feed_id': id, 'short_url': tinyurl, 'content': content, 'hashtags': hashtags, 'date': date}) entry_id = result.last_insert_i...
4
2009-09-10T09:59:20Z
[ "python", "sqlite", "insert", "sqlalchemy", "many-to-many" ]
Python - IronPython dilemma
1,403,103
<p>I'm starting to study Python, and for now I like it very much. But, if you could just answer a few questions for me, which have been troubling me, and I can't find any definite answers to them:</p> <ol> <li><p>What is the relationship between Python's C implementation (main version from python.org) and IronPython, ...
15
2009-09-10T02:30:15Z
1,403,118
<p>1) The language implemented by CPython and IronPython are the same, or at most a version or two apart. This is nothing like the situation with Java and Javascript, which are two completely different languages given similar names by some bone-headed marketing decision.</p> <p>2) 3rd-party libraries implemented in C...
1
2009-09-10T02:39:10Z
[ "python", "excel", "vba", "ironpython", "python.net" ]
Python - IronPython dilemma
1,403,103
<p>I'm starting to study Python, and for now I like it very much. But, if you could just answer a few questions for me, which have been troubling me, and I can't find any definite answers to them:</p> <ol> <li><p>What is the relationship between Python's C implementation (main version from python.org) and IronPython, ...
15
2009-09-10T02:30:15Z
1,403,131
<ol> <li>CPython is implemented by C for corresponding platform, such as Windows, Linux or Unix; IronPython is implemented by C# and Windows .Net Framework, so it can only run on Windows Platform with .Net Framework. For gramma, both are same. But we cannot say they are one same language. IronPython can use .Net Framew...
0
2009-09-10T02:44:29Z
[ "python", "excel", "vba", "ironpython", "python.net" ]
Python - IronPython dilemma
1,403,103
<p>I'm starting to study Python, and for now I like it very much. But, if you could just answer a few questions for me, which have been troubling me, and I can't find any definite answers to them:</p> <ol> <li><p>What is the relationship between Python's C implementation (main version from python.org) and IronPython, ...
15
2009-09-10T02:30:15Z
1,403,134
<p>1) IronPython and CPython share nearly identical language syntax. There is very little difference between them. Transitioning should be trivial.</p> <p>2) The libraries in IronPython are very different than CPython. The <strong>Python</strong> libraries are a fair bit behind - quite a few of the CPython-accessib...
18
2009-09-10T02:46:03Z
[ "python", "excel", "vba", "ironpython", "python.net" ]
Python - IronPython dilemma
1,403,103
<p>I'm starting to study Python, and for now I like it very much. But, if you could just answer a few questions for me, which have been troubling me, and I can't find any definite answers to them:</p> <ol> <li><p>What is the relationship between Python's C implementation (main version from python.org) and IronPython, ...
15
2009-09-10T02:30:15Z
1,403,346
<blockquote> <p>What is the relationship between Python's C implementation (main version from python.org) and IronPython, in terms of language compatibility ? Is it the same language, and do I by learning one, will be able to smoothly cross to another, or is it Java to JavaScript ?</p> </blockquote> <p...
11
2009-09-10T04:24:42Z
[ "python", "excel", "vba", "ironpython", "python.net" ]
Python - IronPython dilemma
1,403,103
<p>I'm starting to study Python, and for now I like it very much. But, if you could just answer a few questions for me, which have been troubling me, and I can't find any definite answers to them:</p> <ol> <li><p>What is the relationship between Python's C implementation (main version from python.org) and IronPython, ...
15
2009-09-10T02:30:15Z
1,410,705
<ol> <li>IronPython version 2.0.2, the current release, supports Python 2.5 syntax. With the next release, 2.6, which is expected sometime over the next month or so (though I'm not sure the team have set a hard release date; here's the <a href="http://ironpython.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=2735...
2
2009-09-11T12:56:36Z
[ "python", "excel", "vba", "ironpython", "python.net" ]
Error using python doctest
1,403,408
<p>I try to use doctest from example from <a href="http://docs.python.org/library/doctest.html" rel="nofollow">http://docs.python.org/library/doctest.html</a></p> <p>But when I run</p> <pre><code>python example.py -v </code></pre> <p>I get this</p> <pre><code>Traceback (most recent call last): File "example.py", ...
1
2009-09-10T04:44:10Z
1,403,419
<p>Try inserting a </p> <pre><code>print doctest, dir(doctest) </code></pre> <p>before line 61. This will tell you the location of the doctest module, and what attributes it has. You can do this to make sure that there's nothing wrong with your doctest module.</p>
0
2009-09-10T04:50:21Z
[ "python", "doctest" ]
Error using python doctest
1,403,408
<p>I try to use doctest from example from <a href="http://docs.python.org/library/doctest.html" rel="nofollow">http://docs.python.org/library/doctest.html</a></p> <p>But when I run</p> <pre><code>python example.py -v </code></pre> <p>I get this</p> <pre><code>Traceback (most recent call last): File "example.py", ...
1
2009-09-10T04:44:10Z
1,403,514
<p>Clearly the <code>doctest</code> module object you have at hand at that point is NOT the normal, unadulterated one you get from an <code>import doctest</code> from the standard library. Printing <code>doctest.__file__</code> (and <code>sys.stdout.flush()</code>ing after that, just to make sure you do get to see the...
5
2009-09-10T05:30:47Z
[ "python", "doctest" ]
"deprecated" status on Google App Engine Django
1,403,413
<p>I'm looking at <a href="http://code.google.com/p/google-app-engine-django/" rel="nofollow">Google App Engine Django</a> on google code but the latest release (May 15/09) has been <em>deprecated</em>.</p> <p>I'd like to know why that is? Are they discouraging us from using it? What deprecated it? Is there a bette...
0
2009-09-10T04:46:11Z
1,403,476
<p>None of the packaged downloads are recommended by the project's owners -- <strong>deprecated</strong> basically means the same thing as "<strong>NOT</strong> recommended". There have been several changes since the May 15 upload of the last (now-deprecated) downloads, and I imagine the project owners are working to g...
4
2009-09-10T05:11:50Z
[ "python", "google-app-engine" ]
Confused about making a CSV file into a ZIP file in django
1,403,438
<p>I have a view that takes data from my site and then makes it into a zip compressed csv file. Here is my working code sans zip:</p> <pre><code>def backup_to_csv(request): response = HttpResponse(mimetype='text/csv') response['Content-Disposition'] = 'attachment; filename=backup.csv' writer = csv.writer(...
2
2009-09-10T04:57:22Z
1,403,508
<p>Note how, in the working case, you <code>return response</code>... and in the NON-working case you return <code>z</code>, which is <strong>NOT</strong> an <code>HttpResponse</code> of course (while it should be!).</p> <p>So: use your <code>csv_writer</code> NOT on <code>response</code> but on a temporary file; zip ...
5
2009-09-10T05:27:37Z
[ "python", "django", "zipfile" ]
Confused about making a CSV file into a ZIP file in django
1,403,438
<p>I have a view that takes data from my site and then makes it into a zip compressed csv file. Here is my working code sans zip:</p> <pre><code>def backup_to_csv(request): response = HttpResponse(mimetype='text/csv') response['Content-Disposition'] = 'attachment; filename=backup.csv' writer = csv.writer(...
2
2009-09-10T04:57:22Z
1,403,694
<p>OK I got it. Here is my new function:</p> <pre><code>def backup_to_csv(request): output = StringIO.StringIO() ## temp output file writer = csv.writer(output, dialect='excel') #code for writing csv file go here... response = HttpResponse(mimetype='application/zip') response['Content-Dispositio...
5
2009-09-10T06:37:31Z
[ "python", "django", "zipfile" ]
Confused about making a CSV file into a ZIP file in django
1,403,438
<p>I have a view that takes data from my site and then makes it into a zip compressed csv file. Here is my working code sans zip:</p> <pre><code>def backup_to_csv(request): response = HttpResponse(mimetype='text/csv') response['Content-Disposition'] = 'attachment; filename=backup.csv' writer = csv.writer(...
2
2009-09-10T04:57:22Z
39,086,064
<pre><code>zipfile.ZipFile(response,'w') </code></pre> <p>doesn't seem to work in python 2.7.9. The <strong><em>response</em></strong> is a <strong>django.HttpResponse</strong> object (which is said to be file-like) but it gives an error <em>"HttpResponse object does not have an attribute 'seek'</em>. When the same c...
0
2016-08-22T18:09:21Z
[ "python", "django", "zipfile" ]
Combine tab-separated value (TSV) files into an Excel 2007 (XLSX) spreadsheet
1,403,468
<p>I need to combine several tab-separated value (TSV) files into an Excel 2007 (XLSX) spreadsheet, preferably using Python. There is not much cleverness needed in combining them - just copying each TSV file onto a separate sheet in Excel will do. Of course, the data needs to be split into columns and rows same as Exce...
1
2009-09-10T05:08:17Z
1,403,553
<p>Looks like <a href="http://pypi.python.org/pypi/xlwt" rel="nofollow">xlwt</a> may serve your needs -- you can read each TSV file with Python's standard library <a href="http://docs.python.org/library/csv.html" rel="nofollow">csv</a> module (which DOES do tab-separated as well as comma-separated etc, don't worry!-) a...
2
2009-09-10T05:43:52Z
[ "python", "excel", "excel-2007" ]
Combine tab-separated value (TSV) files into an Excel 2007 (XLSX) spreadsheet
1,403,468
<p>I need to combine several tab-separated value (TSV) files into an Excel 2007 (XLSX) spreadsheet, preferably using Python. There is not much cleverness needed in combining them - just copying each TSV file onto a separate sheet in Excel will do. Of course, the data needs to be split into columns and rows same as Exce...
1
2009-09-10T05:08:17Z
1,403,561
<p>The best python module for directly creating Excel files is <a href="http://pypi.python.org/pypi/xlwt" rel="nofollow"><code>xlwt</code></a>, but it doesn't support XLSX.</p> <p>As I see it, your options are:</p> <ol> <li>If you only have "several", you could just do it by hand.</li> <li>Use <code>pythonwin</code> ...
1
2009-09-10T05:45:58Z
[ "python", "excel", "excel-2007" ]
Combine tab-separated value (TSV) files into an Excel 2007 (XLSX) spreadsheet
1,403,468
<p>I need to combine several tab-separated value (TSV) files into an Excel 2007 (XLSX) spreadsheet, preferably using Python. There is not much cleverness needed in combining them - just copying each TSV file onto a separate sheet in Excel will do. Of course, the data needs to be split into columns and rows same as Exce...
1
2009-09-10T05:08:17Z
1,404,510
<p>Note that Excel 2007 will quite happily read "legacy" XLS files (those written by Excel 97-2003 and by xlwt). You need XLSX files because .....?</p> <p>If you want to go with the defaults that Excel will choose when deciding whether each piece of your data is a number, a date, or some text, use pythonwin to drive E...
1
2009-09-10T10:31:36Z
[ "python", "excel", "excel-2007" ]
Efficient way to determine whether a particular function is on the stack in Python
1,403,471
<p>For debugging, it is often useful to tell if a particular function is higher up on the call stack. For example, we often only want to run debugging code when a certain function called us.</p> <p>One solution is to examine all of the stack entries higher up, but it this is in a function that is deep in the stack and...
3
2009-09-10T05:11:09Z
1,403,485
<p>Unless the function you're aiming for does something very special to mark "one instance of me is active on the stack" (IOW: if the function is pristine and untouchable and can't possibly be made aware of this peculiar need of yours), there is no conceivable alternative to walking frame by frame up the stack until yo...
8
2009-09-10T05:16:11Z
[ "python", "callstack" ]
Efficient way to determine whether a particular function is on the stack in Python
1,403,471
<p>For debugging, it is often useful to tell if a particular function is higher up on the call stack. For example, we often only want to run debugging code when a certain function called us.</p> <p>One solution is to examine all of the stack entries higher up, but it this is in a function that is deep in the stack and...
3
2009-09-10T05:11:09Z
1,403,619
<p>I don't really like this approach, but here's a fixed-up version of what you were doing:</p> <pre><code>from collections import defaultdict import threading functions_on_stack = threading.local() def record_function_on_stack(f): def wrapped(*args, **kwargs): if not getattr(functions_on_stack, "stacks",...
1
2009-09-10T06:13:49Z
[ "python", "callstack" ]
In bash, what is the simplest way to configure lighttpd to call a local python script based on a particular URL?
1,403,672
<p>In bash, what is the simplest way to configure lighttpd to call a local python script while passing any query string or name-value pairs included with the URL as a command line option for the local python app to parse? </p> <pre><code>Example: www.myapp.com/sendtopython/app1.py?Foo=Bar results in the following occu...
0
2009-09-10T06:32:00Z
1,404,520
<p>Mh, for one thing I wouldn't mess with the install script, but run it once and then edit the resulting lighttpd configuration file (webconsole.conf in your case).</p> <p>You then need to register Python scripts for CGI, like is done for Perl in the install script. You could add a line</p> <pre><code>cgi.assign = (...
3
2009-09-10T10:35:02Z
[ "python", "bash", "lighttpd" ]
Pythonic way to return list of every n'th item in a larger list
1,403,674
<p>Say we have a list of numbers from zero to 1000. Is there a pythonic/efficient way to produce a list of the first and every subsequent 10th item? ie. [0, 10, 20, 30 ...]</p> <p>Yes I can do this using a for loop but I'm wondering if there is a neater way to do this, perhaps even in one line?</p>
72
2009-09-10T06:32:29Z
1,403,693
<pre><code>&gt;&gt;&gt; l = range(165) &gt;&gt;&gt; l[0::10] [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160] </code></pre> <p>EDIT: just for fun, a little timing comparison (ignoring the boundary condition):</p> <pre><code>$ python -m timeit -s "l = range(1000)" "l1 = [x for x in l if x % 1...
136
2009-09-10T06:37:28Z
[ "list", "python" ]
Pythonic way to return list of every n'th item in a larger list
1,403,674
<p>Say we have a list of numbers from zero to 1000. Is there a pythonic/efficient way to produce a list of the first and every subsequent 10th item? ie. [0, 10, 20, 30 ...]</p> <p>Yes I can do this using a for loop but I'm wondering if there is a neater way to do this, perhaps even in one line?</p>
72
2009-09-10T06:32:29Z
1,403,696
<pre><code>existing_list = range(0, 1001) filtered_list = [i for i in existing_list if i % 10 == 0] </code></pre>
0
2009-09-10T06:37:48Z
[ "list", "python" ]
Pythonic way to return list of every n'th item in a larger list
1,403,674
<p>Say we have a list of numbers from zero to 1000. Is there a pythonic/efficient way to produce a list of the first and every subsequent 10th item? ie. [0, 10, 20, 30 ...]</p> <p>Yes I can do this using a for loop but I'm wondering if there is a neater way to do this, perhaps even in one line?</p>
72
2009-09-10T06:32:29Z
1,403,697
<p>List comprehensions are exactly made for that:</p> <pre><code>smaller_list = [x for x in range(100001) if x % 10 == 0] </code></pre> <p>You can get more info about them in the python official documentation: <a href="http://docs.python.org/tutorial/datastructures.html#list-comprehensions" rel="nofollow">http://docs...
-8
2009-09-10T06:37:55Z
[ "list", "python" ]
Pythonic way to return list of every n'th item in a larger list
1,403,674
<p>Say we have a list of numbers from zero to 1000. Is there a pythonic/efficient way to produce a list of the first and every subsequent 10th item? ie. [0, 10, 20, 30 ...]</p> <p>Yes I can do this using a for loop but I'm wondering if there is a neater way to do this, perhaps even in one line?</p>
72
2009-09-10T06:32:29Z
1,403,698
<p>You can use the slice operator like this: </p> <pre><code>l = [1,2,3,4,5] l2 = l[::2] # get subsequent 2nd item </code></pre>
16
2009-09-10T06:37:59Z
[ "list", "python" ]
Pythonic way to return list of every n'th item in a larger list
1,403,674
<p>Say we have a list of numbers from zero to 1000. Is there a pythonic/efficient way to produce a list of the first and every subsequent 10th item? ie. [0, 10, 20, 30 ...]</p> <p>Yes I can do this using a for loop but I'm wondering if there is a neater way to do this, perhaps even in one line?</p>
72
2009-09-10T06:32:29Z
1,403,703
<p>From manual: <code>s[i:j:k] slice of s from i to j with step k</code></p> <pre><code>li = range(100); sub = li[0::10] &gt;&gt;&gt; sub [0, 10, 20, 30, 40, 50, 60, 70, 80, 90] </code></pre>
8
2009-09-10T06:39:50Z
[ "list", "python" ]
Pythonic way to return list of every n'th item in a larger list
1,403,674
<p>Say we have a list of numbers from zero to 1000. Is there a pythonic/efficient way to produce a list of the first and every subsequent 10th item? ie. [0, 10, 20, 30 ...]</p> <p>Yes I can do this using a for loop but I'm wondering if there is a neater way to do this, perhaps even in one line?</p>
72
2009-09-10T06:32:29Z
1,403,706
<pre><code>newlist = oldlist[::10] </code></pre> <p>This picks out every 10th element of the list.</p>
8
2009-09-10T06:42:24Z
[ "list", "python" ]
Pythonic way to return list of every n'th item in a larger list
1,403,674
<p>Say we have a list of numbers from zero to 1000. Is there a pythonic/efficient way to produce a list of the first and every subsequent 10th item? ie. [0, 10, 20, 30 ...]</p> <p>Yes I can do this using a for loop but I'm wondering if there is a neater way to do this, perhaps even in one line?</p>
72
2009-09-10T06:32:29Z
1,404,145
<p>Here is a better implementation of an "every 10th item" list comprehension, that does not use the list contents as part of the membership test:</p> <pre><code>&gt;&gt;&gt; l = range(165) &gt;&gt;&gt; [ item for i,item in enumerate(l) if i%10==0 ] [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150,...
1
2009-09-10T08:50:20Z
[ "list", "python" ]
Pythonic way to return list of every n'th item in a larger list
1,403,674
<p>Say we have a list of numbers from zero to 1000. Is there a pythonic/efficient way to produce a list of the first and every subsequent 10th item? ie. [0, 10, 20, 30 ...]</p> <p>Yes I can do this using a for loop but I'm wondering if there is a neater way to do this, perhaps even in one line?</p>
72
2009-09-10T06:32:29Z
1,404,202
<p>Why not just use a <strong>step</strong> parameter of <strong>range</strong> function as well to get:</p> <pre><code>l = range(0, 1000, 10) </code></pre> <p>For comparison, on my machine:</p> <pre><code>H:\&gt;python -m timeit -s "l = range(1000)" "l1 = [x for x in l if x % 10 == 0]" 10000 loops, best of 3: 90.8 ...
4
2009-09-10T09:08:27Z
[ "list", "python" ]
Pythonic way to return list of every n'th item in a larger list
1,403,674
<p>Say we have a list of numbers from zero to 1000. Is there a pythonic/efficient way to produce a list of the first and every subsequent 10th item? ie. [0, 10, 20, 30 ...]</p> <p>Yes I can do this using a for loop but I'm wondering if there is a neater way to do this, perhaps even in one line?</p>
72
2009-09-10T06:32:29Z
1,404,229
<ol> <li><code>source_list[::10]</code> is the most obvious, but this doesn't work for any iterable and is not memory efficient for large lists.</li> <li><code>itertools.islice(source_sequence, 0, None, 10)</code> works for any iterable and is memery efficient, but probably is not the fastest solution for large list an...
27
2009-09-10T09:13:49Z
[ "list", "python" ]
Good way to write a lightweight client function to be imported Twisted Python
1,404,066
<p>Dear everyone, I have the following server running:</p> <pre><code>class ThasherProtocol(basic.LineReceiver): def lineReceived(self, line): dic = simplejson.loads( line) ret = self.factory.d[ dic['method'] ]( dic['args'] ) self.transport.write( simplejson.dumps( ret) ) self.trans...
2
2009-09-10T08:28:58Z
1,404,238
<p>You want <code>getHash</code> to return a <code>Deferred</code>, not a synchronous value.</p> <p>The way to do this is to create a <code>Deferred</code> and associate it with the connection that performs a particular request.</p> <p>The following is untested and probably won't work, but it should give you a rough ...
2
2009-09-10T09:16:52Z
[ "python", "twisted" ]
Good way to write a lightweight client function to be imported Twisted Python
1,404,066
<p>Dear everyone, I have the following server running:</p> <pre><code>class ThasherProtocol(basic.LineReceiver): def lineReceived(self, line): dic = simplejson.loads( line) ret = self.factory.d[ dic['method'] ]( dic['args'] ) self.transport.write( simplejson.dumps( ret) ) self.trans...
2
2009-09-10T08:28:58Z
1,404,962
<p>I managed to solve my own problem.</p> <p>Use sockets (Unix sockets in particular) it speed up my app 4x and it's not difficult to use at all.</p> <p>so now my solution is simplejson + socket</p>
-1
2009-09-10T12:23:13Z
[ "python", "twisted" ]
How to catch error in Django project on apache: 10048 "Address already in use"
1,404,259
<p>Python 2.5.2, Apache 2.2, Django 1.0.2 final</p> <p>My Django app tries to connect to a certain port. When that port is busy, I get the error 10048 "Address already in use" from apache. I know where the error is coming from. How do I catch this apache error?</p> <p>More info:</p> <pre><code>error at /report/5/200...
2
2009-09-10T09:25:31Z
1,406,058
<p>If you're calling <code>httplib.connect</code> directly from your code, then the <code>try</code>/<code>except</code> should be around that direct call. Or is the call happening indirectly...? Unfortunately Apache is not giving you a stack trace, so if you're having problems locating exactly what call sequence is i...
1
2009-09-10T15:40:14Z
[ "python", "django", "apache" ]
Plotting two graphs that share an x-axis in matplotlib
1,404,502
<p>I have to plot 2 graphs in a single screen. The x-axis remains the same but the y-axis should be different.</p> <p>How can I do that in 'matplotlib'?</p>
8
2009-09-10T10:27:50Z
1,404,551
<p><a href="http://matplotlib.sourceforge.net/api/pyplot%5Fapi.html#matplotlib.pyplot.subplot"><code>subplot</code></a> will let you plot more than one figure on the same canvas. See the example on the linked documentation page.</p> <p>There is an example of a shared axis plot in the examples directory, called <code>s...
6
2009-09-10T10:45:00Z
[ "python", "matplotlib" ]
Plotting two graphs that share an x-axis in matplotlib
1,404,502
<p>I have to plot 2 graphs in a single screen. The x-axis remains the same but the y-axis should be different.</p> <p>How can I do that in 'matplotlib'?</p>
8
2009-09-10T10:27:50Z
1,404,572
<p><a href="http://matplotlib.sourceforge.net/api/axes%5Fapi.html?highlight=twinx#matplotlib.axes.Axes.twinx"><code>twinx</code></a> is the function you're looking for; <a href="http://matplotlib.sourceforge.net/examples/api/two%5Fscales.html">here's an example</a> of how to use it.</p> <p><img src="http://matplotlib....
17
2009-09-10T10:50:20Z
[ "python", "matplotlib" ]
Is there something like Ruby's Machinist for Python
1,404,503
<p>Copied from the site <a href="http://github.com/notahat/machinist/" rel="nofollow">http://github.com/notahat/machinist/</a></p> <blockquote> <p>Machinist makes it easy to create test data within your tests. It generates data for the fields you don't care about, and constructs any necessary associated objects, lea...
2
2009-09-10T10:28:03Z
1,411,283
<p>I looked through the whole <a href="http://pycheesecake.org/wiki/PythonTestingToolsTaxonomy" rel="nofollow">Python Testing Tools Taxonomy</a> page (which has lots of great stuff) but didn't find much of anything like Machinist.</p> <p>There is one simply script (called <a href="http://www.accesscom.com/~darius/soft...
1
2009-09-11T14:36:41Z
[ "python", "ruby" ]
gVim and multiple programming languages
1,404,515
<p>My day job involves coding with Perl. At home I play around with Python and Erlang. For Perl I want to indent my code with two spaces. Whereas for Python the standard is 4. Also I have some key bindings to open function declarations which I would like to use with all programming languages. How can this be achieved i...
13
2009-09-10T10:34:07Z
1,404,527
<p>You should be able to do with by leveraging filetypes ... e.g., add this to your vimrc (and modify appropriately for different languages):</p> <pre><code>autocmd FileType python set tabstop=4|set shiftwidth=4|set expandtab </code></pre>
22
2009-09-10T10:36:55Z
[ "python", "perl", "editor", "vim" ]
gVim and multiple programming languages
1,404,515
<p>My day job involves coding with Perl. At home I play around with Python and Erlang. For Perl I want to indent my code with two spaces. Whereas for Python the standard is 4. Also I have some key bindings to open function declarations which I would like to use with all programming languages. How can this be achieved i...
13
2009-09-10T10:34:07Z
1,404,570
<p>In your $HOME, make .vim/ directory (or vimfiles/ on Windows), in it make ftplugin/ directory, and in it keep files named "perl.vim" or "python.vim" or "html.vim" or ...</p> <p>These should be loaded automatically when you open/create new file of given filetype as long as you don't forget to add <code>:filetype plu...
22
2009-09-10T10:49:21Z
[ "python", "perl", "editor", "vim" ]
gVim and multiple programming languages
1,404,515
<p>My day job involves coding with Perl. At home I play around with Python and Erlang. For Perl I want to indent my code with two spaces. Whereas for Python the standard is 4. Also I have some key bindings to open function declarations which I would like to use with all programming languages. How can this be achieved i...
13
2009-09-10T10:34:07Z
1,404,600
<p>Here's how I do it. The below is an excerpt from my <code>.vimrc</code>, and I maintain further configs per language, and load those when a new buffer is loaded.</p> <pre><code>" HTML autocmd BufNewFile,BufRead *.html,*.htm,*.xhtml source ~/.vimhtml " XML autocmd BufNewFile,BufRead *.xml,*.xmi source ~/.vimxml " Pe...
3
2009-09-10T10:57:00Z
[ "python", "perl", "editor", "vim" ]
gVim and multiple programming languages
1,404,515
<p>My day job involves coding with Perl. At home I play around with Python and Erlang. For Perl I want to indent my code with two spaces. Whereas for Python the standard is 4. Also I have some key bindings to open function declarations which I would like to use with all programming languages. How can this be achieved i...
13
2009-09-10T10:34:07Z
1,405,318
<p>In addition to rangerchris's answer, you might consider using modelines. Modelines tell the editor how to configure itself:</p> <pre><code>#!/usr/bin/perl # vi: ts=4 sw=4 ht=4 et textwidth=76 : use strict; use warnings; print "hello world\n"; </code></pre> <p>That modeline tells vi to use 4 character tabs and a...
7
2009-09-10T13:29:18Z
[ "python", "perl", "editor", "vim" ]
Python sched.scheduler exceeds max recursion depth
1,404,580
<p>I have recently started learning Python and part of the simple app I am making includes a timer with a hh:mm:ss display running in its own thread.</p> <p>Looking around the web I found two ways of implementing this:</p> <ol> <li>Using sched.scheduler</li> <li>Using threading.Timer</li> </ol> <p>The way I did it l...
4
2009-09-10T10:51:59Z
1,404,612
<p>A Timer is a one-shot event. It cannot be made to loop this way.</p> <p>Using a Timer to call a function which then creates another Timer which calls a function that creates a Timer which calls a function which creates a Timer, ..., must reach the recursion limit.</p> <p>You don't mention your OS, but the "skippi...
3
2009-09-10T10:58:35Z
[ "python", "timer", "clock", "scheduler" ]
Python sched.scheduler exceeds max recursion depth
1,404,580
<p>I have recently started learning Python and part of the simple app I am making includes a timer with a hh:mm:ss display running in its own thread.</p> <p>Looking around the web I found two ways of implementing this:</p> <ol> <li>Using sched.scheduler</li> <li>Using threading.Timer</li> </ol> <p>The way I did it l...
4
2009-09-10T10:51:59Z
1,406,152
<p>Here's how to make a one-shot into a periodic event, e.g. with <code>sched</code>: if the function must make its own scheduler and be the only thing running on its thread:</p> <pre><code>def tick(self, display, alarm_time, scheduler=None): # make a new scheduler only once &amp; schedule this function immediately ...
4
2009-09-10T15:57:34Z
[ "python", "timer", "clock", "scheduler" ]
How to get output from external command combine with Pipe
1,404,693
<p>I have command like this.</p> <pre><code>wmctrl -lp | awk '/gedit/ { print $1 }' </code></pre> <p>And I want its output within python script, i tried this code</p> <pre><code>&gt;&gt;&gt; import subprocess &gt;&gt;&gt; proc = subprocess.Popen(["wmctrl -lp", "|","awk '/gedit/ {print $1}"], shell=True, stdout=subp...
1
2009-09-10T11:17:53Z
1,404,707
<p>With <code>shell=True</code>, you should use a single command line instead of an array, otherwise your additional arguments are interpreted as shell arguments. From the <a href="http://docs.python.org/library/subprocess.html"><code>subprocess</code> documentation</a>:</p> <blockquote> <p>On Unix, with shell=True:...
7
2009-09-10T11:20:47Z
[ "python", "linux", "pipe" ]
How to get output from external command combine with Pipe
1,404,693
<p>I have command like this.</p> <pre><code>wmctrl -lp | awk '/gedit/ { print $1 }' </code></pre> <p>And I want its output within python script, i tried this code</p> <pre><code>&gt;&gt;&gt; import subprocess &gt;&gt;&gt; proc = subprocess.Popen(["wmctrl -lp", "|","awk '/gedit/ {print $1}"], shell=True, stdout=subp...
1
2009-09-10T11:17:53Z
1,404,721
<p>Because you are passing a sequence in for the program, it thinks that the pipe is an <em>argument</em> to <code>wmcrtrl</code>, such as if you did</p> <pre><code>wmctrl -lp "|" </code></pre> <p>and thus the actual pipe <em>operation</em> is lost.</p> <p>Making it a single string should indeed give you the correct...
0
2009-09-10T11:23:07Z
[ "python", "linux", "pipe" ]
How to get output from external command combine with Pipe
1,404,693
<p>I have command like this.</p> <pre><code>wmctrl -lp | awk '/gedit/ { print $1 }' </code></pre> <p>And I want its output within python script, i tried this code</p> <pre><code>&gt;&gt;&gt; import subprocess &gt;&gt;&gt; proc = subprocess.Popen(["wmctrl -lp", "|","awk '/gedit/ {print $1}"], shell=True, stdout=subp...
1
2009-09-10T11:17:53Z
22,395,345
<p>After some research, I have the following code which works very well for me. It basically prints both stdout and stderr in real time. Hope it helps someone else who needs it.</p> <pre><code>stdout_result = 1 stderr_result = 1 def stdout_thread(pipe): global stdout_result while True: out = pipe.std...
0
2014-03-14T03:00:45Z
[ "python", "linux", "pipe" ]
Socket programming
1,404,724
<p>Please take a look at my code:</p> <pre><code>from twisted.internet.protocol import ServerFactory from twisted.internet import reactor from twisted.protocols import basic class ThasherProtocol(basic.LineReceiver): def lineReceived(self, line): print line self.transport.write( 1 ) self....
0
2009-09-10T11:23:45Z
1,404,906
<p>you should send a line and not just hello in order to have lineReceived called e.g. <code>s.sendall('hello\r\n')</code></p>
2
2009-09-10T12:09:25Z
[ "python", "sockets" ]
Path separator char in python 2.4
1,404,749
<p>Just out of curiosity - is there another way to obtain the platform's path separator char than <code>os.path.normcase('/')</code> in Python 2.4?<br /> I was expecting something like a <code>os.path.separator</code> constant...</p>
15
2009-09-10T11:30:26Z
1,404,767
<p>That would be <a href="http://docs.python.org/library/os.html#os.sep"><code>os.sep</code></a>.</p>
36
2009-09-10T11:34:59Z
[ "python", "path-separator" ]
How to get colored emails from crontab?
1,405,108
<p>I call a Python script from crontab. The script does generates colored output using ANSI escapes but when crontab is sending the mail with the output I see the escapes instead of colors. </p> <p>What is happening is logic but I would like to know if it would be possible to generate a html message instead. </p> <p>...
0
2009-09-10T12:50:43Z
1,405,207
<p>Maybe you can try with some txt to html converter, for example, <a href="http://txt2html.sourceforge.net/" rel="nofollow">http://txt2html.sourceforge.net/</a>, you can also use pygments with some modifications.</p>
0
2009-09-10T13:09:30Z
[ "python", "colors", "console", "crontab", "ansi-escape" ]
Serving static files with Twisted and Django under non-root folders
1,405,254
<p>I am in the process of migrating an application (<a href="http://www.sagemath.org" rel="nofollow">Sage</a>) from Twisted to Django.</p> <p>Static documentation is currently served under <code>/doc/static</code>, while live (built on-the-fly) documentation are served under <code>/doc/live</code>.</p> <p>Is it possi...
2
2009-09-10T13:17:56Z
1,405,332
<p>Unless I misunderstood the question, why not simply rewrite the /doc/static url to Twisted before it even reaches Django (ie. at the Apache / proxy level)?</p> <p><a href="http://httpd.apache.org/docs/2.0/mod/mod%5Frewrite.html" rel="nofollow">http://httpd.apache.org/docs/2.0/mod/mod%5Frewrite.html</a></p>
-1
2009-09-10T13:32:33Z
[ "python", "django", "twisted" ]
Serving static files with Twisted and Django under non-root folders
1,405,254
<p>I am in the process of migrating an application (<a href="http://www.sagemath.org" rel="nofollow">Sage</a>) from Twisted to Django.</p> <p>Static documentation is currently served under <code>/doc/static</code>, while live (built on-the-fly) documentation are served under <code>/doc/live</code>.</p> <p>Is it possi...
2
2009-09-10T13:17:56Z
1,405,357
<p>It can be done, the degree of elegance just varies... I understand this is for transition, so it might not have to be very beautiful.</p> <p>If you have to have Twisted serving the static files, then you either have to hack together in django a proxy-through for those files, or throw something in front of the whole...
2
2009-09-10T13:36:09Z
[ "python", "django", "twisted" ]
Serving static files with Twisted and Django under non-root folders
1,405,254
<p>I am in the process of migrating an application (<a href="http://www.sagemath.org" rel="nofollow">Sage</a>) from Twisted to Django.</p> <p>Static documentation is currently served under <code>/doc/static</code>, while live (built on-the-fly) documentation are served under <code>/doc/live</code>.</p> <p>Is it possi...
2
2009-09-10T13:17:56Z
1,409,511
<p>Have a look at <a href="http://blog.dreid.org/2009/03/twisted-django-it-wont-burn-down-your.html" rel="nofollow">this link</a> on how to run Django on top of Twisted: (instructions copied from the blog)</p> <ol> <li>easy_install Twisted</li> <li>easy_install Django</li> <li>Profit!</li> <li>django-admin.py startpro...
3
2009-09-11T07:39:08Z
[ "python", "django", "twisted" ]
Special considerations for using Python in init.d script?
1,405,555
<p>Are there any special considerations for using Python in an <code>'init.d'</code> script being run through <code>init</code>? (i.e. booting Ubuntu)</p> <p>From what I understand through googling/testing on Ubuntu, the environment variables provided to an <code>'init.d'</code> script are scarce and so using <code>"#...
9
2009-09-10T14:17:42Z
1,405,596
<p>I am assuming this is running some kind of daemon written in python, if not then this may not apply.</p> <p>You will (probably) want to do the standard unix double fork and redirect file descriptors thing. This is the one I use (Adapted from an ActiveState code recepie whose url eludes me at the moment).</p> <pre...
1
2009-09-10T14:27:05Z
[ "python", "linux", "ubuntu", "init.d" ]
Special considerations for using Python in init.d script?
1,405,555
<p>Are there any special considerations for using Python in an <code>'init.d'</code> script being run through <code>init</code>? (i.e. booting Ubuntu)</p> <p>From what I understand through googling/testing on Ubuntu, the environment variables provided to an <code>'init.d'</code> script are scarce and so using <code>"#...
9
2009-09-10T14:17:42Z
1,406,020
<p>That just highlights the biggest problem with python in an init.d script -- added complexity. </p> <p>Python has no specification, and the env doesn't even have to point to cpython. If you upgrade and python breaks, you'll have to bite your tongue. And there is a much greater chance that python will break than sh (...
4
2009-09-10T15:32:56Z
[ "python", "linux", "ubuntu", "init.d" ]
How to adjust the quality of a resized image in Python Imaging Library?
1,405,602
<p>thanks for taking time to read my question.</p> <p>I am working on PIL and need to know if the image quality can be adjusted while resizing or thumbnailing an image. From what I have known is the default quality is set to 85. Can this parameter be tweaked during resizing?</p> <p>I am currently using the following ...
33
2009-09-10T14:27:55Z
1,405,701
<p>Use PIL's <code>resize</code> method manually:</p> <pre><code>image = image.resize((x, y), Image.ANTIALIAS) # LANCZOS as of Pillow 2.7 </code></pre> <p>Followed by the save method</p> <pre><code>quality_val = 90 image.save(filename, 'JPEG', quality=quality_val) </code></pre> <p>Take a look at the source for <a ...
51
2009-09-10T14:41:39Z
[ "python", "python-imaging-library" ]
How to adjust the quality of a resized image in Python Imaging Library?
1,405,602
<p>thanks for taking time to read my question.</p> <p>I am working on PIL and need to know if the image quality can be adjusted while resizing or thumbnailing an image. From what I have known is the default quality is set to 85. Can this parameter be tweaked during resizing?</p> <p>I am currently using the following ...
33
2009-09-10T14:27:55Z
1,405,713
<p>ANTIALIAS is in no way comparable to the "85" quality level. The ANTIALIAS parameter tells the thumbnail method what algorithm to use for resampling pixels from one size to another. For example, if I have a 3x3 image that looks like this:</p> <pre><code>2 2 2 2 0 2 2 2 2 </code></pre> <p>and I resize it to 2x2, ...
37
2009-09-10T14:44:19Z
[ "python", "python-imaging-library" ]
How to adjust the quality of a resized image in Python Imaging Library?
1,405,602
<p>thanks for taking time to read my question.</p> <p>I am working on PIL and need to know if the image quality can be adjusted while resizing or thumbnailing an image. From what I have known is the default quality is set to 85. Can this parameter be tweaked during resizing?</p> <p>I am currently using the following ...
33
2009-09-10T14:27:55Z
3,975,415
<p>Don't confuse rescaling and compression.</p> <p>For the best quality you have to use both. See the following code:</p> <pre><code>from PIL import Image image = Image.open(filename) image.thumbnail((x, y), Image.ANTIALIAS) image.save(filename, quality=100) </code></pre> <p>In this way I have very fine thumbs in m...
6
2010-10-20T07:00:15Z
[ "python", "python-imaging-library" ]
How to adjust the quality of a resized image in Python Imaging Library?
1,405,602
<p>thanks for taking time to read my question.</p> <p>I am working on PIL and need to know if the image quality can be adjusted while resizing or thumbnailing an image. From what I have known is the default quality is set to 85. Can this parameter be tweaked during resizing?</p> <p>I am currently using the following ...
33
2009-09-10T14:27:55Z
8,150,029
<p>One way to achieve better quality is to do the downscaling in two steps. For example if your original image is 1200x1200 and you need to resize it to 64x64 pixels, then on the first step downscale it to somewhere in the middle of these two sizes:</p> <p>1200x1200 -> 600x600 -> 64x64</p>
0
2011-11-16T10:20:40Z
[ "python", "python-imaging-library" ]
How to adjust the quality of a resized image in Python Imaging Library?
1,405,602
<p>thanks for taking time to read my question.</p> <p>I am working on PIL and need to know if the image quality can be adjusted while resizing or thumbnailing an image. From what I have known is the default quality is set to 85. Can this parameter be tweaked during resizing?</p> <p>I am currently using the following ...
33
2009-09-10T14:27:55Z
22,777,163
<p>Antialias n set quality like 90</p> <pre><code> img = img.resize((128,128),Image.ANTIALIAS) img.save(os.path.join(output_dir+'/'+x,newfile),"JPEG",quality=90) </code></pre> <p><a href="http://www.dzone.com/snippets/resize-thousands-images-python" rel="nofollow">http://www.dzone.com/snippets/resize-thousands-i...
0
2014-04-01T04:58:02Z
[ "python", "python-imaging-library" ]
Consume a Web service thought an Active Directory
1,405,670
<p>Well i have a project in which i have to consume a web service but authenticating in an Active Directory, i have my system written in python3, python-ldap module in not ported yet so i want to know a way to achive this "consumption".</p> <p>In the worst case i will create a standalone consumer in python2.5 but i wa...
0
2009-09-10T14:37:14Z
1,407,503
<p>I've resolved it with python-ntlm a project in google that handles ntlm for www-authentication: negotiate, <a href="http://code.google.com/p/python-ntlm/" rel="nofollow">http://code.google.com/p/python-ntlm/</a> thanks!</p>
0
2009-09-10T20:19:55Z
[ "python", "web-services", "ldap" ]
What is the simplest URL shortener application one could write in python for the Google App Engine?
1,405,786
<p>Services like bit.ly are great for shortening URL’s that you want to include in tweets and other conversations. What is the simplest URL shortener application one could write in python for the Google App Engine? </p>
12
2009-09-10T14:57:02Z
1,405,962
<p>That sounds like a challenge!</p> <pre><code>from google.appengine.ext import db from google.appengine.ext import webapp from google.appengine.ext.webapp import run_wsgi_app class ShortLink(db.Model): url = db.TextProperty(required=True) class CreateLinkHandler(webapp.RequestHandler): def post(self): link...
28
2009-09-10T15:21:01Z
[ "python", "google-app-engine" ]
What is the simplest URL shortener application one could write in python for the Google App Engine?
1,405,786
<p>Services like bit.ly are great for shortening URL’s that you want to include in tweets and other conversations. What is the simplest URL shortener application one could write in python for the Google App Engine? </p>
12
2009-09-10T14:57:02Z
1,845,515
<p>There is a django app on github, github.com/nileshk/url-shortener. I forked it to make it more of an all encompassing site,<a href="http://github.com/voidfiles/url-shortener" rel="nofollow">http://github.com/voidfiles/url-shortener</a>.</p>
1
2009-12-04T08:01:13Z
[ "python", "google-app-engine" ]
What is the simplest URL shortener application one could write in python for the Google App Engine?
1,405,786
<p>Services like bit.ly are great for shortening URL’s that you want to include in tweets and other conversations. What is the simplest URL shortener application one could write in python for the Google App Engine? </p>
12
2009-09-10T14:57:02Z
5,038,644
<p>similar, complete with GAE project boilerplate: <a href="https://github.com/dustingetz/vanity-redirect" rel="nofollow">https://github.com/dustingetz/vanity-redirect</a></p>
2
2011-02-18T07:20:58Z
[ "python", "google-app-engine" ]
How to discard from the middle of a list using list comprehensions?
1,405,883
<p>I could do this using an index but I thought there must be a cleaner way using list comprehensions. I'm a beginner. I hope it's not embarrassingly obvious. Thanks</p> <pre><code>for x in firstList: firstFunc(x) secondFunc(x) x = process(x) if x.discard == True: (get rid of x) secondList.appe...
0
2009-09-10T15:08:55Z
1,405,914
<p>You know, your best solution is really to just initialize secondList how you like, and do all three functions in a regular loop, since they're all dependent and contain logic that is not just filtering (you say process sets attributes... I'm assuming you mean other than discard):</p> <pre><code># If secondList not ...
1
2009-09-10T15:14:16Z
[ "python" ]
How to discard from the middle of a list using list comprehensions?
1,405,883
<p>I could do this using an index but I thought there must be a cleaner way using list comprehensions. I'm a beginner. I hope it's not embarrassingly obvious. Thanks</p> <pre><code>for x in firstList: firstFunc(x) secondFunc(x) x = process(x) if x.discard == True: (get rid of x) secondList.appe...
0
2009-09-10T15:08:55Z
1,405,923
<p>Edit: process(x) is necessary for x.discard, meaning that the answer is:</p> <p><strong>No there is no cleaner way. And the way you are doing it is already clean.</strong></p> <p>Old answer:</p> <p>Not really, no. You can make this:</p> <pre><code>def process_item(x): firstFunc(x) secondFunc(x) x = p...
0
2009-09-10T15:16:16Z
[ "python" ]
How to discard from the middle of a list using list comprehensions?
1,405,883
<p>I could do this using an index but I thought there must be a cleaner way using list comprehensions. I'm a beginner. I hope it's not embarrassingly obvious. Thanks</p> <pre><code>for x in firstList: firstFunc(x) secondFunc(x) x = process(x) if x.discard == True: (get rid of x) secondList.appe...
0
2009-09-10T15:08:55Z
1,405,956
<p>a few things: </p> <ul> <li>you cannot <code>append</code> a list, you need to use <code>extend</code>.</li> <li>no need for <code>== True</code> bit, use just <code>if x.discard:</code></li> <li>you'd rather create a new list with values that you don't want to discard and don't pollute your loop with removal.</li>...
0
2009-09-10T15:20:25Z
[ "python" ]
How to discard from the middle of a list using list comprehensions?
1,405,883
<p>I could do this using an index but I thought there must be a cleaner way using list comprehensions. I'm a beginner. I hope it's not embarrassingly obvious. Thanks</p> <pre><code>for x in firstList: firstFunc(x) secondFunc(x) x = process(x) if x.discard == True: (get rid of x) secondList.appe...
0
2009-09-10T15:08:55Z
1,405,965
<p>Sounds like</p> <pre><code>def allProcessing(x) firstFunc(x) secondFunc(x) return !(process(x).discard) newList = filter(allProcessing, oldList) </code></pre>
0
2009-09-10T15:21:09Z
[ "python" ]
How to discard from the middle of a list using list comprehensions?
1,405,883
<p>I could do this using an index but I thought there must be a cleaner way using list comprehensions. I'm a beginner. I hope it's not embarrassingly obvious. Thanks</p> <pre><code>for x in firstList: firstFunc(x) secondFunc(x) x = process(x) if x.discard == True: (get rid of x) secondList.appe...
0
2009-09-10T15:08:55Z
1,405,973
<p>Write this as two list comprehensions, one which assembles the data that might need filtering, and another which does the filtering. Make firstFunc and secondFunc return x (as process does), and then you can write it like so:</p> <pre><code>unfilteredList = [secondFunc(firstFunc(x)) for x in firstList] secondList =...
0
2009-09-10T15:22:08Z
[ "python" ]
How to discard from the middle of a list using list comprehensions?
1,405,883
<p>I could do this using an index but I thought there must be a cleaner way using list comprehensions. I'm a beginner. I hope it's not embarrassingly obvious. Thanks</p> <pre><code>for x in firstList: firstFunc(x) secondFunc(x) x = process(x) if x.discard == True: (get rid of x) secondList.appe...
0
2009-09-10T15:08:55Z
1,406,964
<p>Just a thought, and it does little for documentation, but why not try:</p> <pre><code>def masterFunc(x): firstFunc(x) secondFunc(x) process(x) return x.discard secondList = [ x for x in firstList if masterFunc(x) ] </code></pre> <p>Good news: does what you asked, strictly speaking. Bad news: it hi...
2
2009-09-10T18:35:47Z
[ "python" ]
How do I determine if my python shell is executing in 32bit or 64bit mode on OS X?
1,405,913
<p>I need a way to tell what mode the shell is in from within the shell. </p> <p>I've tried looking at the <a href="http://docs.python.org/library/platform.html">platform</a> module but it seems only to tell you about "about the bit architecture and the linkage format used for the executable": the binary is compiled ...
224
2009-09-10T15:14:01Z
1,405,971
<p>UPDATED: One way is to look at <code>sys.maxsize</code> as documented <a href="http://docs.python.org/library/platform.html#cross-platform">here</a>:</p> <pre><code>$ python-32 -c 'import sys;print("%x" % sys.maxsize, sys.maxsize &gt; 2**32)' ('7fffffff', False) $ python-64 -c 'import sys;print("%x" % sys.maxsize, ...
247
2009-09-10T15:21:42Z
[ "python", "osx" ]
How do I determine if my python shell is executing in 32bit or 64bit mode on OS X?
1,405,913
<p>I need a way to tell what mode the shell is in from within the shell. </p> <p>I've tried looking at the <a href="http://docs.python.org/library/platform.html">platform</a> module but it seems only to tell you about "about the bit architecture and the linkage format used for the executable": the binary is compiled ...
224
2009-09-10T15:14:01Z
1,406,210
<p>Try using ctypes to get the size of a void pointer:</p> <pre><code>import ctypes print ctypes.sizeof(ctypes.c_voidp) </code></pre> <p>It'll be 4 for 32 bit or 8 for 64 bit.</p>
43
2009-09-10T16:06:35Z
[ "python", "osx" ]
How do I determine if my python shell is executing in 32bit or 64bit mode on OS X?
1,405,913
<p>I need a way to tell what mode the shell is in from within the shell. </p> <p>I've tried looking at the <a href="http://docs.python.org/library/platform.html">platform</a> module but it seems only to tell you about "about the bit architecture and the linkage format used for the executable": the binary is compiled ...
224
2009-09-10T15:14:01Z
1,406,849
<p>Basically a variant on Matthew Marshall's answer (with struct from the std.library):</p> <pre><code>import struct print struct.calcsize("P") * 8 </code></pre>
113
2009-09-10T18:11:27Z
[ "python", "osx" ]
How do I determine if my python shell is executing in 32bit or 64bit mode on OS X?
1,405,913
<p>I need a way to tell what mode the shell is in from within the shell. </p> <p>I've tried looking at the <a href="http://docs.python.org/library/platform.html">platform</a> module but it seems only to tell you about "about the bit architecture and the linkage format used for the executable": the binary is compiled ...
224
2009-09-10T15:14:01Z
1,484,362
<p>For a non-programmatic solution, look in the Activity Monitor. It lists the architecture of 64-bit processes as “Intel (64-bit)”.</p>
11
2009-09-27T20:14:03Z
[ "python", "osx" ]
How do I determine if my python shell is executing in 32bit or 64bit mode on OS X?
1,405,913
<p>I need a way to tell what mode the shell is in from within the shell. </p> <p>I've tried looking at the <a href="http://docs.python.org/library/platform.html">platform</a> module but it seems only to tell you about "about the bit architecture and the linkage format used for the executable": the binary is compiled ...
224
2009-09-10T15:14:01Z
10,966,396
<p>When starting the Python interpreter in the terminal/command line you may also see a line like: </p> <p><code>Python 2.7.2 (default, Jun 12 2011, 14:24:46) [MSC v.1500 64 bit (AMD64)] on win32</code> </p> <p>Where <code>[MSC v.1500 64 bit (AMD64)]</code> means 64-bit Python. Works for my particular setup.</p>
144
2012-06-10T04:37:47Z
[ "python", "osx" ]
How do I determine if my python shell is executing in 32bit or 64bit mode on OS X?
1,405,913
<p>I need a way to tell what mode the shell is in from within the shell. </p> <p>I've tried looking at the <a href="http://docs.python.org/library/platform.html">platform</a> module but it seems only to tell you about "about the bit architecture and the linkage format used for the executable": the binary is compiled ...
224
2009-09-10T15:14:01Z
21,573,486
<pre><code>C:\Users\xyz&gt;python Python 2.7.6 (default, Nov XY ..., 19:24:24) **[MSC v.1500 64 bit (AMD64)] on win 32** Type "help", "copyright", "credits" or "license" for more information. &gt;&gt;&gt; </code></pre> <p>after hitting python in cmd</p>
-1
2014-02-05T09:40:16Z
[ "python", "osx" ]
How do I determine if my python shell is executing in 32bit or 64bit mode on OS X?
1,405,913
<p>I need a way to tell what mode the shell is in from within the shell. </p> <p>I've tried looking at the <a href="http://docs.python.org/library/platform.html">platform</a> module but it seems only to tell you about "about the bit architecture and the linkage format used for the executable": the binary is compiled ...
224
2009-09-10T15:14:01Z
27,745,449
<p>On my centos linux platform I did the following: <br><br> 1) start python interpreter (I'm using 2.6.6)<br> 2) import platform<br> 3) print platform.architecture()</p> <p>and it gave me (64bit, 'ELF')</p>
3
2015-01-02T16:43:10Z
[ "python", "osx" ]
How do I determine if my python shell is executing in 32bit or 64bit mode on OS X?
1,405,913
<p>I need a way to tell what mode the shell is in from within the shell. </p> <p>I've tried looking at the <a href="http://docs.python.org/library/platform.html">platform</a> module but it seems only to tell you about "about the bit architecture and the linkage format used for the executable": the binary is compiled ...
224
2009-09-10T15:14:01Z
28,482,481
<p>platform.architecture() notes say:</p> <blockquote> <p>Note: On Mac OS X (and perhaps other platforms), executable files may be universal files containing multiple architectures.</p> <p>To get at the “64-bitness” of the current interpreter, it is more reliable to query the sys.maxsize attribute:</p> ...
5
2015-02-12T16:20:26Z
[ "python", "osx" ]
How do I determine if my python shell is executing in 32bit or 64bit mode on OS X?
1,405,913
<p>I need a way to tell what mode the shell is in from within the shell. </p> <p>I've tried looking at the <a href="http://docs.python.org/library/platform.html">platform</a> module but it seems only to tell you about "about the bit architecture and the linkage format used for the executable": the binary is compiled ...
224
2009-09-10T15:14:01Z
39,541,823
<p><strong>Open python console:</strong></p> <pre><code>import platform platform.architecture()[0] </code></pre> <p>it should display the '64bit' or '32bit' according to your platform.</p> <p><strong>Alternatively</strong>( <a href="https://docs.python.org/3/library/platform.html#cross-platform" rel="nofollow">in ca...
1
2016-09-17T00:45:22Z
[ "python", "osx" ]
Why does "enable-shared failed" happen on libjpeg build for os X?
1,405,920
<p>I'm trying to install libjpeg on os X to fix a problem with the Python Imaging Library JPEG setup.</p> <p>I downloaded libjpeg from <a href="http://www.ijg.org/files/jpegsrc.v7.tar.gz" rel="nofollow">http://www.ijg.org/files/jpegsrc.v7.tar.gz</a></p> <p>I then began to setup the config file</p> <pre><code>cp /usr...
0
2009-09-10T15:16:05Z
1,407,184
<p>I had copied the code from a blog. </p> <p>The flag character there was not a hyphem , it just looked like one:</p> <pre><code>ord("–") TypeError: ord() expected a character, but string of length 3 found </code></pre> <p>I changed it to a proper hypen and it works fine.</p>
0
2009-09-10T19:18:23Z
[ "python", "osx", "build" ]