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
How Do I Create a Python / Django Egg?
1,650,314
<p>I have a Python program (with Django - does this matter?) that I want to 'bundle', if you like. How do I do this, in the same way one can create a .jar for Java? </p>
4
2009-10-30T14:58:00Z
1,650,352
<p>You want to use the <a href="http://pypi.python.org/pypi/setuptools" rel="nofollow">Python SetupTools</a>. You create a description file (setup.py) and then building and creating the egg is a one-line command (similar to Make). </p> <p>There <em>was</em> a nice <a href="http://ianbicking.org/docs/setuptools-prese...
5
2009-10-30T15:05:15Z
[ "python", "django", "egg" ]
How Do I Create a Python / Django Egg?
1,650,314
<p>I have a Python program (with Django - does this matter?) that I want to 'bundle', if you like. How do I do this, in the same way one can create a .jar for Java? </p>
4
2009-10-30T14:58:00Z
4,589,760
<p><a href="http://pypi.python.org/pypi/fez.djangoskel/" rel="nofollow">DjangoSkel</a> is the way to go.</p> <p>Install DjangoSkel:</p> <pre><code>pip install DjangoSkel </code></pre> <p>Create skeleton for django egg:</p> <pre><code>paster create -t django_namespace_app </code></pre> <p>List available templates</...
2
2011-01-04T00:50:39Z
[ "python", "django", "egg" ]
Calling types via their name as a string in Python
1,650,338
<p>I'm aware of using globals(), locals() and getattr to referance things in Python by string (as in <a href="http://stackoverflow.com/questions/3061/calling-a-function-from-a-string-with-the-functions-name-in-python">this question</a>) but unless I'm missing something obvious I can't seem to use this with calling type...
4
2009-10-30T15:02:16Z
1,650,370
<p>The issue here is that <code>int</code> is part of the <code>__builtins__</code> module, not just part of the global namespace. You can get a built-in type, such as <code>int</code>, using the following bit of code:</p> <pre><code>int_gen = getattr(globals()["__builtins__"], "int") i = int_gen(4) # &gt;&gt;&gt; i =...
2
2009-10-30T15:08:07Z
[ "python", "getattr" ]
Calling types via their name as a string in Python
1,650,338
<p>I'm aware of using globals(), locals() and getattr to referance things in Python by string (as in <a href="http://stackoverflow.com/questions/3061/calling-a-function-from-a-string-with-the-functions-name-in-python">this question</a>) but unless I'm missing something obvious I can't seem to use this with calling type...
4
2009-10-30T15:02:16Z
1,650,381
<pre><code>getattr(__builtins__,'int') </code></pre>
2
2009-10-30T15:09:49Z
[ "python", "getattr" ]
Calling types via their name as a string in Python
1,650,338
<p>I'm aware of using globals(), locals() and getattr to referance things in Python by string (as in <a href="http://stackoverflow.com/questions/3061/calling-a-function-from-a-string-with-the-functions-name-in-python">this question</a>) but unless I'm missing something obvious I can't seem to use this with calling type...
4
2009-10-30T15:02:16Z
1,650,390
<p>There are locals,globals, and then builtins. Perhaps you are looking for the builtin:</p> <pre><code>import __builtin__ getattr(__builtin__,'int') </code></pre>
12
2009-10-30T15:12:11Z
[ "python", "getattr" ]
Calling types via their name as a string in Python
1,650,338
<p>I'm aware of using globals(), locals() and getattr to referance things in Python by string (as in <a href="http://stackoverflow.com/questions/3061/calling-a-function-from-a-string-with-the-functions-name-in-python">this question</a>) but unless I'm missing something obvious I can't seem to use this with calling type...
4
2009-10-30T15:02:16Z
1,650,424
<p>If you have a string that is the name of a thing, and you want the thing, you can also use:</p> <pre><code>thing = 'int' eval(thing) </code></pre> <p>Keep in mind though, that this is very powerful, and you need to understand what thing might contain, and where it came from. For example, if you accept user input ...
1
2009-10-30T15:17:15Z
[ "python", "getattr" ]
Calling types via their name as a string in Python
1,650,338
<p>I'm aware of using globals(), locals() and getattr to referance things in Python by string (as in <a href="http://stackoverflow.com/questions/3061/calling-a-function-from-a-string-with-the-functions-name-in-python">this question</a>) but unless I'm missing something obvious I can't seem to use this with calling type...
4
2009-10-30T15:02:16Z
1,650,617
<p>You've already gotten a solution using builtins, but another worthwhile technique to hold in your toolbag is a dispatch table. If your CSV is designed to be used by multiple applications written in multiple languages, it might look like this:</p> <pre><code>Integer,15 String,34 Float,1.0 Integer,8 </code></pre> <...
7
2009-10-30T15:47:16Z
[ "python", "getattr" ]
Calling types via their name as a string in Python
1,650,338
<p>I'm aware of using globals(), locals() and getattr to referance things in Python by string (as in <a href="http://stackoverflow.com/questions/3061/calling-a-function-from-a-string-with-the-functions-name-in-python">this question</a>) but unless I'm missing something obvious I can't seem to use this with calling type...
4
2009-10-30T15:02:16Z
1,652,839
<p>Comments suggest that you are unhappy with the idea of using eval to generate data. looking for a function in <code>__builtins__</code> allows you to find <code>eval</code>. </p> <p>the most basic solution given looks like this:</p> <pre><code>import __builtin__ def parseInput(typename, value): return getat...
2
2009-10-30T23:49:15Z
[ "python", "getattr" ]
How do I create an OpenCV image from a PIL image?
1,650,568
<p>I want to do some image processing with OpenCV (in Python), but I have to start with a PIL <code>Image</code> object, so I can't use the <code>cvLoadImage()</code> call, since that takes a filename. </p> <p>This recipe (adapted from <a href="http://opencv.willowgarage.com/wiki/PythonInterface">http://opencv.willow...
9
2009-10-30T15:38:23Z
1,652,018
<p>The example you tried to adapt is for the new python interface for OpenCV 2.0. This is probably the source of the confusion between the prefixed and non-prefixed function names (<code>cv.cvSetData()</code> versus <code>cv.SetData()</code>). </p> <p>OpenCV 2.0 now ships with two sets of python bindings:</p> <ul> <l...
8
2009-10-30T20:06:55Z
[ "python", "image-processing", "opencv", "python-imaging-library" ]
How do I create an OpenCV image from a PIL image?
1,650,568
<p>I want to do some image processing with OpenCV (in Python), but I have to start with a PIL <code>Image</code> object, so I can't use the <code>cvLoadImage()</code> call, since that takes a filename. </p> <p>This recipe (adapted from <a href="http://opencv.willowgarage.com/wiki/PythonInterface">http://opencv.willow...
9
2009-10-30T15:38:23Z
2,528,224
<p>It's really confusing to have both swig and new python binding. For example, in the OpenCV 2.0, cmake can accept both BUILD_SWIG_PYTHON_SUPPORT and BUILD_NEW_PYTHON_SUPPORT. But anyway, I kinda figured out most pitfalls.</p> <p>In the case of using "import cv" (the new python binding), one more step is needed.</p> ...
4
2010-03-27T05:14:48Z
[ "python", "image-processing", "opencv", "python-imaging-library" ]
How do I create an OpenCV image from a PIL image?
1,650,568
<p>I want to do some image processing with OpenCV (in Python), but I have to start with a PIL <code>Image</code> object, so I can't use the <code>cvLoadImage()</code> call, since that takes a filename. </p> <p>This recipe (adapted from <a href="http://opencv.willowgarage.com/wiki/PythonInterface">http://opencv.willow...
9
2009-10-30T15:38:23Z
3,657,442
<p>I did this using the python2.6 bindings of OpenCV2.1:</p> <pre><code> ... cv_img = cv.CreateImageHeader(img.size, cv.IPL_DEPTH_8U, 3) cv.SetData(cv_img, img.rotate(180).tostring()[::-1]) ... </code></pre> <p>The image rotation and reversion of the string is to swap RGB into BGR, that is used in Open...
3
2010-09-07T09:31:52Z
[ "python", "image-processing", "opencv", "python-imaging-library" ]
How do I create an OpenCV image from a PIL image?
1,650,568
<p>I want to do some image processing with OpenCV (in Python), but I have to start with a PIL <code>Image</code> object, so I can't use the <code>cvLoadImage()</code> call, since that takes a filename. </p> <p>This recipe (adapted from <a href="http://opencv.willowgarage.com/wiki/PythonInterface">http://opencv.willow...
9
2009-10-30T15:38:23Z
12,032,101
<p>I'm not an expert but I managed to get a opencv image from a PIL image with this code:</p> <pre><code>import opencv img = opencv.adaptors.PIL2Ipl(pilimg) </code></pre>
0
2012-08-20T03:53:00Z
[ "python", "image-processing", "opencv", "python-imaging-library" ]
Whether to use "SET NAMES"
1,650,591
<p>In reading "High performance MySQL" from O'Reilly I've stumbled upon the following</p> <blockquote> <p>Another common garbage query is SET NAMES UTF8, which is the wrong way to do things anyway (it does not change the client library's character set; it affects only the server).</p> </blockquote> <p>I'm a...
51
2009-10-30T15:41:09Z
1,650,649
<p>Not sure about py, but php has <a href="http://php.net/manual/en/function.mysql-set-charset.php"><code>mysql_set_charset</code></a> now, which states that this is the "preferred way to change the charset [and] using mysql_query() to execute SET NAMES is not recommended." Note, that this function was introduced for M...
8
2009-10-30T15:53:40Z
[ "php", "python", "mysql", "internationalization" ]
Whether to use "SET NAMES"
1,650,591
<p>In reading "High performance MySQL" from O'Reilly I've stumbled upon the following</p> <blockquote> <p>Another common garbage query is SET NAMES UTF8, which is the wrong way to do things anyway (it does not change the client library's character set; it affects only the server).</p> </blockquote> <p>I'm a...
51
2009-10-30T15:41:09Z
1,650,834
<p><a href="http://php.net/manual/en/function.mysql-set-charset.php"><code>mysql_set_charset()</code></a> would be an option - but an option limited to the <a href="http://www.php.net/manual/en/book.mysql.php"><code>ext/mysql</code></a>. For <a href="http://www.php.net/manual/en/book.mysqli.php"><code>ext/mysqli</code>...
28
2009-10-30T16:18:42Z
[ "php", "python", "mysql", "internationalization" ]
Whether to use "SET NAMES"
1,650,591
<p>In reading "High performance MySQL" from O'Reilly I've stumbled upon the following</p> <blockquote> <p>Another common garbage query is SET NAMES UTF8, which is the wrong way to do things anyway (it does not change the client library's character set; it affects only the server).</p> </blockquote> <p>I'm a...
51
2009-10-30T15:41:09Z
14,132,028
<p>This answer has an emphasis on php's pdo library because it's so ubiquitous.</p> <p>A brief reminder - mysql is a client-server architecture. This is significant because there's not only the mysql server where the actual database is, but there's also the seperate mysql client driver, which is the thing that talks t...
18
2013-01-03T01:49:07Z
[ "php", "python", "mysql", "internationalization" ]
Python: Object identity assertions thrown by differences in import statement notations
1,650,603
<p>When checking an object's identity, I am getting assertion errors because the object creation code imports the object-defining module under one notation (<code>base.other_stuff.BarCode</code>) and the identity-checking code imports that same module under a different notation (<code>other_stuff.BarCode</code>). (Ple...
1
2009-10-30T15:43:00Z
1,650,673
<p>Your code layout is seriously broken. You should not have package directories in <code>sys.path</code>.</p> <p>In you situation, Python will use two different search paths to find <code>BarCode.py</code>, therefore loading it twice as separate modules, <code>bar.other_stuff.BarCode</code> and <code>other_stuff.BarC...
1
2009-10-30T15:58:11Z
[ "python" ]
Python: Object identity assertions thrown by differences in import statement notations
1,650,603
<p>When checking an object's identity, I am getting assertion errors because the object creation code imports the object-defining module under one notation (<code>base.other_stuff.BarCode</code>) and the identity-checking code imports that same module under a different notation (<code>other_stuff.BarCode</code>). (Ple...
1
2009-10-30T15:43:00Z
1,650,680
<p>It looks like you have <code>&lt;root&gt;/</code> and <code>&lt;root&gt;/base</code> in your <code>sys.path</code>, which is always bad. When you do <code>import other_stuff.BarCode as bc</code> from base/stuff/FooCode.py it imports <code>other_stuff</code> as root package, but not subpackage of <code>base</code>. S...
2
2009-10-30T15:58:55Z
[ "python" ]
Python: Object identity assertions thrown by differences in import statement notations
1,650,603
<p>When checking an object's identity, I am getting assertion errors because the object creation code imports the object-defining module under one notation (<code>base.other_stuff.BarCode</code>) and the identity-checking code imports that same module under a different notation (<code>other_stuff.BarCode</code>). (Ple...
1
2009-10-30T15:43:00Z
1,650,728
<p>"Notation" is the least of issues -- different notations that are defined to semantically refer to the same module are guaranteed to produce the same object. E.g.:</p> <pre><code>&gt;&gt;&gt; import sys as foobar &gt;&gt;&gt; import sys as zapzip &gt;&gt;&gt; foobar is zapzip True </code></pre> <p>The problem is,...
1
2009-10-30T16:05:27Z
[ "python" ]
Python: Object identity assertions thrown by differences in import statement notations
1,650,603
<p>When checking an object's identity, I am getting assertion errors because the object creation code imports the object-defining module under one notation (<code>base.other_stuff.BarCode</code>) and the identity-checking code imports that same module under a different notation (<code>other_stuff.BarCode</code>). (Ple...
1
2009-10-30T15:43:00Z
1,650,746
<p>You are having problems because you have both base and other_stuff in sys.path. </p> <p>To the Python interpreter there are multiple BarCode modules: <code>bar.other_stuff.BarCode</code> and <code>other_stuff.BarCode</code> the first is located in the top level package: <code>bar.other_stuff</code> and the other is...
1
2009-10-30T16:08:06Z
[ "python" ]
Designing the storage for a very large game world
1,650,627
<p>I'm starting up game programming again. 10 years ago I was making games in qbasic and I havn't done any game programming since, so I am quite rusty. I have been programming all the time though, I am web developer/DBA/admin now. I have several questions, but I'm going to limit it to one per post.</p> <p>The game I a...
7
2009-10-30T15:49:22Z
1,650,647
<p>Don't mess with relational databases unless you're forced to use them by external factors.</p> <p>Look at Python's <code>pickle</code>, <a href="http://docs.python.org/library/shelve.html">shelve</a>.</p> <p>Shelve is fast and scales well. It eliminates messy conversion between Python and non-Python representatio...
11
2009-10-30T15:53:29Z
[ "python", "sqlite", "python-3.x", "python-stackless" ]
Designing the storage for a very large game world
1,650,627
<p>I'm starting up game programming again. 10 years ago I was making games in qbasic and I havn't done any game programming since, so I am quite rusty. I have been programming all the time though, I am web developer/DBA/admin now. I have several questions, but I'm going to limit it to one per post.</p> <p>The game I a...
7
2009-10-30T15:49:22Z
1,650,860
<p>It sounds like what you're asking for is a type of <a href="http://en.wikipedia.org/wiki/Spatial%5Findex" rel="nofollow">spacial index</a>. For a very large 2d game I'd recommend using a <a href="http://en.wikipedia.org/wiki/Quadtree" rel="nofollow">quadtree</a>. Quadtree works well when you have a large area and ac...
3
2009-10-30T16:22:35Z
[ "python", "sqlite", "python-3.x", "python-stackless" ]
Designing the storage for a very large game world
1,650,627
<p>I'm starting up game programming again. 10 years ago I was making games in qbasic and I havn't done any game programming since, so I am quite rusty. I have been programming all the time though, I am web developer/DBA/admin now. I have several questions, but I'm going to limit it to one per post.</p> <p>The game I a...
7
2009-10-30T15:49:22Z
1,660,894
<p>I am using non-relationnal database to store big amounts of datas. If you can work on a 64 bits hardware, <a href="http://www.mongodb.org" rel="nofollow">MongoDB</a> with its <a href="http://pypi.python.org/pypi/pymongo/" rel="nofollow">Python driver</a> is really very good. I do not know if this is ok with Stackles...
1
2009-11-02T12:02:29Z
[ "python", "sqlite", "python-3.x", "python-stackless" ]
Get last function's call arguments from traceback?
1,650,713
<p>Can I get the parameters of the last function called in traceback? How?</p> <p>I want to make a catcher for standard errors to make readable code, yet provide detailed information to user.</p> <p>In the following example I want GET_PARAMS to return me a tuple of parameters supplied to os.chown. Examining the <code...
1
2009-10-30T16:02:46Z
1,650,759
<p>For such inspection tasks, always think first of module <a href="http://docs.python.org/library/inspect.html?highlight=inspect#module-inspect" rel="nofollow"><code>inspect</code></a> in the standard library. Here, <a href="http://docs.python.org/library/inspect.html?highlight=inspect#inspect.getargvalues" rel="nofo...
4
2009-10-30T16:09:46Z
[ "python", "exception-handling", "traceback" ]
Get last function's call arguments from traceback?
1,650,713
<p>Can I get the parameters of the last function called in traceback? How?</p> <p>I want to make a catcher for standard errors to make readable code, yet provide detailed information to user.</p> <p>In the following example I want GET_PARAMS to return me a tuple of parameters supplied to os.chown. Examining the <code...
1
2009-10-30T16:02:46Z
1,650,940
<p>The problem with using a decorator for what you're trying to achieve is that the frame the exception handler gets is <code>do_your_job()</code>s, not <code>os.listdir()</code>s, <code>os.makedirs()</code>s or <code>os.chown()</code>s. So the information you'll be printing out is the arguments to <code>do_your_job()...
0
2009-10-30T16:38:06Z
[ "python", "exception-handling", "traceback" ]
Get last function's call arguments from traceback?
1,650,713
<p>Can I get the parameters of the last function called in traceback? How?</p> <p>I want to make a catcher for standard errors to make readable code, yet provide detailed information to user.</p> <p>In the following example I want GET_PARAMS to return me a tuple of parameters supplied to os.chown. Examining the <code...
1
2009-10-30T16:02:46Z
1,650,970
<p>Here is an example of such function and some problems that you can't get around:</p> <pre><code>import sys def get_params(tb): while tb.tb_next: tb = tb.tb_next frame = tb.tb_frame code = frame.f_code argcount = code.co_argcount if code.co_flags &amp; 4: # *args argcount += 1 ...
3
2009-10-30T16:43:07Z
[ "python", "exception-handling", "traceback" ]
MS-Access Database getting very large during inserts
1,650,856
<p>I have a database which I regularly need to import large amounts of data into via some python scripts. Compacted, the data for a single months imports takes about 280mb, but during the import file size swells to over a gb.</p> <p>Given the 2gb size limit on mdb files, this is a bit of a concern. Apart from breaking...
1
2009-10-30T16:21:54Z
1,650,897
<p>A common trick, if feasible with regard to the schema and semantics of the application, is to have <strong>several MDB files with Linked tables</strong>.</p> <p>Also, <strong>the way the insertions take place matters</strong> with regards to the way the file size balloons... For example: batched, vs. one/few recor...
3
2009-10-30T16:28:55Z
[ "python", "ms-access" ]
MS-Access Database getting very large during inserts
1,650,856
<p>I have a database which I regularly need to import large amounts of data into via some python scripts. Compacted, the data for a single months imports takes about 280mb, but during the import file size swells to over a gb.</p> <p>Given the 2gb size limit on mdb files, this is a bit of a concern. Apart from breaking...
1
2009-10-30T16:21:54Z
1,651,257
<p>I find I am able to link from Access to Sqlite and to run a make table query to import the data. I used this ODBC Driver: <a href="http://www.ch-werner.de/sqliteodbc/" rel="nofollow">http://www.ch-werner.de/sqliteodbc/</a> and created User DNS. </p>
0
2009-10-30T17:34:28Z
[ "python", "ms-access" ]
MS-Access Database getting very large during inserts
1,650,856
<p>I have a database which I regularly need to import large amounts of data into via some python scripts. Compacted, the data for a single months imports takes about 280mb, but during the import file size swells to over a gb.</p> <p>Given the 2gb size limit on mdb files, this is a bit of a concern. Apart from breaking...
1
2009-10-30T16:21:54Z
1,651,412
<p>One thing to watch out for is records which are present in the append queries but aren't inserted into the data due to duplicate key values, null required fields, etc. Access will allocate the space taken by the records which aren't inserted.</p> <p>About the only significant thing I'm aware of is to ensure you h...
2
2009-10-30T18:04:43Z
[ "python", "ms-access" ]
MS-Access Database getting very large during inserts
1,650,856
<p>I have a database which I regularly need to import large amounts of data into via some python scripts. Compacted, the data for a single months imports takes about 280mb, but during the import file size swells to over a gb.</p> <p>Given the 2gb size limit on mdb files, this is a bit of a concern. Apart from breaking...
1
2009-10-30T16:21:54Z
1,651,537
<p>Are you sure row locking is turned off? In my case, turning off row locking reduced bloat by over a 100 megs when working on a 5 meg file. (in other words the file barley grew after turning off row locking to about 6 megs). With row locking on, the same operation results in a file well over 100 megs in size.</p> <...
3
2009-10-30T18:28:02Z
[ "python", "ms-access" ]
MS-Access Database getting very large during inserts
1,650,856
<p>I have a database which I regularly need to import large amounts of data into via some python scripts. Compacted, the data for a single months imports takes about 280mb, but during the import file size swells to over a gb.</p> <p>Given the 2gb size limit on mdb files, this is a bit of a concern. Apart from breaking...
1
2009-10-30T16:21:54Z
1,652,783
<p>Is your script executing a single INSERT statement per row of data? If so, pre-processing the data into a text file of many rows that could then be inserted with a single INSERT statement might improve the efficiency and cut down on the accumulating temporary crud that's causing it to bloat. </p> <p>You might also ...
1
2009-10-30T23:31:07Z
[ "python", "ms-access" ]
MS-Access Database getting very large during inserts
1,650,856
<p>I have a database which I regularly need to import large amounts of data into via some python scripts. Compacted, the data for a single months imports takes about 280mb, but during the import file size swells to over a gb.</p> <p>Given the 2gb size limit on mdb files, this is a bit of a concern. Apart from breaking...
1
2009-10-30T16:21:54Z
31,059,064
<p>File --> Options --> Current Database -> Check below options * Use the Cache format that is compatible with Microsoft Access 2010 and later * Clear Cache on Close</p> <p>Then, you file will be saved by compacting to the original size.</p>
-1
2015-06-25T19:23:51Z
[ "python", "ms-access" ]
IronPython to Original Python comparison. What can I expect from the first one?
1,650,898
<p>I wish to learn Python but I'm working all day in .Net as a C# developer, so I decided to download and install IronPython and integrated IronPython studio. How different or similar from the original Python it is? As a .Net developer can I expect to run conventional Python script in .Net environment with no problem o...
5
2009-10-30T16:29:00Z
1,650,918
<p>Most python scripts work perfectly well in IronPython. </p> <p>Here is a <a href="http://ironpython.codeplex.com/wikipage?title=List%20of%20Standard%20Library%20components%20not%20included%20in%20the%20MSI&amp;referringTitle=Home" rel="nofollow">list of packages and modules not included in IronPython</a> in the la...
1
2009-10-30T16:33:26Z
[ ".net", "python", "comparison", "ironpython", "ironpython-studio" ]
IronPython to Original Python comparison. What can I expect from the first one?
1,650,898
<p>I wish to learn Python but I'm working all day in .Net as a C# developer, so I decided to download and install IronPython and integrated IronPython studio. How different or similar from the original Python it is? As a .Net developer can I expect to run conventional Python script in .Net environment with no problem o...
5
2009-10-30T16:29:00Z
1,651,417
<p>In your situation it's perfectly reasonable to study IronPython (especially as <a href="http://www.manning.com/foord/" rel="nofollow">this book</a> does a great job helping you do that!). You'll have access to essentially all of Python 2.5 functionality (not sure when IronPython will upgrade to a 2.6 version of Pyt...
3
2009-10-30T18:05:33Z
[ ".net", "python", "comparison", "ironpython", "ironpython-studio" ]
Easier concurrency building blocks for Python?
1,650,921
<p>It seems that Python standard library lacks various useful concurrency-related concepts such as atomic counter, executor and others that can be found in e.g. java.util.concurrent. Are there any external libraries that would provide easier building blocks for concurrent Python applications?</p>
2
2009-10-30T16:34:16Z
1,650,936
<p>Concurrency in Python (at least CPython) and Java are wildly different, at least in part because of the Global Interpreter Lock (GIL). In general, concurrency in Python is achieved not with threads, but processes. See <a href="http://docs.python.org/library/multiprocessing.html" rel="nofollow"><code>multiprocessing<...
3
2009-10-30T16:37:00Z
[ "python", "multithreading", "concurrency" ]
Easier concurrency building blocks for Python?
1,650,921
<p>It seems that Python standard library lacks various useful concurrency-related concepts such as atomic counter, executor and others that can be found in e.g. java.util.concurrent. Are there any external libraries that would provide easier building blocks for concurrent Python applications?</p>
2
2009-10-30T16:34:16Z
1,650,937
<p><a href="http://www.kamaelia.org/Home" rel="nofollow">kamaelia</a> provides tools for abstracting concurrency to threads or process etc.</p>
3
2009-10-30T16:37:14Z
[ "python", "multithreading", "concurrency" ]
Easier concurrency building blocks for Python?
1,650,921
<p>It seems that Python standard library lacks various useful concurrency-related concepts such as atomic counter, executor and others that can be found in e.g. java.util.concurrent. Are there any external libraries that would provide easier building blocks for concurrent Python applications?</p>
2
2009-10-30T16:34:16Z
1,651,347
<p>Although it may not be immediately obvious, <a href="http://docs.python.org/library/itertools.html?highlight=itertools.count#itertools.count" rel="nofollow">itertools.count</a> <strong>is</strong> indeed an atomic counter (the <strong>only</strong> operation on an instance <code>x</code> thereof, spelled <code>next(...
5
2009-10-30T17:51:15Z
[ "python", "multithreading", "concurrency" ]
Easier concurrency building blocks for Python?
1,650,921
<p>It seems that Python standard library lacks various useful concurrency-related concepts such as atomic counter, executor and others that can be found in e.g. java.util.concurrent. Are there any external libraries that would provide easier building blocks for concurrent Python applications?</p>
2
2009-10-30T16:34:16Z
1,651,387
<p>Kamaelia, as already mentioned, is aimed at making concurrency easier to work with in python.</p> <p>Its original use case was network systems (which are a naturally concurrent) and developed with the viewpoint "How can we make these systems easier to develop and maintain".</p> <p>Since then life has moved on and ...
5
2009-10-30T17:59:55Z
[ "python", "multithreading", "concurrency" ]
Easier concurrency building blocks for Python?
1,650,921
<p>It seems that Python standard library lacks various useful concurrency-related concepts such as atomic counter, executor and others that can be found in e.g. java.util.concurrent. Are there any external libraries that would provide easier building blocks for concurrent Python applications?</p>
2
2009-10-30T16:34:16Z
37,437,443
<p><a href="https://github.com/ajpen/P-Workers" rel="nofollow">P-workers</a> creates a "Job-Worker" abstraction over the python multiprocessing library. It simplifies concurrency with multiprocessing by starting "Workers" that have specific skills/attributes (defined functions), and providing a queue where they receive...
0
2016-05-25T12:39:14Z
[ "python", "multithreading", "concurrency" ]
Why are default arguments evaluated at definition time in Python?
1,651,154
<p>I had a very difficult time with understanding the root cause of a problem in an algorithm. Then, by simplifying the functions step by step I found out that evaluation of default arguments in Python doesn't behave as I expected.</p> <p>The code is as follows:</p> <pre><code>class Node(object): def __init__(sel...
27
2009-10-30T17:16:08Z
1,651,192
<p>Python function definitions are just code, like all the other code; they're not "magical" in the way that some languages are. For example, in Java you could refer "now" to something defined "later":</p> <pre><code>public static void foo() { bar(); } public static void main(String[] args) { foo(); } public static vo...
1
2009-10-30T17:21:59Z
[ "python", "logic", "language-design" ]
Why are default arguments evaluated at definition time in Python?
1,651,154
<p>I had a very difficult time with understanding the root cause of a problem in an algorithm. Then, by simplifying the functions step by step I found out that evaluation of default arguments in Python doesn't behave as I expected.</p> <p>The code is as follows:</p> <pre><code>class Node(object): def __init__(sel...
27
2009-10-30T17:16:08Z
1,651,196
<p>The workaround for this, <a href="http://www.network-theory.co.uk/docs/pytut/DefaultArgumentValues.html">discussed here</a> (and very solid), is:</p> <pre><code>class Node(object): def __init__(self, children = None): self.children = [] if children is None else children </code></pre> <p>As for why look...
7
2009-10-30T17:22:21Z
[ "python", "logic", "language-design" ]
Why are default arguments evaluated at definition time in Python?
1,651,154
<p>I had a very difficult time with understanding the root cause of a problem in an algorithm. Then, by simplifying the functions step by step I found out that evaluation of default arguments in Python doesn't behave as I expected.</p> <p>The code is as follows:</p> <pre><code>class Node(object): def __init__(sel...
27
2009-10-30T17:16:08Z
1,651,220
<p>Of course in your situation it is difficult to understand. But you must see, that evaluating default args every time would lay a heavy runtime burden on the system.</p> <p>Also you should know, that in case of container types this problem may occur -- but you could circumvent it by making the thing explicit:</p> <...
7
2009-10-30T17:26:59Z
[ "python", "logic", "language-design" ]
Why are default arguments evaluated at definition time in Python?
1,651,154
<p>I had a very difficult time with understanding the root cause of a problem in an algorithm. Then, by simplifying the functions step by step I found out that evaluation of default arguments in Python doesn't behave as I expected.</p> <p>The code is as follows:</p> <pre><code>class Node(object): def __init__(sel...
27
2009-10-30T17:16:08Z
1,651,270
<p>This comes from python's emphasis on syntax and execution simplicity. a def statement occurs at a certain point during execution. When the python interpreter reaches that point, it evaluates the code in that line, and then creates a code object from the body of the function, which will be run later, when you call ...
4
2009-10-30T17:35:47Z
[ "python", "logic", "language-design" ]
Why are default arguments evaluated at definition time in Python?
1,651,154
<p>I had a very difficult time with understanding the root cause of a problem in an algorithm. Then, by simplifying the functions step by step I found out that evaluation of default arguments in Python doesn't behave as I expected.</p> <p>The code is as follows:</p> <pre><code>class Node(object): def __init__(sel...
27
2009-10-30T17:16:08Z
1,651,280
<p>The issue is this.</p> <p>It's too expensive to evaluate a function as an initializer <strong>every time the function is called</strong>.</p> <ul> <li><p><code>0</code> is a simple literal. Evaluate it once, use it forever.</p></li> <li><p><code>int</code> is a function (like list) that would have to be evaluated...
10
2009-10-30T17:36:59Z
[ "python", "logic", "language-design" ]
Why are default arguments evaluated at definition time in Python?
1,651,154
<p>I had a very difficult time with understanding the root cause of a problem in an algorithm. Then, by simplifying the functions step by step I found out that evaluation of default arguments in Python doesn't behave as I expected.</p> <p>The code is as follows:</p> <pre><code>class Node(object): def __init__(sel...
27
2009-10-30T17:16:08Z
1,651,284
<p>The alternative would be quite heavyweight -- storing "default argument values" in the function object as "thunks" of code to be executed over and over again every time the function is called without a specified value for that argument -- and would make it much harder to get early binding (binding at def time), whic...
35
2009-10-30T17:37:32Z
[ "python", "logic", "language-design" ]
Why are default arguments evaluated at definition time in Python?
1,651,154
<p>I had a very difficult time with understanding the root cause of a problem in an algorithm. Then, by simplifying the functions step by step I found out that evaluation of default arguments in Python doesn't behave as I expected.</p> <p>The code is as follows:</p> <pre><code>class Node(object): def __init__(sel...
27
2009-10-30T17:16:08Z
1,652,733
<p>I thought this was counterintuitive too, until I learned how Python implements default arguments.</p> <p>A function's an object. At load time, Python creates the function object, evaluates the defaults in the <code>def</code> statement, puts them into a tuple, and adds that tuple as an attribute of the function na...
5
2009-10-30T23:10:01Z
[ "python", "logic", "language-design" ]
Why are default arguments evaluated at definition time in Python?
1,651,154
<p>I had a very difficult time with understanding the root cause of a problem in an algorithm. Then, by simplifying the functions step by step I found out that evaluation of default arguments in Python doesn't behave as I expected.</p> <p>The code is as follows:</p> <pre><code>class Node(object): def __init__(sel...
27
2009-10-30T17:16:08Z
1,652,835
<p>Because if they had, then someone would post a question asking why it wasn't the other way around :-p</p> <p>Suppose now that they had. How would you implement the current behaviour if needed? It's easy to create new objects inside a function, but you cannot "uncreate" them (you can delete them, but it's not the sa...
0
2009-10-30T23:48:31Z
[ "python", "logic", "language-design" ]
Python, creating triplets from array of words
1,651,386
<p>Let's say I have an array or list of words, something like this:</p> <pre><code>[The,Quick,Brown,Fox,Jumps,Over,The,Lazy,Dog] </code></pre> <p>I'd like to generate an array of arrays, with each array containing 3 of the words, but with a possible triplet for each one. so it should look something like this:</p> <p...
1
2009-10-30T17:59:37Z
1,651,407
<pre><code>&gt;&gt;&gt; words ['The', 'Quick', 'Brown', 'Fox', 'Jumps', 'Over', 'The', 'Lazy', 'Dog'] &gt;&gt;&gt; [words[i:i+3] for i in range(len(words) - 2)] [['The', 'Quick', 'Brown'], ['Quick', 'Brown', 'Fox'], ['Brown', 'Fox', 'Jumps'], ['Fox', 'Jumps', 'Over'], ['Jumps', 'Over', 'The'], ['Over', 'The', 'Lazy'], ...
5
2009-10-30T18:03:54Z
[ "python", "arrays" ]
Python, creating triplets from array of words
1,651,386
<p>Let's say I have an array or list of words, something like this:</p> <pre><code>[The,Quick,Brown,Fox,Jumps,Over,The,Lazy,Dog] </code></pre> <p>I'd like to generate an array of arrays, with each array containing 3 of the words, but with a possible triplet for each one. so it should look something like this:</p> <p...
1
2009-10-30T17:59:37Z
1,651,409
<p>Without knowing why you want to do this or how many times it needs to be done, I'd say just slice it. </p>
0
2009-10-30T18:03:58Z
[ "python", "arrays" ]
Python, creating triplets from array of words
1,651,386
<p>Let's say I have an array or list of words, something like this:</p> <pre><code>[The,Quick,Brown,Fox,Jumps,Over,The,Lazy,Dog] </code></pre> <p>I'd like to generate an array of arrays, with each array containing 3 of the words, but with a possible triplet for each one. so it should look something like this:</p> <p...
1
2009-10-30T17:59:37Z
1,651,410
<pre><code>b = [a[i:i+3] for i in range(len(a)-2)] </code></pre>
5
2009-10-30T18:04:01Z
[ "python", "arrays" ]
Python, creating triplets from array of words
1,651,386
<p>Let's say I have an array or list of words, something like this:</p> <pre><code>[The,Quick,Brown,Fox,Jumps,Over,The,Lazy,Dog] </code></pre> <p>I'd like to generate an array of arrays, with each array containing 3 of the words, but with a possible triplet for each one. so it should look something like this:</p> <p...
1
2009-10-30T17:59:37Z
1,651,475
<p>With sliceable sequences such as lists, the answers already given work fine. For the general case in which the words come in any iterable (be it a sequence, a file, whatever):</p> <pre><code>def NbyN(seq, N=3): it = iter(seq) window = [next(it) for _ in range(N)] while True: yield window window = wi...
3
2009-10-30T18:16:25Z
[ "python", "arrays" ]
Python Array is read-only, can't append values
1,651,430
<p>I am new to Python. The following code is causing an error when it attempts to append values to an array. What am I doing wrong?</p> <pre><code>import re from array import array freq_pattern = re.compile("Frequency of Incident[\(\)A-Za-z\s]*\.*\s*([\.0-9]*)") col_pattern = re.compile("([-\.0-9]+)\s+([-\.0-9]+)\s...
3
2009-10-30T18:08:28Z
1,651,440
<p>Do you want to append to the array?</p> <pre><code>e_rcs.append( float(cols.group(2)) ) </code></pre> <p>Doing this: <code>e_rcs.append = float(cols.group(2))</code> replaces the <code>append</code> method of the array <code>e-rcs</code> with a floating-point value. Rarely something you want to do.</p>
6
2009-10-30T18:10:08Z
[ "python", "arrays" ]
Python Array is read-only, can't append values
1,651,430
<p>I am new to Python. The following code is causing an error when it attempts to append values to an array. What am I doing wrong?</p> <pre><code>import re from array import array freq_pattern = re.compile("Frequency of Incident[\(\)A-Za-z\s]*\.*\s*([\.0-9]*)") col_pattern = re.compile("([-\.0-9]+)\s+([-\.0-9]+)\s...
3
2009-10-30T18:08:28Z
1,651,446
<p>append is a method. You're trying to overwrite it instead of calling it.</p> <pre><code>e_rcs.append(float(cols.group(2))) </code></pre>
3
2009-10-30T18:11:42Z
[ "python", "arrays" ]
Python Array is read-only, can't append values
1,651,430
<p>I am new to Python. The following code is causing an error when it attempts to append values to an array. What am I doing wrong?</p> <pre><code>import re from array import array freq_pattern = re.compile("Frequency of Incident[\(\)A-Za-z\s]*\.*\s*([\.0-9]*)") col_pattern = re.compile("([-\.0-9]+)\s+([-\.0-9]+)\s...
3
2009-10-30T18:08:28Z
1,651,448
<p>You are assigning to the append() function, you want instead to call .append(float(cols.group(2))).</p>
6
2009-10-30T18:12:01Z
[ "python", "arrays" ]
Python Array is read-only, can't append values
1,651,430
<p>I am new to Python. The following code is causing an error when it attempts to append values to an array. What am I doing wrong?</p> <pre><code>import re from array import array freq_pattern = re.compile("Frequency of Incident[\(\)A-Za-z\s]*\.*\s*([\.0-9]*)") col_pattern = re.compile("([-\.0-9]+)\s+([-\.0-9]+)\s...
3
2009-10-30T18:08:28Z
1,651,911
<p>Try this instead:</p> <pre><code>import re freq_pattern = re.compile("Frequency of Incident[\(\)A-Za-z\s]*\.*\s*([\.0-9]*)") col_pattern = re.compile("([-\.0-9]+)\s+([-\.0-9]+)\s+([-\.0-9]+)\s+([-\.0-9]+)\s+([-\.0-9]+)") e_rcs = [] # make an empty list f = open('example.4.out', 'r') for line in f: print line...
0
2009-10-30T19:44:42Z
[ "python", "arrays" ]
Python parsing bracketed blocks
1,651,487
<p>What would be the best way in Python to parse out chunks of text contained in matching brackets?</p> <pre><code>"{ { a } { b } { { { c } } } }" </code></pre> <p>should initially return:</p> <pre><code>[ "{ a } { b } { { { c } } }" ] </code></pre> <p>putting that as an input should return:</p> <pre><code>[ "a", ...
19
2009-10-30T18:18:26Z
1,651,562
<p>Pseudocode:</p> <pre><code>For each string in the array: Find the first '{'. If there is none, leave that string alone. Init a counter to 0. For each character in the string: If you see a '{', increment the counter. If you see a '}', decrement the counter. If the counter reach...
16
2009-10-30T18:35:28Z
[ "python", "parsing", "text-parsing", "brackets" ]
Python parsing bracketed blocks
1,651,487
<p>What would be the best way in Python to parse out chunks of text contained in matching brackets?</p> <pre><code>"{ { a } { b } { { { c } } } }" </code></pre> <p>should initially return:</p> <pre><code>[ "{ a } { b } { { { c } } }" ] </code></pre> <p>putting that as an input should return:</p> <pre><code>[ "a", ...
19
2009-10-30T18:18:26Z
1,651,840
<p>I'm kind of new to Python, so go easy on me, but here is an implementation that works:</p> <pre><code>def balanced_braces(args): parts = [] for arg in args: if '{' not in arg: continue chars = [] n = 0 for c in arg: if c == '{': if n &g...
5
2009-10-30T19:26:54Z
[ "python", "parsing", "text-parsing", "brackets" ]
Python parsing bracketed blocks
1,651,487
<p>What would be the best way in Python to parse out chunks of text contained in matching brackets?</p> <pre><code>"{ { a } { b } { { { c } } } }" </code></pre> <p>should initially return:</p> <pre><code>[ "{ a } { b } { { { c } } }" ] </code></pre> <p>putting that as an input should return:</p> <pre><code>[ "a", ...
19
2009-10-30T18:18:26Z
1,651,896
<p>You could also parse them all at once, though I find the <code>{a}</code> to mean <code>"a"</code> rather than <code>["a"]</code> slightly weird. If I've understood the format correctly:</p> <pre><code>import re import sys _mbrack_rb = re.compile("([^{}]*)}") # re.match doesn't have a pos parameter def mbrack(s)...
2
2009-10-30T19:42:02Z
[ "python", "parsing", "text-parsing", "brackets" ]
Python parsing bracketed blocks
1,651,487
<p>What would be the best way in Python to parse out chunks of text contained in matching brackets?</p> <pre><code>"{ { a } { b } { { { c } } } }" </code></pre> <p>should initially return:</p> <pre><code>[ "{ a } { b } { { { c } } }" ] </code></pre> <p>putting that as an input should return:</p> <pre><code>[ "a", ...
19
2009-10-30T18:18:26Z
1,652,856
<p>Parse using <a href="http://code.google.com/p/lepl/" rel="nofollow"><code>lepl</code></a> (installable via <code>$ easy_install lepl</code>):</p> <pre><code>from lepl import Any, Delayed, Node, Space expr = Delayed() expr += '{' / (Any() | expr[1:,Space()[:]]) / '}' &gt; Node print expr.parse("{{a}{b}{{{c}}}}")[0...
5
2009-10-30T23:54:44Z
[ "python", "parsing", "text-parsing", "brackets" ]
Python parsing bracketed blocks
1,651,487
<p>What would be the best way in Python to parse out chunks of text contained in matching brackets?</p> <pre><code>"{ { a } { b } { { { c } } } }" </code></pre> <p>should initially return:</p> <pre><code>[ "{ a } { b } { { { c } } }" ] </code></pre> <p>putting that as an input should return:</p> <pre><code>[ "a", ...
19
2009-10-30T18:18:26Z
1,653,143
<p>Or this pyparsing version:</p> <pre><code>&gt;&gt;&gt; from pyparsing import nestedExpr &gt;&gt;&gt; txt = "{ { a } { b } { { { c } } } }" &gt;&gt;&gt; &gt;&gt;&gt; nestedExpr('{','}').parseString(txt).asList() [[['a'], ['b'], [[['c']]]]] &gt;&gt;&gt; </code></pre>
29
2009-10-31T01:50:04Z
[ "python", "parsing", "text-parsing", "brackets" ]
Python parsing bracketed blocks
1,651,487
<p>What would be the best way in Python to parse out chunks of text contained in matching brackets?</p> <pre><code>"{ { a } { b } { { { c } } } }" </code></pre> <p>should initially return:</p> <pre><code>[ "{ a } { b } { { { c } } }" ] </code></pre> <p>putting that as an input should return:</p> <pre><code>[ "a", ...
19
2009-10-30T18:18:26Z
1,654,264
<p>If you want to use a parser (lepl in this case), but still want the intermediate results rather than a final parsed list, then I think this is the kind of thing you were looking for:</p> <pre><code>&gt;&gt;&gt; nested = Delayed() &gt;&gt;&gt; nested += "{" + (nested[1:,...]|Any()) + "}" &gt;&gt;&gt; split = (Drop("...
2
2009-10-31T12:38:37Z
[ "python", "parsing", "text-parsing", "brackets" ]
Python parsing bracketed blocks
1,651,487
<p>What would be the best way in Python to parse out chunks of text contained in matching brackets?</p> <pre><code>"{ { a } { b } { { { c } } } }" </code></pre> <p>should initially return:</p> <pre><code>[ "{ a } { b } { { { c } } }" ] </code></pre> <p>putting that as an input should return:</p> <pre><code>[ "a", ...
19
2009-10-30T18:18:26Z
2,780,461
<p>Cleaner solution. This will find return the string enclosed in the outermost bracket. If None is returned, there was no match.</p> <pre><code>def findBrackets( aString ): if '{' in aString: match = aString.split('{',1)[1] open = 1 for index in xrange(len(match)): if match[index] in '...
1
2010-05-06T10:51:05Z
[ "python", "parsing", "text-parsing", "brackets" ]
Python parsing bracketed blocks
1,651,487
<p>What would be the best way in Python to parse out chunks of text contained in matching brackets?</p> <pre><code>"{ { a } { b } { { { c } } } }" </code></pre> <p>should initially return:</p> <pre><code>[ "{ a } { b } { { { c } } }" ] </code></pre> <p>putting that as an input should return:</p> <pre><code>[ "a", ...
19
2009-10-30T18:18:26Z
26,205,763
<p>Using <a href="https://bitbucket.org/apalala/grako/overview" rel="nofollow">Grako (grammar compiler)</a>:</p> <pre><code>#!/usr/bin/env python import json import grako # $ pip install grako grammar_ebnf = """ bracketed = '{' @:( { bracketed }+ | any ) '}' ; any = /[^{}]+?/ ; """ model = grako.genmodel("Bra...
1
2014-10-05T18:17:45Z
[ "python", "parsing", "text-parsing", "brackets" ]
Python parsing bracketed blocks
1,651,487
<p>What would be the best way in Python to parse out chunks of text contained in matching brackets?</p> <pre><code>"{ { a } { b } { { { c } } } }" </code></pre> <p>should initially return:</p> <pre><code>[ "{ a } { b } { { { c } } }" ] </code></pre> <p>putting that as an input should return:</p> <pre><code>[ "a", ...
19
2009-10-30T18:18:26Z
27,361,157
<p>Here is a solution I came up with for a similar use case. This was loosely based on the accepted psuedo code answer. I didn't want to add any dependencies for external libraries:</p> <pre><code>def parse_segments(source, recurse=False): """ extract any substring enclosed in parenthesis source should be ...
0
2014-12-08T15:22:17Z
[ "python", "parsing", "text-parsing", "brackets" ]
Does python twisted framework HttpClient access proxy?
1,651,527
<p>I need to access a webpage using</p> <pre><code>twisted.web.client.getPage() </code></pre> <p>or a similar method to download a webpage from a known address (ie:www.google.com), the problem is: I am behind a proxy server and I couldn't find anywhere explanations on how to configure twisted or factories to use my p...
3
2009-10-30T18:26:25Z
1,653,122
<pre><code>from twisted.internet import reactor from twisted.web import client def processResult(page): print "I got some data", repr(page) reactor.callLater(0.1, reactor.stop) def dealWithError(err): print err.getErrorMessage() reactor.callLater(0.1, reactor.stop) class ProxyClientFactory(client.HTTP...
3
2009-10-31T01:37:57Z
[ "python", "proxy", "networking", "twisted" ]
Does python twisted framework HttpClient access proxy?
1,651,527
<p>I need to access a webpage using</p> <pre><code>twisted.web.client.getPage() </code></pre> <p>or a similar method to download a webpage from a known address (ie:www.google.com), the problem is: I am behind a proxy server and I couldn't find anywhere explanations on how to configure twisted or factories to use my p...
3
2009-10-30T18:26:25Z
1,698,925
<p>To get nosklo's solution to work you will need to create another handler for the '401' that indicates that authentication is required. Try something like this</p> <pre><code>def checkAuthError(self,failure,url): failure.trap(error.Error) if failure.value.status == '401': username = raw_input("User n...
1
2009-11-09T03:19:24Z
[ "python", "proxy", "networking", "twisted" ]
Does python twisted framework HttpClient access proxy?
1,651,527
<p>I need to access a webpage using</p> <pre><code>twisted.web.client.getPage() </code></pre> <p>or a similar method to download a webpage from a known address (ie:www.google.com), the problem is: I am behind a proxy server and I couldn't find anywhere explanations on how to configure twisted or factories to use my p...
3
2009-10-30T18:26:25Z
8,012,453
<p>We chose to use the <code>http_proxy</code> environment variable. We were having trouble with redirections not always getting picked up, or rather getting picked up in the right way. That said, <code>nosklo</code>'s response <em>really</em> helped!</p> <pre><code>import os from twisted.web import client class Prox...
0
2011-11-04T16:20:37Z
[ "python", "proxy", "networking", "twisted" ]
Does python twisted framework HttpClient access proxy?
1,651,527
<p>I need to access a webpage using</p> <pre><code>twisted.web.client.getPage() </code></pre> <p>or a similar method to download a webpage from a known address (ie:www.google.com), the problem is: I am behind a proxy server and I couldn't find anywhere explanations on how to configure twisted or factories to use my p...
3
2009-10-30T18:26:25Z
8,523,455
<p>I had to do something similar using base auth, since the example code for the auth request did not work here is a version that works:</p> <pre><code>import base64 from twisted.internet import defer, reactor from twisted.web import client, error, http from ubuntuone.devtools.testcases.squid import SquidTestCase #...
1
2011-12-15T16:35:45Z
[ "python", "proxy", "networking", "twisted" ]
Python and factories
1,651,593
<p>I cant seem to grasp the proper concepts of a factory.</p> <p>Can anyone help me code a simple test? I read some texts over the internet and cant code it the same way. Actually i cant understand the process. Copying code is easy, but i need to learn why this wont work.</p> <pre><code>class Factory: def __init...
5
2009-10-30T18:41:06Z
1,651,657
<p>Your fabricate method should look like this:</p> <pre><code> def fabricateAnotherObject(self, obj, *args): return apply(obj, args) </code></pre> <p>apply() takes in a list of args. By taking in *args in your fabricateAnotherObject method, you consume all parameters beyond obj as a list that can be passe...
0
2009-10-30T18:52:42Z
[ "python", "oop", "factory" ]
Python and factories
1,651,593
<p>I cant seem to grasp the proper concepts of a factory.</p> <p>Can anyone help me code a simple test? I read some texts over the internet and cant code it the same way. Actually i cant understand the process. Copying code is easy, but i need to learn why this wont work.</p> <pre><code>class Factory: def __init...
5
2009-10-30T18:41:06Z
1,651,707
<p>Your code is counter-productive (sorry, I must say it).</p> <p>The sense of a factory is, that you don't have to know the class of your constructed object at the position where you create it.</p> <p>The reason is, that object creation creates a gap in object oriented abstraction. You must be concrete in creating t...
13
2009-10-30T18:59:44Z
[ "python", "oop", "factory" ]
Python and factories
1,651,593
<p>I cant seem to grasp the proper concepts of a factory.</p> <p>Can anyone help me code a simple test? I read some texts over the internet and cant code it the same way. Actually i cant understand the process. Copying code is easy, but i need to learn why this wont work.</p> <pre><code>class Factory: def __init...
5
2009-10-30T18:41:06Z
1,658,544
<p>Factory pattern is intended for programming languages that don't allow functions (and classes) as first-order values (such as C++ or Java).</p> <p>The idea is that you pass an instance of a "factory" class as an argument to some function (or method or constructor), which is then used to produce new object instances...
4
2009-11-01T22:10:27Z
[ "python", "oop", "factory" ]
Python and factories
1,651,593
<p>I cant seem to grasp the proper concepts of a factory.</p> <p>Can anyone help me code a simple test? I read some texts over the internet and cant code it the same way. Actually i cant understand the process. Copying code is easy, but i need to learn why this wont work.</p> <pre><code>class Factory: def __init...
5
2009-10-30T18:41:06Z
1,742,441
<p>See also <a href="http://docs.python.org/library/functions.html#type" rel="nofollow">type()</a> in docs.python.org/library/functions:</p> <p>type(name, bases, dict)</p> <p>Return a new type object. This is essentially a dynamic form of the class statement. The name string is the class name and becomes the __name__...
0
2009-11-16T14:18:16Z
[ "python", "oop", "factory" ]
Verify key is correct using pyCrypto AES decryption
1,652,127
<p>How do I verify the correct key is being used to decrypt AES encrypted data using pyCrypto AES?</p> <pre><code>cipher = AES.new(key, AES.MODE_CFB) cipher.decrypt(s) </code></pre> <p>If an incorrect key is used, it still attempts to decrypt the data, obfuscating it more. Is there any test I can do to prove the data...
1
2009-10-30T20:31:11Z
1,652,153
<p><strong>I don't believe you can</strong> [tell if the key is correct], <em>with the AES context alone</em>.<br> i.e. you can't, other than by verifying the format and/or some message digest value for the clear text after it is decoded, which implies that you know such structure or message digest.</p> <p>Although th...
2
2009-10-30T20:35:24Z
[ "python", "cryptography", "aes", "encryption" ]
Verify key is correct using pyCrypto AES decryption
1,652,127
<p>How do I verify the correct key is being used to decrypt AES encrypted data using pyCrypto AES?</p> <pre><code>cipher = AES.new(key, AES.MODE_CFB) cipher.decrypt(s) </code></pre> <p>If an incorrect key is used, it still attempts to decrypt the data, obfuscating it more. Is there any test I can do to prove the data...
1
2009-10-30T20:31:11Z
1,654,247
<p>You could use <a href="http://en.wikipedia.org/wiki/CMAC" rel="nofollow">Cipher-based Message Authentication Code (CMAC)</a> or maybe an <a href="http://en.wikipedia.org/wiki/HMAC" rel="nofollow">HMAC (Hash-based Message Authentication Code)</a> (if you have a hash function available).</p> <p>There are defined ways...
8
2009-10-31T12:32:44Z
[ "python", "cryptography", "aes", "encryption" ]
Verify key is correct using pyCrypto AES decryption
1,652,127
<p>How do I verify the correct key is being used to decrypt AES encrypted data using pyCrypto AES?</p> <pre><code>cipher = AES.new(key, AES.MODE_CFB) cipher.decrypt(s) </code></pre> <p>If an incorrect key is used, it still attempts to decrypt the data, obfuscating it more. Is there any test I can do to prove the data...
1
2009-10-30T20:31:11Z
2,465,222
<p>Take a look at this blog post, it includes example code for doing what you need (ie. CRC)<br/> <a href="http://www.turnkeylinux.org/blog/python-symmetric-encryption" rel="nofollow">Python symmetric encryption with CRC</a></p>
0
2010-03-17T19:25:38Z
[ "python", "cryptography", "aes", "encryption" ]
Widget Transparency in PyGTK?
1,652,779
<p>What is the best way to have transparency of specific widgets in a PyGTK application? I do not want to use themes because the transparency of each of the widgets will be changing through animation.</p> <p>The only thing I can find is to use cairo to draw widgets with an Alpha, but I can't figure out how to do this....
0
2009-10-30T23:29:50Z
1,652,873
<p>Assuming that your program runs under composition manager, you could get per-widget transparency by manipulating widget's X window. Look at <a href="http://www.pygtk.org/docs/pygtk/class-gdkwindow.html#method-gdkwindow--set-opacity" rel="nofollow">gtk.gdk.Window.set_opacity()</a>.</p> <p>Note, it is not <code>gtk.W...
3
2009-10-30T23:58:04Z
[ "python", "linux", "gtk", "pygtk", "cairo" ]
How do I automatically rebuild the Sphinx index under django-sphinx?
1,653,071
<p>I just setup django-sphinx, and it is working beautifully. I am now able to search my model and get amazing results. The one problem is that I have to build the index by hand using the indexer command. That means every time I add new content, I have to manually hit the command line to rebuild the search index. That ...
2
2009-10-31T01:18:27Z
1,653,731
<p>There are basically two primary strategies for building search indexes:</p> <ol> <li>Indexer <strong>internal</strong> to a database server, which indexes on the fly as records are inserted or deleted.</li> <li>Indexer <strong>external</strong> to the database (which may or may not be a RDMS which is why I leave of...
5
2009-10-31T07:54:13Z
[ "python", "django", "search", "sphinx", "django-sphinx" ]
How do I automatically rebuild the Sphinx index under django-sphinx?
1,653,071
<p>I just setup django-sphinx, and it is working beautifully. I am now able to search my model and get amazing results. The one problem is that I have to build the index by hand using the indexer command. That means every time I add new content, I have to manually hit the command line to rebuild the search index. That ...
2
2009-10-31T01:18:27Z
2,657,021
<p>The above sounds right to me, though I'll mention that you could call the indexer from your save function for the object.</p> <p>It'd probably get called a LOT, but it could work. Just call it as you would any external command.</p>
0
2010-04-17T02:46:22Z
[ "python", "django", "search", "sphinx", "django-sphinx" ]
Install PyObjC on Python 2.6 on OS X 10.5?
1,653,153
<p>OS X 10.5.8 came with Python 2.5, and had PyObjC already installed.</p> <p>I installed Python 2.6 from the python.org site, and PyObjC isn't there.</p> <p>I can't find a download to install PyObjC on my Python 2.6 install. Is checking out the PyObjC trunk and trying to build it my only choice? Will that work "ou...
1
2009-10-31T01:55:13Z
1,653,175
<p>If your goal is to write software that will work on other people's computers, you shouldn't touch the default Python installation. If you simply cannot live without 2.6, then you're responsible for re-creating everything on your own, and that's not going to be a point-and-click process by any means. </p>
0
2009-10-31T02:08:40Z
[ "python", "osx", "installer", "pyobjc" ]
Install PyObjC on Python 2.6 on OS X 10.5?
1,653,153
<p>OS X 10.5.8 came with Python 2.5, and had PyObjC already installed.</p> <p>I installed Python 2.6 from the python.org site, and PyObjC isn't there.</p> <p>I can't find a download to install PyObjC on my Python 2.6 install. Is checking out the PyObjC trunk and trying to build it my only choice? Will that work "ou...
1
2009-10-31T01:55:13Z
1,653,364
<p>Apple includes <code>PyObjC</code> with their Pythons that come with <code>OS X 10.5</code> and <code>10.6</code>. It is not part of the python.org installers. But it should be easy enough to install. Just install <code>setuptools</code> to the python.org python 2.6 following the instructions <a href="http://pypi...
1
2009-10-31T04:03:34Z
[ "python", "osx", "installer", "pyobjc" ]
Install PyObjC on Python 2.6 on OS X 10.5?
1,653,153
<p>OS X 10.5.8 came with Python 2.5, and had PyObjC already installed.</p> <p>I installed Python 2.6 from the python.org site, and PyObjC isn't there.</p> <p>I can't find a download to install PyObjC on my Python 2.6 install. Is checking out the PyObjC trunk and trying to build it my only choice? Will that work "ou...
1
2009-10-31T01:55:13Z
1,655,073
<p>You should probably try to build PyObjC from trunk, which will work fine on the official Python 2.6 distribution, but not on Python 2.5. There are quite a lot of fixes in the trunk right now that weren't in 2.2b2, which afaik. is the most current version available through easy_install.</p> <p>There are some little...
1
2009-10-31T17:47:33Z
[ "python", "osx", "installer", "pyobjc" ]
Cross-Platform Programming Language with a decent gui toolkit?
1,653,419
<p>For the program idea I have, it requires that the software be written in one binary that is executeable by all major desktop platforms, meaning it needs an interpreted language or a language within a JVM. Either is fine with me, but the programming language has to balance power &amp; simplicity (e.g. Python)</p> <p...
4
2009-10-31T04:34:48Z
1,653,424
<p>You could use <a href="http://groovy.codehaus.org/Swing+Builder" rel="nofollow">Groovy</a> to work around the Java complexities.</p> <p>Still you'll need good foundations of Swing. </p> <p>While the learning curve may be steep, the trade of of not having to completely re-write the whole application again for the n...
2
2009-10-31T04:37:47Z
[ "java", "python", "cross-platform", "wxpython", "multiplatform" ]
Cross-Platform Programming Language with a decent gui toolkit?
1,653,419
<p>For the program idea I have, it requires that the software be written in one binary that is executeable by all major desktop platforms, meaning it needs an interpreted language or a language within a JVM. Either is fine with me, but the programming language has to balance power &amp; simplicity (e.g. Python)</p> <p...
4
2009-10-31T04:34:48Z
1,653,433
<p>I used Python with wxPython for quite a while and found it very easy to use. I now use Java with both Swing and SWT.</p> <p>I prefer Java but that's just a personal preference so you shouldn't let that sway you.</p> <p>I didn't find the transition from Python to Java that difficult. In terms of GUI, they both have...
6
2009-10-31T04:43:05Z
[ "java", "python", "cross-platform", "wxpython", "multiplatform" ]
Cross-Platform Programming Language with a decent gui toolkit?
1,653,419
<p>For the program idea I have, it requires that the software be written in one binary that is executeable by all major desktop platforms, meaning it needs an interpreted language or a language within a JVM. Either is fine with me, but the programming language has to balance power &amp; simplicity (e.g. Python)</p> <p...
4
2009-10-31T04:34:48Z
1,653,435
<ul> <li><p>You can use any of languages targeting JVM, e.g. Jython (Python impl) and JRuby (Ruby impl).</p></li> <li><p>You can try using <a href="http://wiki.python.org/moin/PyQt" rel="nofollow">Qt bindings</a> for Python, Qt <a href="http://doc.trolltech.com/3.3/qtmac-as-native.html" rel="nofollow">seems to support<...
3
2009-10-31T04:44:38Z
[ "java", "python", "cross-platform", "wxpython", "multiplatform" ]
Cross-Platform Programming Language with a decent gui toolkit?
1,653,419
<p>For the program idea I have, it requires that the software be written in one binary that is executeable by all major desktop platforms, meaning it needs an interpreted language or a language within a JVM. Either is fine with me, but the programming language has to balance power &amp; simplicity (e.g. Python)</p> <p...
4
2009-10-31T04:34:48Z
1,653,436
<p>I work on a program that has to run on Windows, Linux and OS X (and OS X is my development platform), and wxPython is what we use.</p> <p>If I had a chance to start again, I'd probably go with PyQT (based on advice from friends), but wxPython will get the job done.</p>
1
2009-10-31T04:46:12Z
[ "java", "python", "cross-platform", "wxpython", "multiplatform" ]
Cross-Platform Programming Language with a decent gui toolkit?
1,653,419
<p>For the program idea I have, it requires that the software be written in one binary that is executeable by all major desktop platforms, meaning it needs an interpreted language or a language within a JVM. Either is fine with me, but the programming language has to balance power &amp; simplicity (e.g. Python)</p> <p...
4
2009-10-31T04:34:48Z
1,653,442
<p>Java seems better for what you want.</p> <p>Well what about the web application in Javascript?</p>
0
2009-10-31T04:50:33Z
[ "java", "python", "cross-platform", "wxpython", "multiplatform" ]
Cross-Platform Programming Language with a decent gui toolkit?
1,653,419
<p>For the program idea I have, it requires that the software be written in one binary that is executeable by all major desktop platforms, meaning it needs an interpreted language or a language within a JVM. Either is fine with me, but the programming language has to balance power &amp; simplicity (e.g. Python)</p> <p...
4
2009-10-31T04:34:48Z
1,653,446
<p>Python with <a href="http://www.riverbankcomputing.co.uk/software/pyqt/intro">PyQt</a> or the eventually-to-be-equivalent-but-gratis <a href="http://www.pyside.org/">PySide</a> seems the way to go -- after all, few languages are easier to program in than Java (which you consider "almost too difficult to program in")...
5
2009-10-31T04:52:15Z
[ "java", "python", "cross-platform", "wxpython", "multiplatform" ]
Cross-Platform Programming Language with a decent gui toolkit?
1,653,419
<p>For the program idea I have, it requires that the software be written in one binary that is executeable by all major desktop platforms, meaning it needs an interpreted language or a language within a JVM. Either is fine with me, but the programming language has to balance power &amp; simplicity (e.g. Python)</p> <p...
4
2009-10-31T04:34:48Z
1,656,477
<p>I think wxPython is pretty good, though I am not sure what you mean by "support on Mac OS X is fairly limited" but I have been porting a wxPython app (www.mockupscreens.com) to Mac and it wasn't that difficult with few tweaks e.g. some UI elements may not come up as you expected, as wxPython uses native UI elements,...
1
2009-11-01T05:29:33Z
[ "java", "python", "cross-platform", "wxpython", "multiplatform" ]
Cross-Platform Programming Language with a decent gui toolkit?
1,653,419
<p>For the program idea I have, it requires that the software be written in one binary that is executeable by all major desktop platforms, meaning it needs an interpreted language or a language within a JVM. Either is fine with me, but the programming language has to balance power &amp; simplicity (e.g. Python)</p> <p...
4
2009-10-31T04:34:48Z
1,656,490
<p>How about <a href="http://www.eclipse.org/swt/" rel="nofollow">SWT</a> </p> <ul> <li>Cross Platform</li> <li>Native Look and feel</li> <li>Huge community </li> <li>Constantly maintained/upgraded ( IBM backed )</li> <li>Atleast <a href="http://www.eclipse.org" rel="nofollow">one</a> mega successful cross platform pr...
0
2009-11-01T05:38:24Z
[ "java", "python", "cross-platform", "wxpython", "multiplatform" ]
Cross-Platform Programming Language with a decent gui toolkit?
1,653,419
<p>For the program idea I have, it requires that the software be written in one binary that is executeable by all major desktop platforms, meaning it needs an interpreted language or a language within a JVM. Either is fine with me, but the programming language has to balance power &amp; simplicity (e.g. Python)</p> <p...
4
2009-10-31T04:34:48Z
1,681,343
<p>Consider Tcl/Tk. I'm not sure how you define "one binary that is executeable [sic] by all major desktop platforms" but Tcl probably meets this as well as java, and likely better than any other scripting language.</p> <p>Using the tcl packaging technology of starkits you can either a) create a single file that can b...
3
2009-11-05T15:37:00Z
[ "java", "python", "cross-platform", "wxpython", "multiplatform" ]
Cross-Platform Programming Language with a decent gui toolkit?
1,653,419
<p>For the program idea I have, it requires that the software be written in one binary that is executeable by all major desktop platforms, meaning it needs an interpreted language or a language within a JVM. Either is fine with me, but the programming language has to balance power &amp; simplicity (e.g. Python)</p> <p...
4
2009-10-31T04:34:48Z
1,681,376
<p>I would suggest going the wxPython route, I know that wxWidgets (which is what wxPython is using) can be made to have great looking Mac apps (look at PgAdmin3 from postgresql). While PgAdmin3 is not done in python, it was done with wxWidgets and looks fine on a mac.</p>
0
2009-11-05T15:42:37Z
[ "java", "python", "cross-platform", "wxpython", "multiplatform" ]
Cross-Platform Programming Language with a decent gui toolkit?
1,653,419
<p>For the program idea I have, it requires that the software be written in one binary that is executeable by all major desktop platforms, meaning it needs an interpreted language or a language within a JVM. Either is fine with me, but the programming language has to balance power &amp; simplicity (e.g. Python)</p> <p...
4
2009-10-31T04:34:48Z
1,681,426
<p>I use three cross-platform tools regularly: Realbasic from Realsoftware which is what Visual Basic v6 would have been if allowed to grow; Revolution from Runrev which is what Hypercard would have been if allowed to survive (and its neat using a scripting language whose syntax is basically English); and finally, Delp...
0
2009-11-05T15:51:18Z
[ "java", "python", "cross-platform", "wxpython", "multiplatform" ]
Lightweight crash recovery for Python
1,653,460
<p>What would be the best way to handle lightweight crash recovery for my program? </p> <p>I have a Python program that runs a number of test cases and the results are stored in a dictionary which serves as a cache. If I could save (and then restore) each item that is added to the dictionary, I could simply run the pr...
0
2009-10-31T05:00:32Z
1,653,466
<p>The pickle module supports serializing objects to a file (and loading from file):</p> <p><a href="http://docs.python.org/library/pickle.html" rel="nofollow">http://docs.python.org/library/pickle.html</a></p>
1
2009-10-31T05:03:37Z
[ "python" ]
Lightweight crash recovery for Python
1,653,460
<p>What would be the best way to handle lightweight crash recovery for my program? </p> <p>I have a Python program that runs a number of test cases and the results are stored in a dictionary which serves as a cache. If I could save (and then restore) each item that is added to the dictionary, I could simply run the pr...
0
2009-10-31T05:00:32Z
1,653,495
<p>There's no good way to guard against "your program crashing <strong>while</strong> writing a checkpoint to a file", but why should you worry so much about <strong>that</strong>?! What ELSE is your program doing at that time BESIDES "saving checkpoint to a file", that could easily cause it to crash?!</p> <p>It's ha...
2
2009-10-31T05:20:24Z
[ "python" ]
Lightweight crash recovery for Python
1,653,460
<p>What would be the best way to handle lightweight crash recovery for my program? </p> <p>I have a Python program that runs a number of test cases and the results are stored in a dictionary which serves as a cache. If I could save (and then restore) each item that is added to the dictionary, I could simply run the pr...
0
2009-10-31T05:00:32Z
1,653,522
<p>One possibility would be to create a number of smaller files ... each representing a subset of the state that you're trying to preserve and each with a checksum or tag indicating that it's complete as the last line/datum of the file (just before the file is closed).</p> <p>If the checksum/tag is good then the rest ...
1
2009-10-31T05:32:42Z
[ "python" ]
Lightweight crash recovery for Python
1,653,460
<p>What would be the best way to handle lightweight crash recovery for my program? </p> <p>I have a Python program that runs a number of test cases and the results are stored in a dictionary which serves as a cache. If I could save (and then restore) each item that is added to the dictionary, I could simply run the pr...
0
2009-10-31T05:00:32Z
1,653,557
<p>Pickle/cPickle have problems. </p> <p>I use the JSON module to serialize objects out. I like it because not only does it work on any OS, but it will work fine in other programming languages, too; many other languages and platforms have readily-accessible JSON deserialization support, which makes it easy to use the ...
1
2009-10-31T05:56:16Z
[ "python" ]
Lightweight crash recovery for Python
1,653,460
<p>What would be the best way to handle lightweight crash recovery for my program? </p> <p>I have a Python program that runs a number of test cases and the results are stored in a dictionary which serves as a cache. If I could save (and then restore) each item that is added to the dictionary, I could simply run the pr...
0
2009-10-31T05:00:32Z
1,653,586
<p><strong>Solution with severe restrictions</strong></p> <p>If I don't worry about it crashing while writing out and I only want to allow manual termination, I can use standard output to control this. Unfortunately, this can only terminate the program when a control point is reached. This could be solved by creating ...
0
2009-10-31T06:13:47Z
[ "python" ]
How can I parse text in Python?
1,653,509
<h3>Sample Text:</h3> <pre><code>SUBJECT = 'NETHERLANDS MUSIC EPA' CONTENT = 'Michael Buble performs in Amsterdam Canadian singer Michael Buble performs during a concert in Amsterdam, The Netherlands, 30 October 2009. Buble released his new album entitled 'Crazy Love'. EPA/OLAF KRAAK ' </code></pre> <h3>Expected resu...
-1
2009-10-31T05:26:03Z
1,653,537
<p>Looks like you want something like...:</p> <pre><code>import re x = re.compile(r'^([^\|]*?)\s*\|[^\n]*\n\s*(.*?)\s*$') s = """NETHERLANDS MUSIC EPA | 36 before Michael Buble performs in Amsterdam Canadian singer Michael Buble performs during a concert in Amsterdam, The Netherlands, 30 October 2009. Buble released...
1
2009-10-31T05:40:59Z
[ "python", "regex" ]
How can I parse text in Python?
1,653,509
<h3>Sample Text:</h3> <pre><code>SUBJECT = 'NETHERLANDS MUSIC EPA' CONTENT = 'Michael Buble performs in Amsterdam Canadian singer Michael Buble performs during a concert in Amsterdam, The Netherlands, 30 October 2009. Buble released his new album entitled 'Crazy Love'. EPA/OLAF KRAAK ' </code></pre> <h3>Expected resu...
-1
2009-10-31T05:26:03Z
1,654,541
<p>Here's a simple solution. I am using Python 3 but I think this code would be identical in 2:</p> <pre><code>&gt;&gt;&gt; import re &gt;&gt;&gt; pair = re.compile("SUBJECT = '([^\n]*)'\nCONTENT = '([^\n]*)'\n", re.MULTILINE) &gt;&gt;&gt; s = """SUBJECT = 'NETHERLANDS MUSIC EPA' ... CONTENT = 'Michael Buble performs...
0
2009-10-31T14:29:53Z
[ "python", "regex" ]
Python urllib2 Response header
1,653,591
<p>I'm trying to extract the response header of a URL request. When I use firebug to analyze the response output of a URL request, it returns:</p> <pre><code>Content-Type text/html </code></pre> <p>However when I use the python code:</p> <pre><code>urllib2.urlopen(URL).info() </code></pre> <p>the resulting output r...
20
2009-10-31T06:17:18Z
1,653,600
<p>This peculiar discrepancy might be explained by different headers (maybe ones of the accept kind) being sent by the two requests -- can you check that...? Or, if Javascript is running in Firefox (which I assume you're using when you're running firebug?) -- since it's definitely NOT running in the Python case -- "al...
2
2009-10-31T06:21:52Z
[ "python", "url", "header", "response" ]
Python urllib2 Response header
1,653,591
<p>I'm trying to extract the response header of a URL request. When I use firebug to analyze the response output of a URL request, it returns:</p> <pre><code>Content-Type text/html </code></pre> <p>However when I use the python code:</p> <pre><code>urllib2.urlopen(URL).info() </code></pre> <p>the resulting output r...
20
2009-10-31T06:17:18Z
1,654,347
<blockquote> <p>Content-Type text/html</p> </blockquote> <p>Really, like that, without the colon?</p> <p>If so, that might explain it: it's an invalid header, so it gets ignored, so urllib guesses the content-type instead, by looking at the filename. If the URL happens to have ‘.flv’ at the end, it'll guess the...
5
2009-10-31T13:11:36Z
[ "python", "url", "header", "response" ]