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
Pymssql: Calling Stored Procedure with parameters
1,971,264
<p>I am using <a href="http://pymssql.sourceforge.net/" rel="nofollow">pymssql</a> to make database calls to a SQL 2005 database. I want to pass parameters to a stored procedure. I am having a hard time getting the correct syntax for that. Here is what I have for calling a procedure with no parameters:</p> <pre><code>...
1
2009-12-28T20:03:17Z
1,971,704
<p>I found the correct syntax to do this:</p> <pre><code>connection.execute_query('exec storedProcedureName @Id=1') </code></pre>
1
2009-12-28T21:40:02Z
[ "python", "sql-server-2005", "stored-procedures" ]
Pymssql: Calling Stored Procedure with parameters
1,971,264
<p>I am using <a href="http://pymssql.sourceforge.net/" rel="nofollow">pymssql</a> to make database calls to a SQL 2005 database. I want to pass parameters to a stored procedure. I am having a hard time getting the correct syntax for that. Here is what I have for calling a procedure with no parameters:</p> <pre><code>...
1
2009-12-28T20:03:17Z
31,435,148
<p>For anyone using a newer version of <code>pymssql</code>, you can call procedures with parameters like this: <code>cursor.callproc('storedProcedureName', (1,))</code></p> <p>Where the second parameter is a tuple of all the parameters required.</p>
0
2015-07-15T15:48:31Z
[ "python", "sql-server-2005", "stored-procedures" ]
how to "export CFLAGS='my -flags -here' from python script
1,971,344
<p>I'm writing a python program that needs to set the environment CFLAGS as needed.</p> <p>I'm using the subprocess module to perform some operations, but, I'm not sure this is the correct way of doing this.</p> <p>The script will first set the CFLAGS and then compile some code, so the cflags need to stay put while t...
0
2009-12-28T20:18:24Z
1,971,395
<p>You can do this without modifying the python process's environment.</p> <pre><code># Make a copy of the environment and modify that. myenv = dict(os.environ) myenv["CXXFLAGS"] = "-DFOO" # Pass the modified environment to the subprocess. subprocess.check_call(["make", "install"], env=myenv) </code></pre> <p>See th...
1
2009-12-28T20:27:31Z
[ "python", "compiler-flags" ]
how to "export CFLAGS='my -flags -here' from python script
1,971,344
<p>I'm writing a python program that needs to set the environment CFLAGS as needed.</p> <p>I'm using the subprocess module to perform some operations, but, I'm not sure this is the correct way of doing this.</p> <p>The script will first set the CFLAGS and then compile some code, so the cflags need to stay put while t...
0
2009-12-28T20:18:24Z
1,971,767
<p>Setting it in the environment by modifying <code>os.environ['CXXFLAGS']</code> should work. However, the way I've always passed extra <code>CXXFLAGS</code> to <code>./configure</code> is by passing it on the command line, e.g.:</p> <pre><code>cmd = [ './configure', 'CXXFLAGS=-O2 -march=i586 -mtune=i686', ]...
0
2009-12-28T21:52:59Z
[ "python", "compiler-flags" ]
Haystack / Whoosh Index Generation Error
1,971,356
<p>I'm trying to setup haystack with whoosh backend. When i try to gen the index [or any index command for that matter] i receive:</p> <pre><code>TypeError: Item in ``from list'' not a string </code></pre> <p>if i completely remove my search_indexes.py i get the same error [so i'm guessing it can't find that file at ...
3
2009-12-28T20:21:29Z
1,972,537
<p>It seems like there are two problems you're running into.</p> <p>The first is the one that's generating that <code>TypeError</code>. It occurs while Haystack is searching through each app you have listed in <code>INSTALLED_APPS</code> for a search_indexes.py (since you're auto-registering). I'm not sure exactly wha...
1
2009-12-29T01:55:01Z
[ "python", "django", "django-haystack", "whoosh" ]
Haystack / Whoosh Index Generation Error
1,971,356
<p>I'm trying to setup haystack with whoosh backend. When i try to gen the index [or any index command for that matter] i receive:</p> <pre><code>TypeError: Item in ``from list'' not a string </code></pre> <p>if i completely remove my search_indexes.py i get the same error [so i'm guessing it can't find that file at ...
3
2009-12-28T20:21:29Z
2,683,624
<p>I've just encountered the same TypeError message with a completely different stack.</p> <p>A search on the whole error message brought up two results: this question, and the source code for Python's import.c. So after a little digging, I find that this particular error is caused when the <code>__import__</code> bui...
8
2010-04-21T14:09:43Z
[ "python", "django", "django-haystack", "whoosh" ]
Haystack / Whoosh Index Generation Error
1,971,356
<p>I'm trying to setup haystack with whoosh backend. When i try to gen the index [or any index command for that matter] i receive:</p> <pre><code>TypeError: Item in ``from list'' not a string </code></pre> <p>if i completely remove my search_indexes.py i get the same error [so i'm guessing it can't find that file at ...
3
2009-12-28T20:21:29Z
16,384,357
<p>I bumped into the same error last night, on a codebase that was working 5 minutes before without any modification of any kind. As far up as I went through my git repo, code that was working previously caused the same error. I cast my unicode value to string and it removed the problem but did not solve the underlying...
1
2013-05-05T12:07:59Z
[ "python", "django", "django-haystack", "whoosh" ]
Haystack / Whoosh Index Generation Error
1,971,356
<p>I'm trying to setup haystack with whoosh backend. When i try to gen the index [or any index command for that matter] i receive:</p> <pre><code>TypeError: Item in ``from list'' not a string </code></pre> <p>if i completely remove my search_indexes.py i get the same error [so i'm guessing it can't find that file at ...
3
2009-12-28T20:21:29Z
18,132,024
<p>In my case, this occurred after I upgraded my django-tastypie to v0.10. As part of the Py3 porting effort, <code>from __future__ import unicode_literals</code> was added to the top of the migrations.</p> <p>After commenting that line out in each of the tastypie migrations files, my migrations have run OK.</p> <p>W...
2
2013-08-08T17:13:17Z
[ "python", "django", "django-haystack", "whoosh" ]
License plate recognition using OpenCV
1,971,582
<p>I have a project where I need to identify the license plate of a car using OpenCV.</p> <p>I want to load an image of a number or a letter and let OpenCV identify it and print it to the console.</p> <p>Is there a function do this? If not, how can I do it?</p> <p><strong>Note:</strong> I am working on gray level</p...
7
2009-12-28T21:10:36Z
1,971,639
<p>dunno what implementations are available in opencv, but a couple other libraries are:</p> <ul> <li><p><a href="http://javaanpr.sourceforge.net/" rel="nofollow">JavaANPR</a></p></li> <li><p><a href="http://www.dtksoft.com/dtkanpr.php" rel="nofollow">DTK ANPR</a></p></li> </ul>
2
2009-12-28T21:27:09Z
[ "python", "opencv", "image-recognition" ]
License plate recognition using OpenCV
1,971,582
<p>I have a project where I need to identify the license plate of a car using OpenCV.</p> <p>I want to load an image of a number or a letter and let OpenCV identify it and print it to the console.</p> <p>Is there a function do this? If not, how can I do it?</p> <p><strong>Note:</strong> I am working on gray level</p...
7
2009-12-28T21:10:36Z
2,039,895
<p>if you are looking to learn more about OpenCV generally, you a good place to start is with this book: <a href="http://rads.stackoverflow.com/amzn/click/0596516134" rel="nofollow"><em>Learning OpenCV</em></a> by Bradksi et al.</p>
0
2010-01-11T04:20:05Z
[ "python", "opencv", "image-recognition" ]
License plate recognition using OpenCV
1,971,582
<p>I have a project where I need to identify the license plate of a car using OpenCV.</p> <p>I want to load an image of a number or a letter and let OpenCV identify it and print it to the console.</p> <p>Is there a function do this? If not, how can I do it?</p> <p><strong>Note:</strong> I am working on gray level</p...
7
2009-12-28T21:10:36Z
25,101,307
<p>I have recently been working on a simple implementation of ANPR in OpenCV python. You can check it out <a href="http://nbviewer.ipython.org/gist/kislayabhi/89b985e5b78a6f56029a" rel="nofollow">here</a> </p> <p>It is written with the help of Shogun Machine Learning toolbox with the Image processing part in OpenCV....
0
2014-08-03T03:16:10Z
[ "python", "opencv", "image-recognition" ]
Python, PyTables - taking advantage of in-kernel searching
1,971,870
<p>I have HDF5 files with multiple groups, where each group contains a data set with >= 25 million rows. At each time step of simulation, each agent outputs the other agents he/she sensed at that time step. There are ~2000 agents in the scenario and thousands of time steps; the O(n^2) nature of the output explains th...
1
2009-12-28T22:21:24Z
1,987,098
<p>If you have N=~2k agents, I suggest putting all sightings into a numpy array of size NxN. This easily fits in memory (around 16 meg for integers). Just store a 1 wherever a sighting occurred.</p> <p>Assume that you have an array <code>sightings</code>. The first coordinate is Sensing, the second is Sensed. Assum...
2
2009-12-31T20:57:20Z
[ "python", "optimization", "query-optimization", "pytables" ]
Replace letters in a secret text
1,971,911
<p>I want to change every letter in a text to after next following letter. But this program doesnt work. Does anyone know why. Thanks in advance. There is also a minor problem with y and z.</p> <pre><code>import string letters = string.ascii_lowercase text=("g fmnc wms bgblr rpylqjyrc gr zw fylb. rfyrq ufyr amknsrcpq...
3
2009-12-28T22:33:25Z
1,971,922
<p>Your first error is that strings are immutable so your replace isn't doing anything. To replace characters in a string you have to reassign:</p> <pre><code>text = text.replace(a, b) </code></pre> <p>But this is a very inefficient way to do it anyway as you are creating many temporary strings which will just be dis...
3
2009-12-28T22:37:36Z
[ "python", "string" ]
Replace letters in a secret text
1,971,911
<p>I want to change every letter in a text to after next following letter. But this program doesnt work. Does anyone know why. Thanks in advance. There is also a minor problem with y and z.</p> <pre><code>import string letters = string.ascii_lowercase text=("g fmnc wms bgblr rpylqjyrc gr zw fylb. rfyrq ufyr amknsrcpq...
3
2009-12-28T22:33:25Z
1,971,926
<p><em><strong>Ok, I incorporated the suggestions, but this is still not quite there yet ...</em></strong></p> <pre><code>text = "g fmnc wms bgblr rpylqjyrc gr zw fylb. rfyrq ufyr amknsrcpq ypc dmp. bmgle gr gl zw fylb gq glcddgagclr ylb rfyr'q ufw rfgq rcvr gq qm jmle. sqgle qrpgle.kyicrpylq() gq pcamkkclbcb. lmu ynn...
2
2009-12-28T22:38:19Z
[ "python", "string" ]
Replace letters in a secret text
1,971,911
<p>I want to change every letter in a text to after next following letter. But this program doesnt work. Does anyone know why. Thanks in advance. There is also a minor problem with y and z.</p> <pre><code>import string letters = string.ascii_lowercase text=("g fmnc wms bgblr rpylqjyrc gr zw fylb. rfyrq ufyr amknsrcpq...
3
2009-12-28T22:33:25Z
1,971,937
<p>aren't you forgetting forgetting base cases?</p> <p>problems that I see are: 1)</p> <pre><code>for x in range(1,24): </code></pre> <p>-- shouldn't that be your string length?</p> <p>2)</p> <pre><code>text.replace(letters[x],letters[x+2]) </code></pre> <p>what happens when x == 23? I suggest using ((x+2) % len...
0
2009-12-28T22:40:41Z
[ "python", "string" ]
Replace letters in a secret text
1,971,911
<p>I want to change every letter in a text to after next following letter. But this program doesnt work. Does anyone know why. Thanks in advance. There is also a minor problem with y and z.</p> <pre><code>import string letters = string.ascii_lowercase text=("g fmnc wms bgblr rpylqjyrc gr zw fylb. rfyrq ufyr amknsrcpq...
3
2009-12-28T22:33:25Z
1,971,938
<p>Strings are <strong>immutable</strong> in python.</p> <p>So <code>text.replace</code> <em>returns</em> a string, but doesn't change its original string.</p> <p>Given that, you shouldn't actually use <code>text.replace</code>, since you would have to change the string 24 (or probably 26; see below) times. Rather, y...
8
2009-12-28T22:41:10Z
[ "python", "string" ]
Replace letters in a secret text
1,971,911
<p>I want to change every letter in a text to after next following letter. But this program doesnt work. Does anyone know why. Thanks in advance. There is also a minor problem with y and z.</p> <pre><code>import string letters = string.ascii_lowercase text=("g fmnc wms bgblr rpylqjyrc gr zw fylb. rfyrq ufyr amknsrcpq...
3
2009-12-28T22:33:25Z
1,972,053
<p>This should do what you want:</p> <pre><code>&gt;&gt;&gt; rot = lambda xs: (xs + [xs[0]])[1:] &gt;&gt;&gt; apply = lambda n,f,x: (n == 0) and x or f(apply(n-1,f,x)) &gt;&gt;&gt; abc = map(chr,range(ord('a'),ord('z')+1)) &gt;&gt;&gt; d = dict(zip(list(abc),apply(2,rot,(list(abc))))) &gt;&gt;&gt; s = "g fmnc wms bgbl...
4
2009-12-28T23:14:32Z
[ "python", "string" ]
Replace letters in a secret text
1,971,911
<p>I want to change every letter in a text to after next following letter. But this program doesnt work. Does anyone know why. Thanks in advance. There is also a minor problem with y and z.</p> <pre><code>import string letters = string.ascii_lowercase text=("g fmnc wms bgblr rpylqjyrc gr zw fylb. rfyrq ufyr amknsrcpq...
3
2009-12-28T22:33:25Z
1,972,055
<p>Solution closest to yours is:</p> <pre><code>letters = string.ascii_lowercase uletters = string.ascii_uppercase text=("g fmnc wms bgblr rpylqjyrc gr zw fylb. rfyrq ufyr amknsrcpq ypc dmp. bmgle gr gl zw fylb gq glcddgagclr ylb rfyr'q ufw rfgq rcvr gq qm jmle. sqgle qrpgle.kyicrpylq() gq pcamkkclbcb. lmu ynnjw ml rf...
2
2009-12-28T23:15:07Z
[ "python", "string" ]
Replace letters in a secret text
1,971,911
<p>I want to change every letter in a text to after next following letter. But this program doesnt work. Does anyone know why. Thanks in advance. There is also a minor problem with y and z.</p> <pre><code>import string letters = string.ascii_lowercase text=("g fmnc wms bgblr rpylqjyrc gr zw fylb. rfyrq ufyr amknsrcpq...
3
2009-12-28T22:33:25Z
8,458,460
<pre><code>import string s = "g fmnc wms bgblr rpylqjyrc gr zw fylb. rfyrq ufyr amknsrcpq ypc dmp. bmgle gr gl zw fylb gq glcddgagclr ylb rfyr'q ufw rfgq rcvr gq qm jmle. sqgle qrpgle.kyicrpylq() gq pcamkkclbcb. lmu ynnjw ml rfc spj. " trans = string.maketrans('abcdefghijklmnopqrstuvwxyz', 'cdefghijklmnopqrstu...
2
2011-12-10T17:32:14Z
[ "python", "string" ]
Replace letters in a secret text
1,971,911
<p>I want to change every letter in a text to after next following letter. But this program doesnt work. Does anyone know why. Thanks in advance. There is also a minor problem with y and z.</p> <pre><code>import string letters = string.ascii_lowercase text=("g fmnc wms bgblr rpylqjyrc gr zw fylb. rfyrq ufyr amknsrcpq...
3
2009-12-28T22:33:25Z
8,570,715
<p>I finished it by a common way. Here is my code. I <code>didn't use string.translate</code> and I have tried @mangobug's code. I don't know why, but it doesn't work.</p> <pre><code>import string def puzzle(x): y=" " for i in x: if ord("a")&lt;= ord(i)&lt;=ord("x"): n=ord(i)+2 el...
1
2011-12-20T04:11:49Z
[ "python", "string" ]
Image library with advanced text effects?
1,972,044
<p>What would be the best Python library to use when producing text-based images requiring things such as leading, kerning, outlines, drop-shadows, etc?</p> <p>I've worked with PIL before for resizing images, but the methods for working with text seem rather limited. Is there a better alternative?</p>
2
2009-12-28T23:13:02Z
1,972,134
<p>What you seem to want to do is exactly what LaTeX was designed for. With <a href="http://plastex.sourceforge.net/plastex/index.html" rel="nofollow">plasTeX</a>, you can convert LaTeX markup to an image. Here's an example of what you can do with this (from the plasTeX documentation) <img src="http://plastex.sourcefor...
1
2009-12-28T23:36:16Z
[ "python", "python-imaging-library" ]
Image library with advanced text effects?
1,972,044
<p>What would be the best Python library to use when producing text-based images requiring things such as leading, kerning, outlines, drop-shadows, etc?</p> <p>I've worked with PIL before for resizing images, but the methods for working with text seem rather limited. Is there a better alternative?</p>
2
2009-12-28T23:13:02Z
1,973,859
<p><a href="http://www.cairographics.org/" rel="nofollow">Cairo</a> is very capable, and there are <a href="http://www.cairographics.org/pycairo/" rel="nofollow">Python bindings</a> to Cairo. Though, when I used it, I had to look into C documentation too.</p>
0
2009-12-29T10:09:29Z
[ "python", "python-imaging-library" ]
Unable to get Netbeans debugger working for python
1,972,049
<p>Ubuntu 9.10 Netbeans 6.7.1</p> <p>Whenever I start the debugger it crashes out with the error below.</p> <p>I've set the project properties to the correct version of python, although it doesn't seem to make any difference what it is set to.</p> <p>I've also noticed that the PythonConsole window reports that Pytho...
2
2009-12-28T23:14:00Z
1,972,160
<p>I've experienced some issues with the Netbeans Python debugger as well. Python support in Netbeans is not yet perfect and does not come anywhere near to Java Netbeans peformance and support.</p> <p>You could try checking python platforms in Tools -> Python Platforms; try removing and readding the interpreter, thus ...
2
2009-12-28T23:42:03Z
[ "python", "netbeans", "ubuntu", "debugging" ]
Unable to get Netbeans debugger working for python
1,972,049
<p>Ubuntu 9.10 Netbeans 6.7.1</p> <p>Whenever I start the debugger it crashes out with the error below.</p> <p>I've set the project properties to the correct version of python, although it doesn't seem to make any difference what it is set to.</p> <p>I've also noticed that the PythonConsole window reports that Pytho...
2
2009-12-28T23:14:00Z
19,606,116
<p>Somebody has mentioned that spaces in project path cause this error (for me with Kubuntu 13.10 and Netbeans 7.4 the problem persisted after eliminatin spaces from the path, however)</p> <p><a href="https://netbeans.org/bugzilla/show_bug.cgi?id=196842" rel="nofollow">https://netbeans.org/bugzilla/show_bug.cgi?id=196...
0
2013-10-26T11:25:38Z
[ "python", "netbeans", "ubuntu", "debugging" ]
Unable to get Netbeans debugger working for python
1,972,049
<p>Ubuntu 9.10 Netbeans 6.7.1</p> <p>Whenever I start the debugger it crashes out with the error below.</p> <p>I've set the project properties to the correct version of python, although it doesn't seem to make any difference what it is set to.</p> <p>I've also noticed that the PythonConsole window reports that Pytho...
2
2009-12-28T23:14:00Z
24,780,460
<p>possibly you used spaces in the path of your file (happenned to me)</p> <p><a href="https://netbeans.org/bugzilla/show_bug.cgi?id=175116" rel="nofollow">https://netbeans.org/bugzilla/show_bug.cgi?id=175116</a></p>
0
2014-07-16T12:10:08Z
[ "python", "netbeans", "ubuntu", "debugging" ]
Unable to get Netbeans debugger working for python
1,972,049
<p>Ubuntu 9.10 Netbeans 6.7.1</p> <p>Whenever I start the debugger it crashes out with the error below.</p> <p>I've set the project properties to the correct version of python, although it doesn't seem to make any difference what it is set to.</p> <p>I've also noticed that the PythonConsole window reports that Pytho...
2
2009-12-28T23:14:00Z
31,058,072
<p>I had this same problem today. Renaming the folder my code was in to have no spaces didn't help. The parent folder was the only folder in the code's file path that had spaces in it.</p> <p>The only thing that worked for me was to make a new folder with the correct name (without spaces) and move all my code into tha...
0
2015-06-25T18:30:08Z
[ "python", "netbeans", "ubuntu", "debugging" ]
How can I insert a new Event for non primary Calendar? Using python gdata
1,972,096
<pre><code>def addEvent(calendar_service): event = gdata.calendar.CalendarEventEntry() event.content = atom.Content(text='Tennis with John 30.12.2009 15:00-16:00') event.quick_add = gdata.calendar.QuickAdd(value='true') new_event = calendar_service.InsertEvent(event, '/calendar/feeds/default/private/ful...
3
2009-12-28T23:26:05Z
1,972,408
<p>Try specifying a different URL for InsertEvent. See the docs on <a href="http://code.google.com/apis/calendar/data/1.0/developers%5Fguide%5Fpython.html#RetrievingCalendars" rel="nofollow">retrieving calendars</a> or just try hitting the listed URL with a GET. Use a retrieved calendar's URL instead of '/calendar/feed...
0
2009-12-29T01:03:04Z
[ "python", "django", "gdata-api", "gdata" ]
How can I insert a new Event for non primary Calendar? Using python gdata
1,972,096
<pre><code>def addEvent(calendar_service): event = gdata.calendar.CalendarEventEntry() event.content = atom.Content(text='Tennis with John 30.12.2009 15:00-16:00') event.quick_add = gdata.calendar.QuickAdd(value='true') new_event = calendar_service.InsertEvent(event, '/calendar/feeds/default/private/ful...
3
2009-12-28T23:26:05Z
1,973,540
<p>Ok, i found the url in <em>a_calendar.content.src</em> it show like "http://www.google.com/calendar/feeds/"+id+"/private/full"</p> <pre><code>def addEvent(calendar_service): event = gdata.calendar.CalendarEventEntry() event.content = atom.Content(text='Tennis with John 30.12.2009 15:00-16:00') event.qui...
3
2009-12-29T08:26:49Z
[ "python", "django", "gdata-api", "gdata" ]
Interpolating a scalar field in a 3D space
1,972,172
<p>I have a 3D space (x, y, z) with an additional parameter at each point (energy), giving 4 dimensions of data in total.</p> <p>I would like to find a set of x, y, z points which correspond to an iso-energy surface found by interpolating between the known points.</p> <p>The spacial mesh has constant spacing and surr...
7
2009-12-28T23:46:15Z
1,972,190
<p>There are quite a few options here...</p> <p>In order to get your energy into your mesh, you'll need to use some form of interpolation. <a href="http://en.wikipedia.org/wiki/Inverse%5Fdistance%5Fweighting">Shepard's method</a> is a common, and reasonably simple, method to implement, and tends to work well if your ...
7
2009-12-28T23:52:49Z
[ "python", "algorithm", "interpolation" ]
Interpolating a scalar field in a 3D space
1,972,172
<p>I have a 3D space (x, y, z) with an additional parameter at each point (energy), giving 4 dimensions of data in total.</p> <p>I would like to find a set of x, y, z points which correspond to an iso-energy surface found by interpolating between the known points.</p> <p>The spacial mesh has constant spacing and surr...
7
2009-12-28T23:46:15Z
1,972,198
<p>Why not try quadlinear interpolation?</p> <p>extend Trilinear interpolation by another dimension. As long as a linear interpolation model fits your data, it should work.</p>
1
2009-12-28T23:54:54Z
[ "python", "algorithm", "interpolation" ]
Interpolating a scalar field in a 3D space
1,972,172
<p>I have a 3D space (x, y, z) with an additional parameter at each point (energy), giving 4 dimensions of data in total.</p> <p>I would like to find a set of x, y, z points which correspond to an iso-energy surface found by interpolating between the known points.</p> <p>The spacial mesh has constant spacing and surr...
7
2009-12-28T23:46:15Z
1,973,347
<p>Since you have a spatial mesh with constant spacing, you can identify all neighbors on opposite sides of the isosurface. Choose some form of interpolation (q.v. Reed Copsey's answer) and do root-finding along the line between each such neighbor.</p>
2
2009-12-29T07:17:13Z
[ "python", "algorithm", "interpolation" ]
Start and capture GUI's output from same Python script and transfer variables?
1,972,176
<p>I have to start a GUI from an existing Python application. The GUI is actually separate Python GUI that can run alone. Right now, I am starting the GUI using something like:</p> <pre><code> res=Popen(['c:\python26\pythonw.exe', full_filename, str(RESULTs), ...
0
2009-12-28T23:47:19Z
1,972,226
<p>Is the python application opensource? You can look at how the GUI itself hooks up into the back end, and directly import the relative modules into your application, then call it as the GUI would, bypassing this messy hack.</p>
0
2009-12-29T00:03:08Z
[ "python", "user-interface", "automation", "subprocess" ]
Start and capture GUI's output from same Python script and transfer variables?
1,972,176
<p>I have to start a GUI from an existing Python application. The GUI is actually separate Python GUI that can run alone. Right now, I am starting the GUI using something like:</p> <pre><code> res=Popen(['c:\python26\pythonw.exe', full_filename, str(RESULTs), ...
0
2009-12-28T23:47:19Z
1,972,376
<p>From the sounds of it, unless Nazarius' excellent suggestion for a first step is infeasible, a program like <a href="http://pywinauto.openqa.org/" rel="nofollow">pyWinAuto</a> would do what you need. We use it to control our own wxPython-based application for use in automated testing, with a Python script controlli...
1
2009-12-29T00:50:07Z
[ "python", "user-interface", "automation", "subprocess" ]
"Cannot open include file: 'config-win.h': No such file or directory" while installing mysql-python
1,972,259
<p>I'm trying to install mysql-python in a virtualenv using pip on windows. At first, I was getting the same error <a href="http://stackoverflow.com/questions/1706989/setting-up-virtualenv-for-django-development-on-windows">reported here</a>, but the answer there worked for me too. Now I'm getting this following erro...
42
2009-12-29T00:13:07Z
1,975,291
<p>Installing dev bits for mysql got rid of the <code>config-win.h</code> error I was having, and threw another. <code>Failed to load and parse the manifest. The system cannot find the file specified.</code> I found the answer to my problem in this post: <a href="http://www.fuyun.org/2009/12/install-mysql-for-python-on...
3
2009-12-29T15:51:33Z
[ "python", "windows", "virtualenv", "pip", "mysql-python" ]
"Cannot open include file: 'config-win.h': No such file or directory" while installing mysql-python
1,972,259
<p>I'm trying to install mysql-python in a virtualenv using pip on windows. At first, I was getting the same error <a href="http://stackoverflow.com/questions/1706989/setting-up-virtualenv-for-django-development-on-windows">reported here</a>, but the answer there worked for me too. Now I'm getting this following erro...
42
2009-12-29T00:13:07Z
2,142,016
<p>Most probably the answer is to install MySQL Developer Build and selecting "C headers\libs" option during configuration. (as reported in this entry: Building MySQLdb for Python on Windows on rationalpie.wordpress.com)</p> <p>Maybe even better solution is to install a precompiled build: <a href="http://www.technical...
7
2010-01-26T19:32:44Z
[ "python", "windows", "virtualenv", "pip", "mysql-python" ]
"Cannot open include file: 'config-win.h': No such file or directory" while installing mysql-python
1,972,259
<p>I'm trying to install mysql-python in a virtualenv using pip on windows. At first, I was getting the same error <a href="http://stackoverflow.com/questions/1706989/setting-up-virtualenv-for-django-development-on-windows">reported here</a>, but the answer there worked for me too. Now I'm getting this following erro...
42
2009-12-29T00:13:07Z
5,398,589
<p>Try <a href="http://code.activestate.com/pypm/mysql-python/" rel="nofollow">ActivePython</a>,</p> <pre><code>pypm -E C:\myvirtualenv install mysql-python </code></pre>
1
2011-03-22T22:21:49Z
[ "python", "windows", "virtualenv", "pip", "mysql-python" ]
"Cannot open include file: 'config-win.h': No such file or directory" while installing mysql-python
1,972,259
<p>I'm trying to install mysql-python in a virtualenv using pip on windows. At first, I was getting the same error <a href="http://stackoverflow.com/questions/1706989/setting-up-virtualenv-for-django-development-on-windows">reported here</a>, but the answer there worked for me too. Now I'm getting this following erro...
42
2009-12-29T00:13:07Z
5,685,209
<p>Update for mysql 5.5 and config-win.h not visible issue</p> <p>In 5.5 config-win. has actually moved to Connector separate folder in windows. i.e. smth like:</p> <p>C:\Program Files\MySQL\Connector C 6.0.2\include</p> <p>To overcome the problem one need not only to download "dev bits" (which actually connects the...
15
2011-04-16T07:48:27Z
[ "python", "windows", "virtualenv", "pip", "mysql-python" ]
"Cannot open include file: 'config-win.h': No such file or directory" while installing mysql-python
1,972,259
<p>I'm trying to install mysql-python in a virtualenv using pip on windows. At first, I was getting the same error <a href="http://stackoverflow.com/questions/1706989/setting-up-virtualenv-for-django-development-on-windows">reported here</a>, but the answer there worked for me too. Now I'm getting this following erro...
42
2009-12-29T00:13:07Z
6,723,407
<p>Well, if you are still having the problem, you can download the installer from <a href="http://code.google.com/p/soemin/downloads/detail?name=MySQL-python-1.2.3.win32-py2.7.exe" rel="nofollow">http://code.google.com/p/soemin/downloads/detail?name=MySQL-python-1.2.3.win32-py2.7.exe</a></p>
2
2011-07-17T10:59:03Z
[ "python", "windows", "virtualenv", "pip", "mysql-python" ]
"Cannot open include file: 'config-win.h': No such file or directory" while installing mysql-python
1,972,259
<p>I'm trying to install mysql-python in a virtualenv using pip on windows. At first, I was getting the same error <a href="http://stackoverflow.com/questions/1706989/setting-up-virtualenv-for-django-development-on-windows">reported here</a>, but the answer there worked for me too. Now I'm getting this following erro...
42
2009-12-29T00:13:07Z
14,132,398
<p>I had a lot of headache with MySQLdb too.</p> <p>Why not use the official MysQL Python Connector?</p> <pre><code>easy_install mysql-connector-python </code></pre> <p>Or you can download it from here: <a href="http://dev.mysql.com/downloads/connector/python/" rel="nofollow">http://dev.mysql.com/downloads/connector...
2
2013-01-03T02:50:09Z
[ "python", "windows", "virtualenv", "pip", "mysql-python" ]
"Cannot open include file: 'config-win.h': No such file or directory" while installing mysql-python
1,972,259
<p>I'm trying to install mysql-python in a virtualenv using pip on windows. At first, I was getting the same error <a href="http://stackoverflow.com/questions/1706989/setting-up-virtualenv-for-django-development-on-windows">reported here</a>, but the answer there worked for me too. Now I'm getting this following erro...
42
2009-12-29T00:13:07Z
16,619,567
<p>All I had to do was go over to oracle, and download the MySQL Connector C 6.0.2 and do the typical install.</p> <p><a href="http://dev.mysql.com/downloads/connector/c/6.0.html#downloads">http://dev.mysql.com/downloads/connector/c/6.0.html#downloads</a></p> <p>Once that was done, I went into pycharms, and selected ...
50
2013-05-18T00:29:25Z
[ "python", "windows", "virtualenv", "pip", "mysql-python" ]
"Cannot open include file: 'config-win.h': No such file or directory" while installing mysql-python
1,972,259
<p>I'm trying to install mysql-python in a virtualenv using pip on windows. At first, I was getting the same error <a href="http://stackoverflow.com/questions/1706989/setting-up-virtualenv-for-django-development-on-windows">reported here</a>, but the answer there worked for me too. Now I'm getting this following erro...
42
2009-12-29T00:13:07Z
18,141,164
<p>The accepted solution no longer seems to work for newer versions of mysql-python. The installer no longer provides a <code>site.cfg</code> file to edit.</p> <p>If you are installing mysql-python it'll look for <code>C:\Program Files (x86)\MySQL\MySQL Connector C 6.0.2\include</code>. If you have a 64-bit installati...
19
2013-08-09T06:29:01Z
[ "python", "windows", "virtualenv", "pip", "mysql-python" ]
"Cannot open include file: 'config-win.h': No such file or directory" while installing mysql-python
1,972,259
<p>I'm trying to install mysql-python in a virtualenv using pip on windows. At first, I was getting the same error <a href="http://stackoverflow.com/questions/1706989/setting-up-virtualenv-for-django-development-on-windows">reported here</a>, but the answer there worked for me too. Now I'm getting this following erro...
42
2009-12-29T00:13:07Z
19,056,568
<p>The accepted answer is out of date. Some of the suggestions were already incorporated in the package, and I was still getting the error about missing config-win.h &amp; mysqlclient.lib.</p> <ul> <li><p>Install <a href="http://dev.mysql.com/downloads/connector/c/6.0.html#downloads" rel="nofollow">mysql-connector-c-6...
12
2013-09-27T17:19:21Z
[ "python", "windows", "virtualenv", "pip", "mysql-python" ]
"Cannot open include file: 'config-win.h': No such file or directory" while installing mysql-python
1,972,259
<p>I'm trying to install mysql-python in a virtualenv using pip on windows. At first, I was getting the same error <a href="http://stackoverflow.com/questions/1706989/setting-up-virtualenv-for-django-development-on-windows">reported here</a>, but the answer there worked for me too. Now I'm getting this following erro...
42
2009-12-29T00:13:07Z
20,435,801
<p>If pip fails to install "MySQLdb", a workaround is to download and install it on your machine first from this link</p> <p><a href="http://www.lfd.uci.edu/~gohlke/pythonlibs/#mysql-python" rel="nofollow">http://www.lfd.uci.edu/~gohlke/pythonlibs/#mysql-python</a></p> <p>then copy all MySQL* and _mysql* files and di...
2
2013-12-07T00:07:58Z
[ "python", "windows", "virtualenv", "pip", "mysql-python" ]
"Cannot open include file: 'config-win.h': No such file or directory" while installing mysql-python
1,972,259
<p>I'm trying to install mysql-python in a virtualenv using pip on windows. At first, I was getting the same error <a href="http://stackoverflow.com/questions/1706989/setting-up-virtualenv-for-django-development-on-windows">reported here</a>, but the answer there worked for me too. Now I'm getting this following erro...
42
2009-12-29T00:13:07Z
20,459,288
<p>In my case, my fix was copying the folder created from mysql-connector-c-6.0.2-win32.msi (referenced from username buffer in a previous post), which is located at c:\Program Files\MySQL\MySQL Connector C 6.0.2 and creating a new path with Program Files (x86) and pasting the content there since the installation is no...
2
2013-12-08T21:24:13Z
[ "python", "windows", "virtualenv", "pip", "mysql-python" ]
"Cannot open include file: 'config-win.h': No such file or directory" while installing mysql-python
1,972,259
<p>I'm trying to install mysql-python in a virtualenv using pip on windows. At first, I was getting the same error <a href="http://stackoverflow.com/questions/1706989/setting-up-virtualenv-for-django-development-on-windows">reported here</a>, but the answer there worked for me too. Now I'm getting this following erro...
42
2009-12-29T00:13:07Z
22,703,204
<p>I did follow the answer from Bugagotti, And it does not work in my windows (Win7 64 bit, py27 and have mysql connector 6.1 installed) for mysql-python-1.2.5, so I made some even dirty changes inside mysql-python-1.2.5:</p> <p>First, the site.cfg:</p> <pre><code>connector = C:\Program Files\MySQL\MySQL Connector C ...
1
2014-03-28T02:39:36Z
[ "python", "windows", "virtualenv", "pip", "mysql-python" ]
"Cannot open include file: 'config-win.h': No such file or directory" while installing mysql-python
1,972,259
<p>I'm trying to install mysql-python in a virtualenv using pip on windows. At first, I was getting the same error <a href="http://stackoverflow.com/questions/1706989/setting-up-virtualenv-for-django-development-on-windows">reported here</a>, but the answer there worked for me too. Now I'm getting this following erro...
42
2009-12-29T00:13:07Z
27,671,880
<p>I followed Mingcai SHEN's method.</p> <p>But in my case, I changed the connector to</p> <pre><code>connector = C:\Program Files\MySQL\MySQL Connector.C 6.1 </code></pre> <p>And the library_dirs is changed to </p> <pre><code>library_dirs = [ os.path.join(connector, r'lib\vs10') ] </code></pre> <p>because I don't...
1
2014-12-27T22:07:08Z
[ "python", "windows", "virtualenv", "pip", "mysql-python" ]
"Cannot open include file: 'config-win.h': No such file or directory" while installing mysql-python
1,972,259
<p>I'm trying to install mysql-python in a virtualenv using pip on windows. At first, I was getting the same error <a href="http://stackoverflow.com/questions/1706989/setting-up-virtualenv-for-django-development-on-windows">reported here</a>, but the answer there worked for me too. Now I'm getting this following erro...
42
2009-12-29T00:13:07Z
38,846,217
<p>I know this post is super old, but it is still coming up as the top hit in google so I will add some more info to this issue. </p> <p>I was having the same problems as OP but none of the suggested answers seemed to work for me. Mainly because "config-win.h" didn't exist anywhere in the connector install folder. </p...
2
2016-08-09T08:55:16Z
[ "python", "windows", "virtualenv", "pip", "mysql-python" ]
"Cannot open include file: 'config-win.h': No such file or directory" while installing mysql-python
1,972,259
<p>I'm trying to install mysql-python in a virtualenv using pip on windows. At first, I was getting the same error <a href="http://stackoverflow.com/questions/1706989/setting-up-virtualenv-for-django-development-on-windows">reported here</a>, but the answer there worked for me too. Now I'm getting this following erro...
42
2009-12-29T00:13:07Z
39,925,518
<p>Solution that worked for me on <code>Windows</code>: Install both the <code>32</code>-bit and <code>64</code>-bit versions of the <a href="http://dev.mysql.com/downloads/connector/c/6.0.html#downloads" rel="nofollow">MySQL Connector/C 6.0.2</a>. Open <code>Command Prompt</code> and run:</p> <pre><code>pip install ...
0
2016-10-07T20:43:25Z
[ "python", "windows", "virtualenv", "pip", "mysql-python" ]
Separate image of text into component character images
1,972,299
<p>I'd like to separate an image of text into it's component characters, also as images. For example, using the sample below I'd end up with 14 images. </p> <p>I'm only going to be using text on a single line, so the y-height is unimportant - what I need to find is the beginning and end of each letter and crop to thos...
2
2009-12-29T00:22:38Z
1,972,340
<p>This is not an easy task especially if the background is not uniform. If what you have is an already binary image like the example, it is slightly simpler. </p> <p>You can start applying a threshold algorithm if your image is not binary (Otsu adaptative threshold works well)</p> <p>After you can use a labelling al...
3
2009-12-29T00:37:25Z
[ "python", "image-processing", "python-imaging-library" ]
Separate image of text into component character images
1,972,299
<p>I'd like to separate an image of text into it's component characters, also as images. For example, using the sample below I'd end up with 14 images. </p> <p>I'm only going to be using text on a single line, so the y-height is unimportant - what I need to find is the beginning and end of each letter and crop to thos...
2
2009-12-29T00:22:38Z
1,972,350
<p>I've been playing around with <a href="http://code.google.com/p/ocropus/" rel="nofollow">ocropus</a> recently, an open-source text analysis and ocr-preprocessing tool. As a part of its workflow, it also creates the images you want. Maybe this helps you, although no python magic is involved.</p>
1
2009-12-29T00:41:06Z
[ "python", "image-processing", "python-imaging-library" ]
Separate image of text into component character images
1,972,299
<p>I'd like to separate an image of text into it's component characters, also as images. For example, using the sample below I'd end up with 14 images. </p> <p>I'm only going to be using text on a single line, so the y-height is unimportant - what I need to find is the beginning and end of each letter and crop to thos...
2
2009-12-29T00:22:38Z
1,972,608
<p>The problem you have posed is really hard&mdash;it took some of the world's best image-processing researchers quite some time to solve. The solution is a major part of the <a href="http://djvuzone.org/" rel="nofollow">Djvu</a> image-compression and display toolset: their first step in compressing a document is to i...
1
2009-12-29T02:27:03Z
[ "python", "image-processing", "python-imaging-library" ]
Separate image of text into component character images
1,972,299
<p>I'd like to separate an image of text into it's component characters, also as images. For example, using the sample below I'd end up with 14 images. </p> <p>I'm only going to be using text on a single line, so the y-height is unimportant - what I need to find is the beginning and end of each letter and crop to thos...
2
2009-12-29T00:22:38Z
1,972,677
<p>You could start with a simple connected components analysis (CCA) algorithm, which can be implemented quite efficiently with a scanline algorithm (you just keep track of merged regions and relabel at the end). This would give you separately numbered "blobs" for each continuous region, which would work for most (but...
2
2009-12-29T02:51:54Z
[ "python", "image-processing", "python-imaging-library" ]
Separate image of text into component character images
1,972,299
<p>I'd like to separate an image of text into it's component characters, also as images. For example, using the sample below I'd end up with 14 images. </p> <p>I'm only going to be using text on a single line, so the y-height is unimportant - what I need to find is the beginning and end of each letter and crop to thos...
2
2009-12-29T00:22:38Z
1,973,097
<p>Um, this is actually very easy for the sample you provided:</p> <pre><code>start at left edge go right 1 column at a time until the current column contains black (a letter) this is the start of the character go right again till no black at all in current column end of character repeat till end of image </co...
2
2009-12-29T05:42:01Z
[ "python", "image-processing", "python-imaging-library" ]
Separate image of text into component character images
1,972,299
<p>I'd like to separate an image of text into it's component characters, also as images. For example, using the sample below I'd end up with 14 images. </p> <p>I'm only going to be using text on a single line, so the y-height is unimportant - what I need to find is the beginning and end of each letter and crop to thos...
2
2009-12-29T00:22:38Z
28,029,854
<p>I know I am few years late :-) but you can do this sort of thing with ImageMagick pretty easily now, straight at the command-line without compiling anything, as it has Connected Component Analysis built-in:</p> <p>Here is one way to do it like that:</p> <pre><code>#!/bin/bash image="$1" draw=$(convert $image ...
2
2015-01-19T16:59:01Z
[ "python", "image-processing", "python-imaging-library" ]
MySQLdb connection issue
1,972,562
<p>I am writing a server which provide a service by query MySQL database. Everything goes fine, except when run one or two days the connection will go away. The error code is (2600, MySQL has gone away)</p> <p>I try to wrap the cursor object by:</p> <pre><code>def cursor(self): try: return self.connec...
0
2009-12-29T02:05:48Z
1,972,584
<p>You would be better served by a connection pool and minimizing the length of time that a connection stays open. It'll be more scalable, and you won't suffer from this issue.</p>
1
2009-12-29T02:15:14Z
[ "python", "mysql" ]
MySQLdb connection issue
1,972,562
<p>I am writing a server which provide a service by query MySQL database. Everything goes fine, except when run one or two days the connection will go away. The error code is (2600, MySQL has gone away)</p> <p>I try to wrap the cursor object by:</p> <pre><code>def cursor(self): try: return self.connec...
0
2009-12-29T02:05:48Z
1,972,638
<p>@duffymo's idea about not keeping connections open too long is viable, but so is your original idea about catching the exception and retrying (I'm not so sure about which one is better).</p> <p>Since the exception is raised by <code>cursor.execute</code>, that's where you must catch and remedy it (by renewing the c...
2
2009-12-29T02:38:43Z
[ "python", "mysql" ]
What arguments does Python sort function have?
1,972,672
<p>Is there any other argument except <code>key</code>, for example: <code>value</code>?</p> <p>Thanks.</p>
4
2009-12-29T02:49:34Z
1,972,686
<p>Yes, it takes other arguments, but no <code>value</code>.</p> <pre><code>&gt;&gt;&gt; print list.sort.__doc__ L.sort(cmp=None, key=None, reverse=False) -- stable sort *IN PLACE*; cmp(x, y) -&gt; -1, 0, 1 </code></pre> <p>What would a <code>value</code> argument even mean?</p>
1
2009-12-29T02:54:29Z
[ "python", "sorting" ]
What arguments does Python sort function have?
1,972,672
<p>Is there any other argument except <code>key</code>, for example: <code>value</code>?</p> <p>Thanks.</p>
4
2009-12-29T02:49:34Z
1,972,691
<p>Besides <code>key=</code>, the <code>sort</code> method of lists can alternatively take a <code>cmp=</code> argument (<strong>not</strong> a good idea, it's been removed in Python 3); with either or none of these two, you can always pass <code>reverse=True</code> to have the sort go downwards (instead of upwards as ...
2
2009-12-29T02:55:20Z
[ "python", "sorting" ]
What arguments does Python sort function have?
1,972,672
<p>Is there any other argument except <code>key</code>, for example: <code>value</code>?</p> <p>Thanks.</p>
4
2009-12-29T02:49:34Z
1,973,688
<h2>Arguments of <code>sort</code> and <code>sorted</code></h2> <p>Both <code>sort</code> and <code>sorted</code> have three keyword arguments: <code>cmp</code>, <code>key</code> and <code>reverse</code>.</p> <pre><code>L.sort(cmp=None, key=None, reverse=False) -- stable sort *IN PLACE*; cmp(x, y) -&gt; -1, 0, 1 sor...
25
2009-12-29T09:17:36Z
[ "python", "sorting" ]
Python code optimization
1,972,699
<p>I'm building a online font previewer, with following architecture. I wrapped preview creation function in a standalone .py file and making system calls to it in a Django view in order to run them in parallel and maximum performance on multi-core CPU system.</p> <p><strong>preview.py</strong></p> <pre><code>.... de...
0
2009-12-29T02:57:02Z
1,972,729
<p>You should look into the <a href="http://docs.python.org/library/multiprocessing.html" rel="nofollow">multiprocessing</a> module. You could create a pool of workers equal to your number of CPU cores and then send jobs to your make_preview function.</p>
2
2009-12-29T03:09:30Z
[ "python", "optimization" ]
Python code optimization
1,972,699
<p>I'm building a online font previewer, with following architecture. I wrapped preview creation function in a standalone .py file and making system calls to it in a Django view in order to run them in parallel and maximum performance on multi-core CPU system.</p> <p><strong>preview.py</strong></p> <pre><code>.... de...
0
2009-12-29T02:57:02Z
1,973,013
<p>If this is a font chooser, where you can reasonably display the same text every time you show it, you can pre-render the font samples and save the results as .PNG or .GIF files. (You don't want to use JPEG images because they will make your fonts blurry; JPEGs use lossy compression.)</p> <p>Then you can make your ...
0
2009-12-29T05:05:42Z
[ "python", "optimization" ]
Get the position of the windows start menu
1,972,709
<p>I'm writing an app in Python that automatically moves stuff around. How do I get the position of the windows start menu bar, so I can account for it in my calculations? </p>
0
2009-12-29T03:02:23Z
1,972,720
<p>Ah, found it. <code>GetMonitorInfo</code>: <a href="http://msdn.microsoft.com/en-us/library/dd144901%28VS.85%29.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/dd144901%28VS.85%29.aspx</a> . Here is an example: <a href="http://msdn.microsoft.com/en-us/library/dd162826%28VS.85%29.aspx" rel="nofollow">htt...
0
2009-12-29T03:05:48Z
[ "python", "winapi", "pywin32" ]
Get the position of the windows start menu
1,972,709
<p>I'm writing an app in Python that automatically moves stuff around. How do I get the position of the windows start menu bar, so I can account for it in my calculations? </p>
0
2009-12-29T03:02:23Z
1,972,724
<p>To get the rectangle use <a href="http://msdn.microsoft.com/en-us/library/bb762108%28VS.85%29.aspx" rel="nofollow">SHAppBarMessage()</a>. You would do the following in C++:</p> <pre><code>APPBARDATA abd = {0}; SHAppBarMessage(ABM_GETTASKBARPOS, &amp;abd); </code></pre> <p>And then <code>abd.rc</code> would contai...
0
2009-12-29T03:07:11Z
[ "python", "winapi", "pywin32" ]
Get the position of the windows start menu
1,972,709
<p>I'm writing an app in Python that automatically moves stuff around. How do I get the position of the windows start menu bar, so I can account for it in my calculations? </p>
0
2009-12-29T03:02:23Z
1,972,757
<p>When you ask for the work area, the taskbar area is automatically excluded. </p> <pre><code>System.Parameters.WorkArea </code></pre> <p>or Use interop to </p> <pre><code>SystemParametersInfo(SPI_GETWORKAREA, ...)` </code></pre> <p>and you are done.</p>
1
2009-12-29T03:26:16Z
[ "python", "winapi", "pywin32" ]
How to use pyparsing to parse and hash strings enclosed by special characters?
1,972,781
<p>The majority of pyparsing examples that I have seen have dealt with linear expressions.</p> <p>a = 1 + 2</p> <p>I'd like to parse mediawiki headlines, and hash them to their sections.</p> <p>e.g.</p> <pre><code>Introduction goes here ==Hello== foo foo ===World=== bar bar </code></pre> <p>Dict would look like:</...
0
2009-12-29T03:39:07Z
1,972,801
<p>Did you miss <a href="http://pyparsing.wikispaces.com/file/view/simpleWiki.py" rel="nofollow">this wiki-like language parser</a> in the pyParsing web site examples?</p> <pre><code>h2 = QuotedString("==") </code></pre>
3
2009-12-29T03:46:40Z
[ "python", "dictionary", "parsing", "mediawiki", "pyparsing" ]
How to use pyparsing to parse and hash strings enclosed by special characters?
1,972,781
<p>The majority of pyparsing examples that I have seen have dealt with linear expressions.</p> <p>a = 1 + 2</p> <p>I'd like to parse mediawiki headlines, and hash them to their sections.</p> <p>e.g.</p> <pre><code>Introduction goes here ==Hello== foo foo ===World=== bar bar </code></pre> <p>Dict would look like:</...
0
2009-12-29T03:39:07Z
1,972,947
<p>Also, this format is not unlike a .INI file:</p> <pre><code>[section1] a = 1 b = 3 [section2] blah=a </code></pre> <p>Which can be parsed into a nested dictionary using <a href="http://pyparsing.wikispaces.com/file/view/configParse.py" rel="nofollow">this example code</a>.</p>
1
2009-12-29T04:40:30Z
[ "python", "dictionary", "parsing", "mediawiki", "pyparsing" ]
delete a line based on logic
1,972,817
<p>I have a file where i have multiple records with such data </p> <blockquote> <p>F00DY4302B8JRQ rank=0000030 x=800.0 y=1412.0 length=89</p> </blockquote> <p>now i want to search for the line where if i find length&lt;=50 then delete this line and the next line in the file and write to another file. </p> <p>Th...
-2
2009-12-29T03:52:32Z
1,972,855
<p>From the top of my head:</p> <pre><code>for every line in file split by spaces get last token split by equal verify length write line to another file delete line and the next </code></pre> <p>Hope this is what you need to start working.</p>
1
2009-12-29T04:09:56Z
[ "python", "text-processing" ]
delete a line based on logic
1,972,817
<p>I have a file where i have multiple records with such data </p> <blockquote> <p>F00DY4302B8JRQ rank=0000030 x=800.0 y=1412.0 length=89</p> </blockquote> <p>now i want to search for the line where if i find length&lt;=50 then delete this line and the next line in the file and write to another file. </p> <p>Th...
-2
2009-12-29T03:52:32Z
1,972,856
<p>Assuming Python 2.6 (let us know if it's another version you need!), and that you want to skip <em>every</em> line with length &lt;= 50 (and ignore the next line in each case), if any:</p> <pre><code>import re def weirdtask(infname, oufname): inf = open(infname, 'r') ouf = open(oufname, 'w') rle = re.compile...
1
2009-12-29T04:10:42Z
[ "python", "text-processing" ]
delete a line based on logic
1,972,817
<p>I have a file where i have multiple records with such data </p> <blockquote> <p>F00DY4302B8JRQ rank=0000030 x=800.0 y=1412.0 length=89</p> </blockquote> <p>now i want to search for the line where if i find length&lt;=50 then delete this line and the next line in the file and write to another file. </p> <p>Th...
-2
2009-12-29T03:52:32Z
1,972,867
<p>If the columns are always in the same order and there are always the same number, you can just use the <code>.split()</code> method on the string, and find the one you want with an index:</p> <pre><code>words = line.split() l = words[4] temp = l.split("=")[2] if int(temp) &lt;= 50: # found the line, handle it ...
0
2009-12-29T04:12:49Z
[ "python", "text-processing" ]
django:error with the custom inclusiong_tag, error info:Invalid block tag
1,972,844
<p>I'm trying to write a custom inclusion_tag in django.</p> <p>Following the example on <a href="http://docs.djangoproject.com/en/dev/howto/custom-template-tags/" rel="nofollow">http://docs.djangoproject.com/en/dev/howto/custom-template-tags/</a></p> <p>I'm just writing </p> <pre><code>from django import template f...
1
2009-12-29T04:06:19Z
1,972,872
<p>The problem lies in your template. Its calling <code>{% libmas_tags %}</code>. Have you created template tags called libmas_tags? If so you might need to change it to </p> <pre><code>{% load libmas_tags %} </code></pre>
2
2009-12-29T04:14:03Z
[ "python", "django" ]
django:error with the custom inclusiong_tag, error info:Invalid block tag
1,972,844
<p>I'm trying to write a custom inclusion_tag in django.</p> <p>Following the example on <a href="http://docs.djangoproject.com/en/dev/howto/custom-template-tags/" rel="nofollow">http://docs.djangoproject.com/en/dev/howto/custom-template-tags/</a></p> <p>I'm just writing </p> <pre><code>from django import template f...
1
2009-12-29T04:06:19Z
1,973,657
<p>What is <code>libmas_tags</code>? The tag you have defined is called <code>display_records</code>, and that's what you should be calling in your template. If the tags file is called libmas_tags, you'll need to load that first as czarchaic points out.</p>
1
2009-12-29T09:07:39Z
[ "python", "django" ]
Apache: Download files getting a CR inserted before every LF (even spreadsheets)
1,972,849
<p>I am using Apache 2.2.14 and Python 2.6 for CGI on Windows XP. Files sent through CGI get corrupted. A CR gets inserted before every LF. Firefox, IE, and Curl clients give the same result. The file is the correct size, but CR's are inserted throughout, and the data is shifted down and truncated. I can look at th...
0
2009-12-29T04:07:07Z
1,972,881
<p>Use <a href="http://docs.python.org/library/msvcrt.html#msvcrt.setmode" rel="nofollow"><code>msvcrt.setmode(1, os.O_BINARY)</code></a> (after you write the headers and <code>sys.stdout.flush</code> them) to set standard output to binary mode -- poor Apache is innocent, it's a Windows thing;-).</p>
3
2009-12-29T04:17:01Z
[ "python", "apache", "cgi" ]
MATLAB's griddata3 for NumPy?
1,972,877
<p>I realize that there is a griddata for <a href="http://en.wikipedia.org/wiki/NumPy" rel="nofollow">NumPy</a> via <a href="http://en.wikipedia.org/wiki/Matplotlib" rel="nofollow">Matplotlib</a>, but is there a griddata3 (same has griddata, but for higher dimensions)?</p> <p>In other words, I have (x,y,z,d(x,y,z)) wh...
0
2009-12-29T04:15:23Z
1,973,045
<p>I am not familiar with griddata3, but you might want to look into <a href="http://docs.scipy.org/doc/numpy/reference/generated/numpy.meshgrid.html" rel="nofollow">meshgrid</a> and this related <a href="http://stackoverflow.com/questions/1827489/numpy-meshgrid-in-3d/1830192#1830192">post</a>.</p>
0
2009-12-29T05:19:04Z
[ "python", "numpy", "analysis", "interpolation", "scientific-computing" ]
MATLAB's griddata3 for NumPy?
1,972,877
<p>I realize that there is a griddata for <a href="http://en.wikipedia.org/wiki/NumPy" rel="nofollow">NumPy</a> via <a href="http://en.wikipedia.org/wiki/Matplotlib" rel="nofollow">Matplotlib</a>, but is there a griddata3 (same has griddata, but for higher dimensions)?</p> <p>In other words, I have (x,y,z,d(x,y,z)) wh...
0
2009-12-29T04:15:23Z
1,994,617
<p>Not sure how you intend to render a surface of a scalar function of 3 variables, except perhaps using cutplanes or something similar. <a href="http://code.enthought.com/projects/mayavi/" rel="nofollow">Mayavi</a> (really <a href="http://www.vtk.org/" rel="nofollow">VTK</a> which powers Mayavi) has support for effici...
1
2010-01-03T10:57:03Z
[ "python", "numpy", "analysis", "interpolation", "scientific-computing" ]
MATLAB's griddata3 for NumPy?
1,972,877
<p>I realize that there is a griddata for <a href="http://en.wikipedia.org/wiki/NumPy" rel="nofollow">NumPy</a> via <a href="http://en.wikipedia.org/wiki/Matplotlib" rel="nofollow">Matplotlib</a>, but is there a griddata3 (same has griddata, but for higher dimensions)?</p> <p>In other words, I have (x,y,z,d(x,y,z)) wh...
0
2009-12-29T04:15:23Z
4,667,091
<p><a href="http://en.wikipedia.org/wiki/SciPy" rel="nofollow">SciPy</a> 0.9 (at the moment, a first beta is out) has a new <a href="http://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.griddata.html" rel="nofollow">griddata</a> function that can handle N-dimensional data.</p>
1
2011-01-12T09:28:35Z
[ "python", "numpy", "analysis", "interpolation", "scientific-computing" ]
insert tags in ElementTree text
1,973,026
<p>I am using the Python <a href="http://effbot.org/zone/element-index.htm" rel="nofollow">ElementTree</a> module to manipulate HTML. I want to emphasize certain words, and my current solution is:</p> <pre><code>for e in tree.getiterator(): for attr in 'text', 'tail': words = (getattr(e, attr) or '').split...
1
2009-12-29T05:11:15Z
1,975,248
<p>Although ElementTree is very easy to use for most XML processing tasks, it's also inconvenient for mixed content. I suggest using DOM parser:</p> <pre><code>from xml.dom import minidom import re ws_split = re.compile(r'\s+', re.U).split def processNode(parent): doc = parent.ownerDocument for node in paren...
1
2009-12-29T15:40:33Z
[ "python", "html", "lxml", "elementtree" ]
insert tags in ElementTree text
1,973,026
<p>I am using the Python <a href="http://effbot.org/zone/element-index.htm" rel="nofollow">ElementTree</a> module to manipulate HTML. I want to emphasize certain words, and my current solution is:</p> <pre><code>for e in tree.getiterator(): for attr in 'text', 'tail': words = (getattr(e, attr) or '').split...
1
2009-12-29T05:11:15Z
1,993,970
<p>You can also use xslt and a custom xpath function to do this. </p> <p>Shown below is an example. It still needs some work, for example cleaning up extra whitespace at the end of elements and handling mixed-text, but it's another idea.</p> <p>given this input:</p> <pre><code> &lt;html> &lt;head> &lt;/head> &lt;bod...
3
2010-01-03T04:17:29Z
[ "python", "html", "lxml", "elementtree" ]
Why does this happen with Python's list.sort?
1,973,164
<p>Given the code:</p> <pre><code>a=['a','b','c','d'] b=a[::-1] print b c=zip(a,b) print c c.sort(key=lambda x:x[1])# print c </code></pre> <p>It prints:</p> <pre><code>['d', 'c', 'b', 'a'] [('a', 'd'), ('b', 'c'), ('c', 'b'), ('d', 'a')] [('d', 'a'), ('c', 'b'), ('b', 'c'), ('a', 'd')] </code></pre> <p>Why does [(...
3
2009-12-29T06:09:48Z
1,973,169
<p>because x[1] means <em>second</em></p> <p>use</p> <pre><code>c.sort(key=lambda x:x[0]) </code></pre>
7
2009-12-29T06:12:36Z
[ "python" ]
Why does this happen with Python's list.sort?
1,973,164
<p>Given the code:</p> <pre><code>a=['a','b','c','d'] b=a[::-1] print b c=zip(a,b) print c c.sort(key=lambda x:x[1])# print c </code></pre> <p>It prints:</p> <pre><code>['d', 'c', 'b', 'a'] [('a', 'd'), ('b', 'c'), ('c', 'b'), ('d', 'a')] [('d', 'a'), ('c', 'b'), ('b', 'c'), ('a', 'd')] </code></pre> <p>Why does [(...
3
2009-12-29T06:09:48Z
1,973,173
<p>You've sorted <code>c</code> using the second item as the key, and the second item does indeed go up, just as you asked for it to go up. What's so surprising?!</p>
4
2009-12-29T06:12:59Z
[ "python" ]
Why does this happen with Python's list.sort?
1,973,164
<p>Given the code:</p> <pre><code>a=['a','b','c','d'] b=a[::-1] print b c=zip(a,b) print c c.sort(key=lambda x:x[1])# print c </code></pre> <p>It prints:</p> <pre><code>['d', 'c', 'b', 'a'] [('a', 'd'), ('b', 'c'), ('c', 'b'), ('d', 'a')] [('d', 'a'), ('c', 'b'), ('b', 'c'), ('a', 'd')] </code></pre> <p>Why does [(...
3
2009-12-29T06:09:48Z
1,973,174
<pre><code>from operator import itemgetter c.sort(key=itemgetter(0)) </code></pre>
1
2009-12-29T06:13:09Z
[ "python" ]
Why does this happen with Python's list.sort?
1,973,164
<p>Given the code:</p> <pre><code>a=['a','b','c','d'] b=a[::-1] print b c=zip(a,b) print c c.sort(key=lambda x:x[1])# print c </code></pre> <p>It prints:</p> <pre><code>['d', 'c', 'b', 'a'] [('a', 'd'), ('b', 'c'), ('c', 'b'), ('d', 'a')] [('d', 'a'), ('c', 'b'), ('b', 'c'), ('a', 'd')] </code></pre> <p>Why does [(...
3
2009-12-29T06:09:48Z
1,973,218
<p>You've sorted the list using the second element of each tuple as a key so you get the tuples ordered by their second element (Notice the 'a', 'b', 'c', 'd' in increasing order). What's the problem?</p>
0
2009-12-29T06:24:56Z
[ "python" ]
Why does this happen with Python's list.sort?
1,973,164
<p>Given the code:</p> <pre><code>a=['a','b','c','d'] b=a[::-1] print b c=zip(a,b) print c c.sort(key=lambda x:x[1])# print c </code></pre> <p>It prints:</p> <pre><code>['d', 'c', 'b', 'a'] [('a', 'd'), ('b', 'c'), ('c', 'b'), ('d', 'a')] [('d', 'a'), ('c', 'b'), ('b', 'c'), ('a', 'd')] </code></pre> <p>Why does [(...
3
2009-12-29T06:09:48Z
1,973,418
<p>As the others have said, <code>[1]</code> refers to the second element, so the elements in the first part are sorted that way.</p> <p>As for the second part, <code>list.sort()</code> is <a href="http://en.wikipedia.org/wiki/Sorting_algorithm#Stability" rel="nofollow">stable</a>, so elements that evaluate to the sam...
1
2009-12-29T07:39:32Z
[ "python" ]
WMD Output Issue
1,973,751
<p>I have an issue with my google app engine whereby I am using wmd to input text and save text. In preview mode, I can see the wmd formatted correctly as html, but when I switch to output, I just see unformatted wmd. </p> <p>I have python-wmd installed, but am assuming that there is some sort of issue whereby python-...
0
2009-12-29T09:37:27Z
10,572,013
<p><a href="http://rpmfind.net/linux/rpm2html/search.php?query=python-wmd" rel="nofollow"><code>python-wmd</code></a> appears to be a "Driver for the Nintendo Wii Remote" and not a <a href="http://code.google.com/p/wmd/" rel="nofollow">Markdown</a> <a href="https://github.com/derobins/wmd#readme" rel="nofollow">Editor<...
0
2012-05-13T13:10:31Z
[ "python", "django", "wmd" ]
Infinite loop error in python code
1,973,822
<p>I am learning how to code through this book called "Headfirst Programming", which I am really enjoying so far. </p> <p>One of the projects in the book uses the following code:</p> <pre><code>def save_transaction(price, credit_card, description): file = open("transactions.txt", "a") file.write("%s%07d%s\n" % (credi...
0
2009-12-29T10:01:44Z
1,973,834
<p>As you've probably read, Python uses indentation to identify blocks of code.</p> <p>So...</p> <pre><code>while running: option = 1 for choice in items: print(str(option) + ". " + choice) option = option + 1 </code></pre> <p>will run forever, and</p> <pre><code>print(str(option) + "....
8
2009-12-29T10:04:32Z
[ "python", "loops" ]
Infinite loop error in python code
1,973,822
<p>I am learning how to code through this book called "Headfirst Programming", which I am really enjoying so far. </p> <p>One of the projects in the book uses the following code:</p> <pre><code>def save_transaction(price, credit_card, description): file = open("transactions.txt", "a") file.write("%s%07d%s\n" % (credi...
0
2009-12-29T10:01:44Z
1,973,845
<p>It's pretty clear that the indentation here is wrong -- since the whole body of the function should be indented relative to the <code>def save_transaction(price, credit_card, description):</code> line.</p> <p>Hence, I suspect that there's also a problem with the indentation below the <code>while running</code> line...
0
2009-12-29T10:06:14Z
[ "python", "loops" ]
Infinite loop error in python code
1,973,822
<p>I am learning how to code through this book called "Headfirst Programming", which I am really enjoying so far. </p> <p>One of the projects in the book uses the following code:</p> <pre><code>def save_transaction(price, credit_card, description): file = open("transactions.txt", "a") file.write("%s%07d%s\n" % (credi...
0
2009-12-29T10:01:44Z
1,973,850
<p>You need to indent forward all the lines starting from <code>print(str(option) + ". Quit"))</code>. Align them at the same level as <code>for choice in items:</code>.</p>
0
2009-12-29T10:07:33Z
[ "python", "loops" ]
How do I do text wrapping in pyCairo + Pango?
1,973,990
<p>What I need pyCairo to do is :</p> <ul> <li>generate an image of size 100x100 containing some text and an image from filesystem as background</li> <li>the text should be within a box which has text wrapping of size 20x20 with bottom left corner at (40,40).</li> <li>save this image </li> </ul>
4
2009-12-29T10:40:46Z
2,224,487
<p>You need to find a way to get the Pango context and set <a href="http://www.pygtk.org/docs/pygtk/class-pangolayout.html#method-pangolayout--set-wrap" rel="nofollow"><code>pango.Layout.set_wrap()</code></a> and <code>pango.Layout.set_width()</code>.</p>
3
2010-02-08T20:03:37Z
[ "python", "cairo", "textwrapping", "pango" ]
python - problem int/string and hash/array
1,974,434
<pre><code>f = open('transaction.log','r') ClerkHash = dict() arr = [0,0] for line in f: Tdate = line[0:12] AccountKey = line[12:50] TransType = line[22:2] ClerkKey = line[24:10] CurrencyCode = line[34:2] Amount = line[36:45] print line print '\n' print Acco...
0
2009-12-29T12:38:52Z
1,974,463
<p>Here is few issue I seen so far</p> <pre><code>Amount = line[36:45] </code></pre> <p>should be</p> <pre><code>Amount = int(line[36:45]) </code></pre> <p>and </p> <pre><code>ClerkHash[ClerkKey+AccountKey] = arr[0,0] </code></pre> <p>should be</p> <pre><code>ClerkHash[ClerkKey+AccountKey] = [0,0] </...
2
2009-12-29T12:44:32Z
[ "python", "string" ]
python - problem int/string and hash/array
1,974,434
<pre><code>f = open('transaction.log','r') ClerkHash = dict() arr = [0,0] for line in f: Tdate = line[0:12] AccountKey = line[12:50] TransType = line[22:2] ClerkKey = line[24:10] CurrencyCode = line[34:2] Amount = line[36:45] print line print '\n' print Acco...
0
2009-12-29T12:38:52Z
1,974,556
<p>Check your slice intervals! The second argument is another index, NOT the number of steps to take from the first index. I guess</p> <pre><code>TransType = line[22:2] </code></pre> <p>should rather be</p> <pre><code>TransType = line[22:24] </code></pre> <p>You overwrite values if you set </p> <pre><code>Clerk...
0
2009-12-29T13:06:51Z
[ "python", "string" ]
django double "extends", problem with login
1,974,478
<p>Hi:) I have got a small problem with template double extends system. I have got a scheme:</p> <pre><code>base.html ---&gt; index.html ---&gt; something.html </code></pre> <p>When I log in to the site I have got access to all invisible blocks (invisible blocks for anonymous users) like:</p> <pre><code>{% if user.i...
0
2009-12-29T12:47:44Z
1,974,699
<p>Are you passing the request <a href="http://docs.djangoproject.com/en/dev/ref/templates/api/#id1" rel="nofollow">context</a> to render_to_response (or HttpResponse)?<br> Information about logged in user must be stored in the context (<a href="http://docs.djangoproject.com/en/dev/ref/templates/api/#id1" rel="nofollow...
1
2009-12-29T13:44:09Z
[ "python", "django", "login" ]
Python sched alternative to cancel all events
1,974,571
<p>I'm looking for an alternative to the sched module which would allow me to cancel all events at any time. sched only allows to cancel single events by id (which is returned from the scheduler when an event is scheduled). Any pointers to Python alternatives to sched would be appreciated. Thanks Toni p</p>
1
2009-12-29T13:09:52Z
1,974,624
<p>In python 2.6, there is a read-only attribute called <code>queue</code> returning a list of upcoming events. So this will cancel all events:</p> <pre><code>s = sched.scheduler(time.time, time.sleep) map(s.cancel, s.queue) </code></pre>
5
2009-12-29T13:25:12Z
[ "python", "events" ]
django, runserver_plus - admin media files served from wrong path
1,974,697
<p>The configuration below works fine on my remote host (same dir structure, same django), all admin media are served properly</p> <p>settings</p> <pre><code>MEDIA_ROOT = '%s/static/' % FS_ROOT STATIC_DOC_ROOT = '%s/static/' % FS_ROOT MEDIA_URL = '/static/' ADMIN_MEDIA_PREFIX = '%smedia/' % MEDIA_URL </code></pre> <...
0
2009-12-29T13:43:49Z
1,976,339
<p>There are two solutions:</p> <ol> <li>You can either set a hostname in ADMIN_MEDIA_PREFIX as suggested in <a href="http://stackoverflow.com/questions/1081596/django-serving-admin-media-files/1656828#1656828">this answer</a>.</li> <li>Or you can start the development server with the --adminmedia parameter as describ...
1
2009-12-29T19:11:10Z
[ "python", "django", "file", "django-admin", "media" ]
Is there a python-equivalent of the unix "file" utility?
1,974,724
<p>I want to have different behavior in a python script, depending on the type of file. I cannot use the filename extension as it may not be present or misleading. I could call the <code>file</code> utility and parse the output, but I would rather use a python builtin for portability.</p> <p>So is there anything in py...
11
2009-12-29T13:48:23Z
1,974,737
<ul> <li><a href="http://pypi.python.org/pypi/python-magic/0.1">python-magic</a></li> <li><a href="http://pypi.python.org/pypi/pymagic/0.1">pymagic</a></li> </ul> <p>Probably others as well. "magic" is the magic keyword to search for. ;-)</p>
9
2009-12-29T13:51:01Z
[ "python", "unix" ]
how to distribute python app with glade GUI?
1,974,733
<p>I'm trying to distribute this app that I wrote in python. The application consists of 2 python scripts. 2 <code>.glade</code> files and 1 <code>.png</code> file.</p> <p>Here is my dir structure on this project</p> <pre><code>vasm/ vasmcc.py src/ vasm.py gui/ vasm.glade vasmset.glad...
1
2009-12-29T13:50:45Z
1,974,955
<p>You should take a look at <a href="http://docs.python.org/library/distutils.html" rel="nofollow">distutils</a>. You can tell it to install all kinds of files, not just the source code itself. For the user, installing your program then comes down to</p> <pre><code>$ python setup.py install </code></pre> <p>and it's...
2
2009-12-29T14:41:58Z
[ "python", "user-interface", "distutils", "glade" ]
Debug history of variable changing in python
1,974,997
<p>I need magic tool, that helps me to understand where one my problem variable is changed in the code. </p> <p>I know about perfect tool:</p> <pre><code>pdb.set_trace() </code></pre> <p>and I need something similar format, but about only one variable changing history.</p> <p>For example, my current problem is stra...
0
2009-12-29T14:47:05Z
1,975,166
<p>I'm not really familiar with django, so your mileage may vary. In general, you can override the <code>__setitem__</code> method on objects to capture item assignment. However, this doesn't work on dictionaries, only on user-created classes, so first of all it depends on what this <code>context</code> object is.</p> ...
2
2009-12-29T15:20:22Z
[ "python", "django", "debugging" ]
Flash-Selenium and Python
1,975,244
<p>I want to try <a href="http://code.google.com/p/flash-selenium/" rel="nofollow">Flash-Selenium</a> with the python driver, however I have some concerns regarding the available <a href="http://flash-selenium.googlecode.com/files/Flash-Selenium%5Fpython%5Fclient%5Fr37.zip" rel="nofollow">python</a> extension, it seems...
4
2009-12-29T15:39:02Z
7,549,080
<p>Example taken from FlashSelenium page:</p> <pre><code>from com.thoughtworks.selenium.FlashSelenium import FlashSelenium from com.thoughtworks.selenium.selenium import selenium url = "http://flashselenium.t35.com/colors.html" browserType = "*firefox" selenium = selenium("localhost", 4444, browserType, url) seleniu...
1
2011-09-25T22:32:28Z
[ "python", "selenium", "selenium-rc" ]
When should I use a Map instead of a For Loop?
1,975,250
<p>This is relating to the following: (In Python Code)</p> <pre><code>for i in object: doSomething(i) </code></pre> <p>versus</p> <pre><code>map(doSomething, object) </code></pre> <p>Both are easy to understand, and short, but is there any speed difference? Now, if doSomething had a return value we needed to...
22
2009-12-29T15:41:00Z
1,975,266
<p>Map is useful when you want to apply the function to every item of iterable and return a list of the results. This is simpler and more concise than usng a for loop and constructing a list.</p> <p>For is often more readable for other situations, and in lisp there were lots of iteration constructs that were written b...
14
2009-12-29T15:44:31Z
[ "python", "for-loop" ]
When should I use a Map instead of a For Loop?
1,975,250
<p>This is relating to the following: (In Python Code)</p> <pre><code>for i in object: doSomething(i) </code></pre> <p>versus</p> <pre><code>map(doSomething, object) </code></pre> <p>Both are easy to understand, and short, but is there any speed difference? Now, if doSomething had a return value we needed to...
22
2009-12-29T15:41:00Z
1,975,305
<p>just use list comprehensions: they're more pythonic. They're also have syntax similar to generator expressions which makes it easy to switch from one to the other. You don't need to change anything when converting your code to py3k: <code>map</code> returns an iterable in py3k and you'll have to adjust your code.</p...
7
2009-12-29T15:53:42Z
[ "python", "for-loop" ]
When should I use a Map instead of a For Loop?
1,975,250
<p>This is relating to the following: (In Python Code)</p> <pre><code>for i in object: doSomething(i) </code></pre> <p>versus</p> <pre><code>map(doSomething, object) </code></pre> <p>Both are easy to understand, and short, but is there any speed difference? Now, if doSomething had a return value we needed to...
22
2009-12-29T15:41:00Z
1,975,427
<p><strong>EDIT</strong>: I didn't realize that <code>map</code> equals <code>itertools.imap</code> after python 3.0. So the conclusion here may not be correct. I'll re-run the test on python 2.6 tomorrow and post result.</p> <p><strike>If <code>doSomething</code> is very "tiny", <code>map</code> can be a lot faster t...
1
2009-12-29T16:17:09Z
[ "python", "for-loop" ]
When should I use a Map instead of a For Loop?
1,975,250
<p>This is relating to the following: (In Python Code)</p> <pre><code>for i in object: doSomething(i) </code></pre> <p>versus</p> <pre><code>map(doSomething, object) </code></pre> <p>Both are easy to understand, and short, but is there any speed difference? Now, if doSomething had a return value we needed to...
22
2009-12-29T15:41:00Z
1,975,588
<p>Are you familiar with the timeit module? Below are some timings. -s performs a one-time setup, and then the command is looped and the best time recorded.</p> <pre><code>1&gt; python -m timeit -s "L=[]; M=range(1000)" "for m in M: L.append(m*2)" 1000 loops, best of 3: 432 usec per loop 2&gt; python -m timeit -s "...
7
2009-12-29T16:45:45Z
[ "python", "for-loop" ]