title stringlengths 10 172 | question_id int64 469 40.1M | question_body stringlengths 22 48.2k | question_score int64 -44 5.52k | question_date stringlengths 20 20 | answer_id int64 497 40.1M | answer_body stringlengths 18 33.9k | answer_score int64 -38 8.38k | answer_date stringlengths 20 20 | tags listlengths 1 5 |
|---|---|---|---|---|---|---|---|---|---|
System theme icons and PyQt4 | 997,904 | <p>I'm writing a basic program in python using the PyQt4 module. I'd like to be able to use my system theme's icons for things like the preference dialog's icon, but i have no idea how to do this. So my question is, how do you get the location of an icon, but make sure it changes with the system's icon theme? If it mat... | 7 | 2009-06-15T19:25:28Z | 999,115 | <p>I spent a decent amount of researching this myself not long ago, and my conclusion was that, unfortunately, Qt doesn't provide this functionality in a cross-platform fashion. Ideally the QIcon class would have defaults for file open, save, '+', '-', preferences, etc, but considering it doesn't you'll have to grab t... | 0 | 2009-06-16T00:26:37Z | [
"python",
"icons",
"pyqt4"
] |
System theme icons and PyQt4 | 997,904 | <p>I'm writing a basic program in python using the PyQt4 module. I'd like to be able to use my system theme's icons for things like the preference dialog's icon, but i have no idea how to do this. So my question is, how do you get the location of an icon, but make sure it changes with the system's icon theme? If it mat... | 7 | 2009-06-15T19:25:28Z | 999,174 | <p>Unfortunately, It appears that Qt does not support getting icons for a specific theme. There are ways to do this for both KDE and Gnome.</p>
<p>The KDE way is quite elegant, which makes sense considering that Qt is KDE's toolkit. Instead of using the PyQt4.QtGui class QIcon, you instead use the PyKDE4.kdeui class K... | 6 | 2009-06-16T01:02:39Z | [
"python",
"icons",
"pyqt4"
] |
Python urllib2 timeout when using Tor as proxy? | 997,969 | <p>I am using Python's urllib2 with Tor as a proxy to access a website. When I
open the site's main page it works fine but when I try to view the login page
(not actually log-in but just view it) I get the following error...</p>
<pre><code>URLError: <urlopen error (10060, 'Operation timed out')>
</code></pre>
... | 3 | 2009-06-15T19:41:31Z | 998,107 | <p>I don't know enough about Tor to be sure, but the timeout may not happen on the server side, but on one of the Tor nodes somewhere between you and the server. In that case there is nothing you can do other than to retry the connection.</p>
| 0 | 2009-06-15T20:05:15Z | [
"python",
"timeout",
"urllib2",
"tor"
] |
Python urllib2 timeout when using Tor as proxy? | 997,969 | <p>I am using Python's urllib2 with Tor as a proxy to access a website. When I
open the site's main page it works fine but when I try to view the login page
(not actually log-in but just view it) I get the following error...</p>
<pre><code>URLError: <urlopen error (10060, 'Operation timed out')>
</code></pre>
... | 3 | 2009-06-15T19:41:31Z | 998,184 | <p>According to the <a href="http://docs.python.org/library/socket.html" rel="nofollow">Python Socket Documentation</a> the default is no timeout so specifying a value of "None" is redundant. </p>
<p>There are a number of possible reasons that your connection is dropping. One could be that your user-agent is "Python-u... | 3 | 2009-06-15T20:22:42Z | [
"python",
"timeout",
"urllib2",
"tor"
] |
Python urllib2 timeout when using Tor as proxy? | 997,969 | <p>I am using Python's urllib2 with Tor as a proxy to access a website. When I
open the site's main page it works fine but when I try to view the login page
(not actually log-in but just view it) I get the following error...</p>
<pre><code>URLError: <urlopen error (10060, 'Operation timed out')>
</code></pre>
... | 3 | 2009-06-15T19:41:31Z | 999,077 | <blockquote>
<p>urllib2.urlopen(url[, data][, timeout])</p>
<p>The optional timeout parameter specifies a timeout in seconds for blocking operations like the connection attempt (if not specified, the global default timeout setting will be used). This actually only works for HTTP, HTTPS, FTP and FTPS connections.... | 0 | 2009-06-16T00:09:28Z | [
"python",
"timeout",
"urllib2",
"tor"
] |
Hash method and UnicodeEncodeError | 998,302 | <p>In Python 2.5, I have the following hash function:</p>
<pre><code>def __hash__(self):
return hash(str(self))
</code></pre>
<p>It works well for my needs, but now I started to get the following error message. Any idea of what is going on?</p>
<pre><code>return hash(str(self))
UnicodeEncodeError: 'ascii' codec ca... | 0 | 2009-06-15T20:48:13Z | 998,348 | <p>The problem is that you are trying to hash a string that is not convertible to ASCII. The str method takes a unicode object and, by default, converts it to ASCII.</p>
<p>To fix this problem you need to either hash the unicode object directly, or else convert the string using the correct codec.</p>
<p>For example,... | 2 | 2009-06-15T20:56:16Z | [
"python",
"string",
"unicode",
"hash"
] |
Hash method and UnicodeEncodeError | 998,302 | <p>In Python 2.5, I have the following hash function:</p>
<pre><code>def __hash__(self):
return hash(str(self))
</code></pre>
<p>It works well for my needs, but now I started to get the following error message. Any idea of what is going on?</p>
<pre><code>return hash(str(self))
UnicodeEncodeError: 'ascii' codec ca... | 0 | 2009-06-15T20:48:13Z | 998,356 | <p>The error doesn't seem to be in the <code>__hash__</code> function, but in the <code>__str__</code> function.</p>
<p>Try <code>str(yourobject)</code> in the object with the problem and you'll see what I mean.</p>
<p>Please edit the question and add your <code>__str__</code> function (and relevant data) so we can p... | 1 | 2009-06-15T20:58:52Z | [
"python",
"string",
"unicode",
"hash"
] |
Unable to have a command line parameter in Python | 998,314 | <p>I run</p>
<pre><code>import sys
print "x \tx^3\tx^3+x^3\t(x+1)^3\tcube+cube=cube+1"
for i in range(sys.argv[2]): // mistake here
cube=i*i*i
cube2=cube+cube
cube3=(i+1)*(i+1)*(i+1)
truth=(cube2==cube3)
print i, "\t", cube, "\t", cube + cube, "\t", cube3, "\t", truth
</code></pre>
... | 0 | 2009-06-15T20:50:12Z | 998,329 | <p>You want <code>int(sys.argv[1])</code> not 2.</p>
<p>Ideally you would check the length of sys.argv first and print a useful error message if the user doesn't provide the proper arguments.</p>
<p>Edit: See <a href="http://www.faqs.org/docs/diveintopython/kgp_commandline.html" rel="nofollow">http://www.faqs.org/doc... | 3 | 2009-06-15T20:52:51Z | [
"python"
] |
Unable to have a command line parameter in Python | 998,314 | <p>I run</p>
<pre><code>import sys
print "x \tx^3\tx^3+x^3\t(x+1)^3\tcube+cube=cube+1"
for i in range(sys.argv[2]): // mistake here
cube=i*i*i
cube2=cube+cube
cube3=(i+1)*(i+1)*(i+1)
truth=(cube2==cube3)
print i, "\t", cube, "\t", cube + cube, "\t", cube3, "\t", truth
</code></pre>
... | 0 | 2009-06-15T20:50:12Z | 998,344 | <p>Use:</p>
<pre><code>sys.argv[1]
</code></pre>
<p>also note that arguments are always strings, and <code>range</code> expects an integer.</p>
<p>So the correct code would be:</p>
<pre><code>for i in range(int(sys.argv[1])):
</code></pre>
| 6 | 2009-06-15T20:55:34Z | [
"python"
] |
Unable to have a command line parameter in Python | 998,314 | <p>I run</p>
<pre><code>import sys
print "x \tx^3\tx^3+x^3\t(x+1)^3\tcube+cube=cube+1"
for i in range(sys.argv[2]): // mistake here
cube=i*i*i
cube2=cube+cube
cube3=(i+1)*(i+1)*(i+1)
truth=(cube2==cube3)
print i, "\t", cube, "\t", cube + cube, "\t", cube3, "\t", truth
</code></pre>
... | 0 | 2009-06-15T20:50:12Z | 998,346 | <p>Its sys.argv[1] instead of 2. You also want to makes sure that you convert that to an integer if you're doing math with it.</p>
<p>so instead of</p>
<pre><code>for i in range(sys.argv[2]):
</code></pre>
<p>you want</p>
<pre><code>for i in range(int(sys.argv[1])):
</code></pre>
| 1 | 2009-06-15T20:56:04Z | [
"python"
] |
Unable to have a command line parameter in Python | 998,314 | <p>I run</p>
<pre><code>import sys
print "x \tx^3\tx^3+x^3\t(x+1)^3\tcube+cube=cube+1"
for i in range(sys.argv[2]): // mistake here
cube=i*i*i
cube2=cube+cube
cube3=(i+1)*(i+1)*(i+1)
truth=(cube2==cube3)
print i, "\t", cube, "\t", cube + cube, "\t", cube3, "\t", truth
</code></pre>
... | 0 | 2009-06-15T20:50:12Z | 1,000,029 | <p>Here are some tips on how you can often solve this type of problem <em>yourself</em>:</p>
<p>Read what the error message is telling you: "list index out of range".</p>
<p>What list? Two choices (1) the list returned by range (2) sys.argv</p>
<p>In this case, it can't be (1); it's impossible to get that error out ... | 2 | 2009-06-16T07:38:52Z | [
"python"
] |
Unable to have a command line parameter in Python | 998,314 | <p>I run</p>
<pre><code>import sys
print "x \tx^3\tx^3+x^3\t(x+1)^3\tcube+cube=cube+1"
for i in range(sys.argv[2]): // mistake here
cube=i*i*i
cube2=cube+cube
cube3=(i+1)*(i+1)*(i+1)
truth=(cube2==cube3)
print i, "\t", cube, "\t", cube + cube, "\t", cube3, "\t", truth
</code></pre>
... | 0 | 2009-06-15T20:50:12Z | 24,611,310 | <p>I'd like to suggest having a look at Python's <a href="https://docs.python.org/dev/library/argparse.html" rel="nofollow"><code>argparse</code></a> module, which is a giant improvement in parsing commandline parameters - it can also do the conversion to <code>int</code> for you including type-checking and error-repor... | 1 | 2014-07-07T13:06:37Z | [
"python"
] |
How can I get the order of an element attribute list using Python xml.sax? | 998,514 | <p>How can I get the order of an element attribute list? It's not totally necessary for the final processing, but it's nice to:</p>
<ul>
<li><p>in a filter, not to gratuitously reorder the attribute list</p></li>
<li><p>while debugging, print the data in the same order as it appears in the input</p></li>
</ul>
<p>He... | 0 | 2009-06-15T21:33:52Z | 998,598 | <p>I don't think it can be done with SAX (at least as currently supported by Python). It could be done with <a href="http://docs.python.org/library/pyexpat.html" rel="nofollow">expat</a>, setting the <code>ordered_attributes</code> attribute of the parser object to <code>True</code> (the attributes are then two paralle... | 1 | 2009-06-15T21:54:48Z | [
"python",
"xml",
"sax"
] |
How can I get the order of an element attribute list using Python xml.sax? | 998,514 | <p>How can I get the order of an element attribute list? It's not totally necessary for the final processing, but it's nice to:</p>
<ul>
<li><p>in a filter, not to gratuitously reorder the attribute list</p></li>
<li><p>while debugging, print the data in the same order as it appears in the input</p></li>
</ul>
<p>He... | 0 | 2009-06-15T21:33:52Z | 998,741 | <p>Unfortunately, it's impossible in the Python implementation of Sax.</p>
<p>This code from the Python library (v2.5) tells you all you need to know:</p>
<pre><code>class AttributesImpl:
def __init__(self, attrs):
"""Non-NS-aware implementation.
attrs should be of the form {name : value}."""
... | 1 | 2009-06-15T22:24:10Z | [
"python",
"xml",
"sax"
] |
Make my code handle in the background function calls that take a long time to finish | 998,674 | <p>Certain functions in my code take a long time to return. I don't need the return value and I'd like to execute the next lines of code in the script before the slow function returns. More precisely, the functions send out commands via USB to another system (via a C++ library with SWIG) and once the other system has c... | 2 | 2009-06-15T22:09:02Z | 998,718 | <pre><code>from threading import Thread
# ... your code
calcthread = Thread(target=longcalc)
timethread = Thread(target=longtime)
print "tic"
calcthread.start()
print "toc"
timethread.start()
print "tic"
</code></pre>
<p>Have a look at the <a href="http://docs.python.org/library/threading.html" rel="nofollow">py... | 1 | 2009-06-15T22:20:05Z | [
"python",
"multithreading"
] |
Make my code handle in the background function calls that take a long time to finish | 998,674 | <p>Certain functions in my code take a long time to return. I don't need the return value and I'd like to execute the next lines of code in the script before the slow function returns. More precisely, the functions send out commands via USB to another system (via a C++ library with SWIG) and once the other system has c... | 2 | 2009-06-15T22:09:02Z | 998,743 | <p>Unless the SWIGged C++ code is specifically set up to release the GIL (Global Interpreter Lock) before long delays and re-acquire it before getting back to Python, multi-threading might not prove very useful in practice. You could try <a href="http://docs.python.org/library/multiprocessing.html" rel="nofollow">mult... | 4 | 2009-06-15T22:24:54Z | [
"python",
"multithreading"
] |
Make my code handle in the background function calls that take a long time to finish | 998,674 | <p>Certain functions in my code take a long time to return. I don't need the return value and I'd like to execute the next lines of code in the script before the slow function returns. More precisely, the functions send out commands via USB to another system (via a C++ library with SWIG) and once the other system has c... | 2 | 2009-06-15T22:09:02Z | 1,006,101 | <p>You can use a Future, which is not included in the standard library, but very simple to implement:</p>
<pre><code>from threading import Thread, Event
class Future(object):
def __init__(self, thunk):
self._thunk = thunk
self._event = Event()
self._result = None
self._failed = Non... | 0 | 2009-06-17T09:54:22Z | [
"python",
"multithreading"
] |
Django ImportError at / no matter what I do | 998,702 | <p>So I've just started playing around with Django and I decided to give it a try on my server. So I installed Django and created a new project, following the basics outlined in the tutorial on Djangoproject.com</p>
<p>Unfortunatly, no matter what I do, I can't get views to work: I constantly get </p>
<pre><code>Impo... | 3 | 2009-06-15T22:17:10Z | 998,933 | <p>Your <code>urls.py</code> is wrong; you should consider reading <a href="http://docs.djangoproject.com/en/dev/intro/tutorial03/#intro-tutorial03">this</a> and <a href="http://docs.djangoproject.com/en/dev/topics/http/urls/#topics-http-urls">this</a>.</p>
<p>You don't include a function; you include a module. You n... | 12 | 2009-06-15T23:19:57Z | [
"python",
"django"
] |
Django ImportError at / no matter what I do | 998,702 | <p>So I've just started playing around with Django and I decided to give it a try on my server. So I installed Django and created a new project, following the basics outlined in the tutorial on Djangoproject.com</p>
<p>Unfortunatly, no matter what I do, I can't get views to work: I constantly get </p>
<pre><code>Impo... | 3 | 2009-06-15T22:17:10Z | 999,105 | <p>Do you have <code>__init__.py</code> in each of the mecore and views directories, as well as an index.py in views?</p>
<p>A directory is a package, from Python's viewpoint, only if it has a file named <code>__init__.py</code> (it may be empty, if you don't need to execute any special code when that package is impor... | 3 | 2009-06-16T00:22:18Z | [
"python",
"django"
] |
Django ImportError at / no matter what I do | 998,702 | <p>So I've just started playing around with Django and I decided to give it a try on my server. So I installed Django and created a new project, following the basics outlined in the tutorial on Djangoproject.com</p>
<p>Unfortunatly, no matter what I do, I can't get views to work: I constantly get </p>
<pre><code>Impo... | 3 | 2009-06-15T22:17:10Z | 39,809,097 | <p>From <a href="http://stackoverflow.com/questions/22011791/importerror-no-module-named-views">ImportError No module named views</a>:</p>
<blockquote>
<p>Try and move <code>views.py</code> to the "inner" mysite directory. Views are part of an application, hence the need to move them inside the application directory... | -1 | 2016-10-01T16:44:33Z | [
"python",
"django"
] |
Handle either a list or single integer as an argument | 998,938 | <p>A function should select rows in a table based on the row name (column 2 in this case). It should be able to take either a single name or a list of names as arguments and handle them correctly.</p>
<p>This is what I have now, but ideally there wouldn't be this duplicated code and something like exceptions would be ... | 21 | 2009-06-15T23:23:35Z | 998,949 | <p>I would do just this:</p>
<pre><code>def select_rows(to_select):
# For a list
for row in range(0, table.numRows()):
if _table.item(row, 1).text() in to_select:
table.selectRow(row)
</code></pre>
<p>and expect that the argument will always be a list - even if its just a list of one eleme... | 9 | 2009-06-15T23:28:10Z | [
"python",
"list",
"function",
"integer"
] |
Handle either a list or single integer as an argument | 998,938 | <p>A function should select rows in a table based on the row name (column 2 in this case). It should be able to take either a single name or a list of names as arguments and handle them correctly.</p>
<p>This is what I have now, but ideally there wouldn't be this duplicated code and something like exceptions would be ... | 21 | 2009-06-15T23:23:35Z | 998,965 | <p>You could redefine your function to take any number of arguments, like this:</p>
<pre><code>def select_rows(*arguments):
for row in range(0, table.numRows()):
if _table.item(row, 1).text() in arguments:
table.selectRow(row)
</code></pre>
<p>Then you can pass a single argument like this:</p>... | 10 | 2009-06-15T23:31:14Z | [
"python",
"list",
"function",
"integer"
] |
Handle either a list or single integer as an argument | 998,938 | <p>A function should select rows in a table based on the row name (column 2 in this case). It should be able to take either a single name or a list of names as arguments and handle them correctly.</p>
<p>This is what I have now, but ideally there wouldn't be this duplicated code and something like exceptions would be ... | 21 | 2009-06-15T23:23:35Z | 999,278 | <p>Actually I agree with Andrew Hare above, just pass a list with a single element.</p>
<p>But if you really must accept a non-list, how about just turning it into a list in that case?</p>
<pre><code>def select_rows(to_select):
if type(to_select) is not list: to_select = [ to_select ]
for row in range(0, tab... | 13 | 2009-06-16T01:52:38Z | [
"python",
"list",
"function",
"integer"
] |
Handle either a list or single integer as an argument | 998,938 | <p>A function should select rows in a table based on the row name (column 2 in this case). It should be able to take either a single name or a list of names as arguments and handle them correctly.</p>
<p>This is what I have now, but ideally there wouldn't be this duplicated code and something like exceptions would be ... | 21 | 2009-06-15T23:23:35Z | 1,001,898 | <p>I'd go along with Sharkey's version, but use a bit more duck typing:</p>
<pre><code>def select_rows(to_select):
try:
len(to_select)
except TypeError:
to_select = [to_select]
for row in range(0, table.numRows()):
if _table.item(row, 1).text() in to_select:
table.selec... | 2 | 2009-06-16T14:36:11Z | [
"python",
"list",
"function",
"integer"
] |
Is  a valid character in XML? | 998,950 | <p>On this data:</p>
<pre><code><row Id="37501" PostId="135577" Text="...uses though.&#x10;"/>
</code></pre>
<p>I'm getting an error with the Python sax parser:</p>
<pre><code>xml.sax._exceptions.SAXParseException:
comments.xml:29776:332: reference to invalid character number
</code></pre>
<p>I trimmed th... | 9 | 2009-06-15T23:28:31Z | 998,988 | <p><code>&#10;</code> is the linefeed character, which seems to be the intent.</p>
<p><code>&#x10;</code> would be the same as <code>&#16;</code> (10 hex is 16 decimal) and would refer to the DLE (data link escape) character.</p>
<p>DLE is a <a href="http://en.wikipedia.org/wiki/Control%5Fcharacter#Transm... | 4 | 2009-06-15T23:40:12Z | [
"python",
"xml"
] |
Is  a valid character in XML? | 998,950 | <p>On this data:</p>
<pre><code><row Id="37501" PostId="135577" Text="...uses though.&#x10;"/>
</code></pre>
<p>I'm getting an error with the Python sax parser:</p>
<pre><code>xml.sax._exceptions.SAXParseException:
comments.xml:29776:332: reference to invalid character number
</code></pre>
<p>I trimmed th... | 9 | 2009-06-15T23:28:31Z | 999,048 | <p>As others have stated, you probably meant <code>&#10;</code>. The reason why <code>&#x10;</code> (0x10 = 10h = 16) is invalid is that it's explicitly excluded by the XML 1.0 standard: (<a href="http://www.w3.org/TR/xml/#NT-Char">http://www.w3.org/TR/xml/#NT-Char</a>)</p>
<pre><code>Char ::= #x9 | #xA | #xD ... | 12 | 2009-06-15T23:59:20Z | [
"python",
"xml"
] |
Generic Views from the object_id or the parent object | 999,291 | <p>I have a model that represents a position at a company:</p>
<pre><code>class Position(models.Model):
preferred_q = ForeignKey("Qualifications", blank=True, null=True, related_name="pref")
base_q = ForeignKey("Qualifications", blank=True, null=True, related_name="base")
#[...]
</code></pre>
<p>It has t... | 0 | 2009-06-16T01:57:49Z | 1,000,738 | <p>As explained in the <a href="https://docs.djangoproject.com/en/1.4/ref/generic-views/#django-views-generic-create-update-update-object" rel="nofollow">documentation for the <code>update_object</code> generic view</a>, if you have <code>ParentModel</code> as value for the <code>'model'</code> key in the <code>options... | -1 | 2009-06-16T10:45:44Z | [
"python",
"django",
"django-generic-views"
] |
Generic Views from the object_id or the parent object | 999,291 | <p>I have a model that represents a position at a company:</p>
<pre><code>class Position(models.Model):
preferred_q = ForeignKey("Qualifications", blank=True, null=True, related_name="pref")
base_q = ForeignKey("Qualifications", blank=True, null=True, related_name="base")
#[...]
</code></pre>
<p>It has t... | 0 | 2009-06-16T01:57:49Z | 1,000,925 | <p>If you want the edit form to be for one of the related instances of InnerModel, but you want to pass in the PK for ParentModel in the URL (as best I can tell this is what you're asking, though it isn't very clear), you will have to use a wrapper view. Otherwise how is Django's generic view supposed to magically kno... | 0 | 2009-06-16T11:36:20Z | [
"python",
"django",
"django-generic-views"
] |
Writing tests for Django's admin actions | 999,452 | <p>I'm using Django 1.1 beta and hoping to use admin actions. I have to write unit tests for those, but I don't get it how to write tests for them.</p>
<p>For normal view handler functions, I can use Django's TestClient to simulate http request/response, but how should it be done with admin actions?</p>
| 5 | 2009-06-16T03:13:23Z | 1,000,185 | <p>Testing django admin is currently pain, because of admin's tight coupling. AFAIK, You can still use request/response, but I gave up and use only functional tests (Selenium, but you can use Windmill as well) and unit testing only our admin extensions.</p>
<p>There is a GSoC project for covering admin with Windmill t... | 4 | 2009-06-16T08:29:58Z | [
"python",
"django",
"unit-testing",
"testing",
"django-admin"
] |
xml.dom.minidom Document() in Python/django outputting memory location | 999,462 | <p>I'm learning Python and django at the same time. I'm trying to create an xml document to return some XML from a view. I'm using the django development server at the moment and I keep getting this information spitting out in my views instead of the document I tried to create.</p>
<p>Here's my code</p>
<pre><code>... | 0 | 2009-06-16T03:35:52Z | 999,485 | <p>You'll need to call <code>xmlFailed.toxml()</code> or the like in order to get XML out of your object -- looks like that's not what you're doing (in the code you didn't show us).</p>
| 1 | 2009-06-16T03:49:18Z | [
"python",
"xml",
"django",
"minidom"
] |
Problems with SQLAlchemy and VirtualEnv | 999,677 | <p>I'm trying to use SQLAlchemy under a virtualenv on OS X 10.5, but cannot seem to get it to load whatsoever.</p>
<p>Here's what I've done</p>
<pre><code>mkvirtualenv --no-site-packages test
easy_install sqlalchemy
</code></pre>
<p>I try to import sqlalchemy from the interpreter and everything works fine, but if i ... | 1 | 2009-06-16T05:10:55Z | 999,705 | <p>I fixed my own problem... I had another script named sqlalchemy.py in the same folder i was working in that was mucking everything up.</p>
| 8 | 2009-06-16T05:21:23Z | [
"python",
"sqlalchemy",
"virtualenv"
] |
Problems with SQLAlchemy and VirtualEnv | 999,677 | <p>I'm trying to use SQLAlchemy under a virtualenv on OS X 10.5, but cannot seem to get it to load whatsoever.</p>
<p>Here's what I've done</p>
<pre><code>mkvirtualenv --no-site-packages test
easy_install sqlalchemy
</code></pre>
<p>I try to import sqlalchemy from the interpreter and everything works fine, but if i ... | 1 | 2009-06-16T05:10:55Z | 21,005,729 | <p>Try</p>
<pre><code>sudo pip install sqlalchemy
</code></pre>
<p>It should help</p>
| -2 | 2014-01-08T20:23:36Z | [
"python",
"sqlalchemy",
"virtualenv"
] |
webob cookies | 999,873 | <p>I am not able to set cookies using following statements</p>
<pre><code> self.request.headers['Cookie'] = 'uniqueid = ',unique_identifier
self.request.headers['Cookie'] = 'nickname = ',nickname
</code></pre>
<p>as
self.request.cookies </p>
<p>is returning null dictionary in another request.</p>
<p>enviro... | 1 | 2009-06-16T06:47:55Z | 999,895 | <p>Changing the cookies in the request does nothing to the cookie on the client.</p>
<p>You need to set the "Set-Cookie" header in the response to the client.</p>
<p>You could use something like this (untested by me) <a href="http://appengine-cookbook.appspot.com/recipe/a-simple-cookie-class/">Google App Engine Cooki... | 5 | 2009-06-16T06:54:50Z | [
"python",
"google-app-engine",
"cookies",
"session"
] |
webob cookies | 999,873 | <p>I am not able to set cookies using following statements</p>
<pre><code> self.request.headers['Cookie'] = 'uniqueid = ',unique_identifier
self.request.headers['Cookie'] = 'nickname = ',nickname
</code></pre>
<p>as
self.request.cookies </p>
<p>is returning null dictionary in another request.</p>
<p>enviro... | 1 | 2009-06-16T06:47:55Z | 2,661,791 | <p>The <a href="http://pythonpaste.org/webob/reference.html#id5" rel="nofollow">WebOb Reference explains set_cookie</a> well - if youre on a framework using the WebOb Response (not valid for Google App Engine, it uses an own Repsonse)</p>
| 3 | 2010-04-18T09:45:32Z | [
"python",
"google-app-engine",
"cookies",
"session"
] |
Python - Print on stdout on a "terminal" | 1,000,360 | <p>Before starting, I ask you all to apologize for the question. Maybe it is stupid, but I cannot find a solution.
I am working on a remote machine, and have no idea what type. </p>
<p>My python code, that seems to work, is the one below. The problem is that I am trying to print some outputs on the screen but nothing ... | 1 | 2009-06-16T09:11:51Z | 1,000,400 | <p>This is a wild guess, but looking at the wording in your comments indicates that it might be a web server application (hint: more detail on your environment would be helpful). In this case, stdout is probably going somewhere else, at least not to the browser.</p>
<p>How are you actually running that code? Do you ty... | 2 | 2009-06-16T09:22:58Z | [
"python",
"stdout"
] |
Python - Print on stdout on a "terminal" | 1,000,360 | <p>Before starting, I ask you all to apologize for the question. Maybe it is stupid, but I cannot find a solution.
I am working on a remote machine, and have no idea what type. </p>
<p>My python code, that seems to work, is the one below. The problem is that I am trying to print some outputs on the screen but nothing ... | 1 | 2009-06-16T09:11:51Z | 1,000,425 | <p>To redirect stdout to something that you can read, a file in this case:</p>
<pre><code>class PyLogger:
def __init__(self, source):
self.file_handle = open('Python_Log.txt', 'a')
self.source=source
self.buf = []
def write(self, data):
self.buf.append(data)
if data.endswith('\n'):
self... | 2 | 2009-06-16T09:27:56Z | [
"python",
"stdout"
] |
Python - Print on stdout on a "terminal" | 1,000,360 | <p>Before starting, I ask you all to apologize for the question. Maybe it is stupid, but I cannot find a solution.
I am working on a remote machine, and have no idea what type. </p>
<p>My python code, that seems to work, is the one below. The problem is that I am trying to print some outputs on the screen but nothing ... | 1 | 2009-06-16T09:11:51Z | 1,000,442 | <pre><code>import sys
print "Hi!"
sys.stdout.flush()
</code></pre>
| 7 | 2009-06-16T09:32:10Z | [
"python",
"stdout"
] |
run django with xampp on windows | 1,000,444 | <p>can i run django (Python framework) site with xampp on windows?
Please guide me.</p>
| 11 | 2009-06-16T09:32:33Z | 1,000,693 | <p>I'm not sure what you want, so this may not be a proper answer.</p>
<p>If you just want to run a development server (for yourself), it would be easier to use a web server provided by Django framework. Read more about that in the book: <a href="http://www.djangobook.com/en/2.0/chapter02/" rel="nofollow">http://www.d... | 5 | 2009-06-16T10:31:19Z | [
"python",
"django",
"xampp"
] |
run django with xampp on windows | 1,000,444 | <p>can i run django (Python framework) site with xampp on windows?
Please guide me.</p>
| 11 | 2009-06-16T09:32:33Z | 1,001,029 | <p><a href="http://www.apachefriends.org/en/xampp.html">XAMPP</a> for windows contains: Apache, MySQL, PHP + PEAR, Perl, <code>mod_php</code>, <code>mod_perl</code>, <code>mod_ssl</code>, OpenSSL, phpMyAdmin, Webalizer, Mercury Mail Transport System for Win32 and NetWare Systems v3.32, Ming, JpGraph, FileZilla FTP Serv... | 37 | 2009-06-16T11:56:55Z | [
"python",
"django",
"xampp"
] |
run django with xampp on windows | 1,000,444 | <p>can i run django (Python framework) site with xampp on windows?
Please guide me.</p>
| 11 | 2009-06-16T09:32:33Z | 1,001,693 | <p>Yes, you can, but first you have to install Python and mod_python. See <a href="http://www.apachefriends.org/en/faq-xampp-windows.html#addons" rel="nofollow">this FAQ</a>.</p>
<p>However for development purposes, it is far easier to use the built in Django development server. This will be much easier to use and set... | 0 | 2009-06-16T14:03:56Z | [
"python",
"django",
"xampp"
] |
run django with xampp on windows | 1,000,444 | <p>can i run django (Python framework) site with xampp on windows?
Please guide me.</p>
| 11 | 2009-06-16T09:32:33Z | 4,307,901 | <p>The running django on xampp can be divided into two steps.</p>
<ul>
<li>Step 1 : install wsgi and check if everything is OK
<ul>
<li>follow the steps in the answer of this post - <a href="http://stackoverflow.com/questions/3891996/setting-python-path-in-windows-xampp-using-wsgi">Setting Python Path in Windows XAMP... | 5 | 2010-11-29T20:41:48Z | [
"python",
"django",
"xampp"
] |
run django with xampp on windows | 1,000,444 | <p>can i run django (Python framework) site with xampp on windows?
Please guide me.</p>
| 11 | 2009-06-16T09:32:33Z | 6,937,390 | <p>You may want to checkout <a href="http://bitnami.org/stack/djangostack" rel="nofollow">DjangoStack</a>. It is similar to XAMPP in that is free, multiplatform and self-contained but it comes with Django installed by default.</p>
| 3 | 2011-08-04T07:00:40Z | [
"python",
"django",
"xampp"
] |
list() doesn't work in appengine? | 1,000,448 | <p>i am trying to use set function in appengine, to prepare a list with unique elements. I hit a snag when i wrote a python code which works fine in the python shell but not in appengine + django</p>
<p>This is what i intend to do(ran this script in IDLE):</p>
<pre><code>import re
value=' r.dushaynth@gmail.com, das... | 0 | 2009-06-16T09:33:18Z | 1,000,519 | <p>It seems like you implemented your own list() function. Its <code>return</code> statements should be at line 208 of your file (views.py). You should rename your <code>list()</code> function to something else (even <code>list_()</code>).</p>
<p>EDIT: Also you can change you regexp, like this:</p>
<pre><code>import ... | 8 | 2009-06-16T09:51:11Z | [
"python",
"django",
"google-app-engine"
] |
Is there an option to configure a priority in memcached? (Similiar to Expiry) | 1,000,540 | <p>A hashtable in memcached will be discarded either when it's Expired or when there's not enough memory and it's choosen to die based on the Least Recently Used algorithm.</p>
<p>Can we put a Priority to hint or influence the LRU algorithm? I want to use memcached to store Web Sessions so i can use the cheap round-ro... | 0 | 2009-06-16T09:56:53Z | 1,130,289 | <p>Not that I know of.
memcached is designed to be very fast and very straightforward, no fancy weights and priorities keep it simple.</p>
<p>You should not rely on memcache for persistent session storage. You should keep your sessions in the DB, but you can cache them in memcache. This way you can enjoy both worlds.<... | 1 | 2009-07-15T09:13:33Z | [
"python",
"database",
"session",
"caching",
"memcached"
] |
How to flatten a fish eye picture (with python)? | 1,000,806 | <p>I've found programs to turn fish eye pictures into flat ones.</p>
<p>I'd like to learn the process behind the scenes.</p>
<p>Can someone share their knowledge about the technique?</p>
| 1 | 2009-06-16T11:07:46Z | 1,001,110 | <p>My understanding is that fish eye effect is basically a projection on a semi-sphere, right? To reverse that you need to use equations for projecting a semi-sphere into a plane. A quick search revealed those Fisheye Projection <a href="http://wiki.panotools.org/Fisheye%5FProjection" rel="nofollow">equations</a>, reve... | 1 | 2009-06-16T12:17:54Z | [
"python",
"image-processing",
"fisheye",
"photography"
] |
How to keep a Python script output window open? | 1,000,900 | <p>I have just started with Python. When I execute a python script file on Windows, the output window appears but instantaneously goes away. I need it to stay there so I can analyze my output. How can I keep it open?</p>
| 108 | 2009-06-16T11:31:16Z | 1,000,912 | <p>Start the script from already open cmd window or
at the end of script add something like this, in Python 2:</p>
<pre><code> raw_input("Press enter to exit ;)")
</code></pre>
<p>Or, in Python 3:</p>
<pre><code>input("Press enter to exit ;)")
</code></pre>
| 18 | 2009-06-16T11:33:39Z | [
"python",
"windows"
] |
How to keep a Python script output window open? | 1,000,900 | <p>I have just started with Python. When I execute a python script file on Windows, the output window appears but instantaneously goes away. I need it to stay there so I can analyze my output. How can I keep it open?</p>
| 108 | 2009-06-16T11:31:16Z | 1,000,968 | <p>You have a few options:</p>
<ol>
<li><p>Run the program from an already-open terminal. Open a command prompt and type:</p>
<pre><code>python myscript.py
</code></pre>
<p>For that to work you need the python executable in your path. Just check on <a href="http://superuser.com/questions/284342/what-are-path-and-oth... | 96 | 2009-06-16T11:43:55Z | [
"python",
"windows"
] |
How to keep a Python script output window open? | 1,000,900 | <p>I have just started with Python. When I execute a python script file on Windows, the output window appears but instantaneously goes away. I need it to stay there so I can analyze my output. How can I keep it open?</p>
| 108 | 2009-06-16T11:31:16Z | 1,031,891 | <p><code>cmd /k</code> is the typical way to open any console application (not only Python) with a console window that will remain after the application closes. The easiest way I can think to do that, is to press Win+R, type <code>cmd /k</code> and then drag&drop the script you want to the Run dialog.</p>
| 30 | 2009-06-23T11:03:09Z | [
"python",
"windows"
] |
How to keep a Python script output window open? | 1,000,900 | <p>I have just started with Python. When I execute a python script file on Windows, the output window appears but instantaneously goes away. I need it to stay there so I can analyze my output. How can I keep it open?</p>
| 108 | 2009-06-16T11:31:16Z | 4,477,506 | <p>I had a similar problem. With Notepad++ I used to use the command : <code>C:\Python27\python.exe "$(FULL_CURRENT_PATH)"</code> which closed the cmd window immediately after the code terminated.<br>
Now I am using <code>cmd /k c:\Python27\python.exe "$(FULL_CURRENT_PATH)"</code> which keeps the cmd window open.</p>
| 3 | 2010-12-18T09:36:23Z | [
"python",
"windows"
] |
How to keep a Python script output window open? | 1,000,900 | <p>I have just started with Python. When I execute a python script file on Windows, the output window appears but instantaneously goes away. I need it to stay there so I can analyze my output. How can I keep it open?</p>
| 108 | 2009-06-16T11:31:16Z | 9,232,527 | <p>you can combine the answers before: (for Notepad++ User)</p>
<p>press F5 to run current script and type in command: </p>
<pre><code>cmd /k python -i "$(FULL_CURRENT_PATH)"
</code></pre>
<p>in this way you stay in interactive mode after executing your Notepad++ python script and you are able to play around with yo... | 9 | 2012-02-10T18:01:31Z | [
"python",
"windows"
] |
How to keep a Python script output window open? | 1,000,900 | <p>I have just started with Python. When I execute a python script file on Windows, the output window appears but instantaneously goes away. I need it to stay there so I can analyze my output. How can I keep it open?</p>
| 108 | 2009-06-16T11:31:16Z | 17,298,882 | <ol>
<li>Go <a href="http://notepad-plus-plus.org/" rel="nofollow">here</a> and download and install Notepad++ </li>
<li>Go <a href="http://python.org/download" rel="nofollow">here</a> and download and install Python 2.7 not 3. </li>
<li>Start, Run Powershell. Enter the following. <code>[Environment]::SetEnvironmen... | 0 | 2013-06-25T13:38:01Z | [
"python",
"windows"
] |
How to keep a Python script output window open? | 1,000,900 | <p>I have just started with Python. When I execute a python script file on Windows, the output window appears but instantaneously goes away. I need it to stay there so I can analyze my output. How can I keep it open?</p>
| 108 | 2009-06-16T11:31:16Z | 19,199,825 | <p>To just keep the window open I agree with Anurag and this is what I did to keep my windows open for short little calculation type programs.</p>
<p><em>This would just show a cursor with no text:</em></p>
<pre><code>raw_input()
</code></pre>
<p><em>This next example would give you a clear message that the program... | 1 | 2013-10-05T16:11:47Z | [
"python",
"windows"
] |
How to keep a Python script output window open? | 1,000,900 | <p>I have just started with Python. When I execute a python script file on Windows, the output window appears but instantaneously goes away. I need it to stay there so I can analyze my output. How can I keep it open?</p>
| 108 | 2009-06-16T11:31:16Z | 22,352,721 | <p>To keep your window open in case of exception (yet, while printing the exception using <a href="http://stackoverflow.com/a/3702726/2436175">http://stackoverflow.com/a/3702726/2436175</a>)</p>
<pre><code>if __name__ == '__main__':
try:
## your code, typically one function call
except:
import ... | 11 | 2014-03-12T13:15:04Z | [
"python",
"windows"
] |
How to keep a Python script output window open? | 1,000,900 | <p>I have just started with Python. When I execute a python script file on Windows, the output window appears but instantaneously goes away. I need it to stay there so I can analyze my output. How can I keep it open?</p>
| 108 | 2009-06-16T11:31:16Z | 30,278,929 | <p>Create a Windows batch file with these 2 lines:</p>
<pre><code>python your-program.py
pause
</code></pre>
| 3 | 2015-05-16T17:53:09Z | [
"python",
"windows"
] |
How to keep a Python script output window open? | 1,000,900 | <p>I have just started with Python. When I execute a python script file on Windows, the output window appears but instantaneously goes away. I need it to stay there so I can analyze my output. How can I keep it open?</p>
| 108 | 2009-06-16T11:31:16Z | 30,281,797 | <p>Apart from <code>input</code> and <code>raw_input</code>, you could also use an infinite <code>while</code> loop, like this:
<code>while True: pass</code> (Python 2.5+/3) or <code>while 1: pass</code> (all versions of Python 2/3). This might use computing power, though.</p>
<p>You could also run the program from th... | 0 | 2015-05-16T23:34:47Z | [
"python",
"windows"
] |
How to keep a Python script output window open? | 1,000,900 | <p>I have just started with Python. When I execute a python script file on Windows, the output window appears but instantaneously goes away. I need it to stay there so I can analyze my output. How can I keep it open?</p>
| 108 | 2009-06-16T11:31:16Z | 32,083,868 | <p>In python 2 you can do it with: raw_input()</p>
<pre><code>>>print("Hello World!")
>>raw_input('Waiting a key...')
</code></pre>
<p>In python 3 you can do it with: input() </p>
<pre><code>>>print("Hello world!")
>>input('Waiting a key...')
</code></pre>
<p>Also, you can do it wit... | 3 | 2015-08-18T22:51:08Z | [
"python",
"windows"
] |
How to keep a Python script output window open? | 1,000,900 | <p>I have just started with Python. When I execute a python script file on Windows, the output window appears but instantaneously goes away. I need it to stay there so I can analyze my output. How can I keep it open?</p>
| 108 | 2009-06-16T11:31:16Z | 34,072,975 | <p>Using <a href="https://docs.python.org/3/library/atexit.html" rel="nofollow"><code>atexit</code></a>, you can pause the program right when it exits. If an error/exception is the reason for the exit, it will pause after printing the stacktrace.</p>
<pre><code>import atexit
# Python 2 should use `raw_input` instead ... | 1 | 2015-12-03T17:56:08Z | [
"python",
"windows"
] |
Creating dynamic images with WSGI, no files involved | 1,001,068 | <p>I would like to send dynamically created images to my users, such as charts, graphs etc. These images are "throw-away" images, they will be only sent to one user and then destroyed, hence the "no files involved".</p>
<p>I would like to send the image directly to the user, without saving it on the file system first.... | 3 | 2009-06-16T12:06:56Z | 1,001,085 | <p>YES. It is as simple as putting the url in the page.</p>
<pre><code><img src="url_to_my_application">
</code></pre>
<p>And your application just have to return it with the correct mimetype, just like on PHP or anything else. Simplest example possible:</p>
<pre><code>def application(environ, start_response):... | 2 | 2009-06-16T12:12:47Z | [
"python",
"image-processing",
"wsgi"
] |
Creating dynamic images with WSGI, no files involved | 1,001,068 | <p>I would like to send dynamically created images to my users, such as charts, graphs etc. These images are "throw-away" images, they will be only sent to one user and then destroyed, hence the "no files involved".</p>
<p>I would like to send the image directly to the user, without saving it on the file system first.... | 3 | 2009-06-16T12:06:56Z | 1,001,092 | <p>It is not related to WSGI or php or any other specific web technology. consider</p>
<pre><code><img src="someScript.php?param1=xyz">
</code></pre>
<p>in general for url <code>someScript.php?param1=xyz</code> server should return data of image type and it would work</p>
<p>Consider this example:</p>
<pre><c... | 8 | 2009-06-16T12:14:19Z | [
"python",
"image-processing",
"wsgi"
] |
Creating dynamic images with WSGI, no files involved | 1,001,068 | <p>I would like to send dynamically created images to my users, such as charts, graphs etc. These images are "throw-away" images, they will be only sent to one user and then destroyed, hence the "no files involved".</p>
<p>I would like to send the image directly to the user, without saving it on the file system first.... | 3 | 2009-06-16T12:06:56Z | 1,179,171 | <p>For a fancy example that uses this technique, please see
<a href="http://aaron.oirt.rutgers.edu/myapp/root/misc/bnfTest" rel="nofollow">the BNF railroad
diagram WHIFF mini-demo</a>. You can get the source from the WHIFF wsgi toolkit download.</p>
| 0 | 2009-07-24T17:54:08Z | [
"python",
"image-processing",
"wsgi"
] |
Creating dynamic images with WSGI, no files involved | 1,001,068 | <p>I would like to send dynamically created images to my users, such as charts, graphs etc. These images are "throw-away" images, they will be only sent to one user and then destroyed, hence the "no files involved".</p>
<p>I would like to send the image directly to the user, without saving it on the file system first.... | 3 | 2009-06-16T12:06:56Z | 1,209,478 | <p>You should consider using and paying attention to ETag headers. It's a CGI script, not WSGI, but the ideas are translatable: <a href="http://bitbucket.org/jcgregorio/sparklines/src/" rel="nofollow">sparklines source</a> -- it happens to always return the same image for the same parameters, so it practices extreme c... | 0 | 2009-07-30T21:26:25Z | [
"python",
"image-processing",
"wsgi"
] |
Python C API: how to get string representation of exception? | 1,001,216 | <p>If I do (e.g.)</p>
<pre><code> open("/snafu/fnord")
</code></pre>
<p>in Python (and the file does not exist), I get a traceback and the message</p>
<pre><code> IOError: [Errno 2] No such file or directory: '/snafu/fnord'
</code></pre>
<p>I would like to get the above string with Python's C API (i.e., a Python in... | 8 | 2009-06-16T12:36:53Z | 1,001,467 | <p>I think that Python exceptions are printed by running "str()" on the exception instance, which will return the formatted string you're interested in. You can get this from C by calling the "PyObject_Str()" method described here:</p>
<p><a href="https://docs.python.org/c-api/object.html" rel="nofollow">https://docs.... | 5 | 2009-06-16T13:25:13Z | [
"python",
"exception",
"python-c-api"
] |
How do I concatenate files in Python? | 1,001,538 | <p>I have multiple (between 40 and 50) MP3 files that I'd like to concatenate into one file. What's the best way to do this in Python?</p>
<p>Use <a href="http://docs.python.org/library/fileinput.html"><code>fileinput</code></a> module to loop through each line of each file and write it to an output file? Outsource ... | 32 | 2009-06-16T13:38:56Z | 1,001,587 | <p>Putting the bytes in those files together is easy... however I am not sure if that will cause a continuous play - I think it might if the files are using the same bitrate, but I'm not sure.</p>
<pre><code>from glob import iglob
import shutil
import os
PATH = r'C:\music'
destination = open('everything.mp3', 'wb')
... | 42 | 2009-06-16T13:44:51Z | [
"python",
"file",
"mp3"
] |
How do I concatenate files in Python? | 1,001,538 | <p>I have multiple (between 40 and 50) MP3 files that I'd like to concatenate into one file. What's the best way to do this in Python?</p>
<p>Use <a href="http://docs.python.org/library/fileinput.html"><code>fileinput</code></a> module to loop through each line of each file and write it to an output file? Outsource ... | 32 | 2009-06-16T13:38:56Z | 1,001,613 | <p>Hmm. I won't use "lines". Quick and dirty use </p>
<pre><code>outfile.write( file1.read() )
outfile.write( file2.read() )
</code></pre>
<p>;)</p>
| 5 | 2009-06-16T13:49:11Z | [
"python",
"file",
"mp3"
] |
How do I concatenate files in Python? | 1,001,538 | <p>I have multiple (between 40 and 50) MP3 files that I'd like to concatenate into one file. What's the best way to do this in Python?</p>
<p>Use <a href="http://docs.python.org/library/fileinput.html"><code>fileinput</code></a> module to loop through each line of each file and write it to an output file? Outsource ... | 32 | 2009-06-16T13:38:56Z | 1,518,697 | <p>Just to summarize (and steal from <a href="http://stackoverflow.com/questions/1001538/how-do-i-concatenate-files-in-python/1001587#1001587">nosklo's answer</a>), in order to concatenate two files you do:</p>
<pre><code>destination = open(outfile,'wb')
shutil.copyfileobj(open(file1,'rb'), destination)
shutil.copyfil... | 30 | 2009-10-05T07:40:10Z | [
"python",
"file",
"mp3"
] |
Python class to merge sorted files, how can this be improved? | 1,001,569 | <p><strong>Background:</strong></p>
<p>I'm cleaning large (cannot be held in memory) tab-delimited files. As I clean the input file, I build up a list in memory; when it gets to 1,000,000 entries (about 1GB in memory) I sort it (using the default key below) and write the list to a file. This class is for putting the ... | 7 | 2009-06-16T13:42:24Z | 1,001,625 | <p>Note that in python2.6, heapq has a new <a href="http://docs.python.org/library/heapq.html#heapq.merge">merge</a> function which will do this for you.</p>
<p>To handle the custom key function, you can just wrap the file iterator with something that decorates it so that it compares based on the key, and strip it out... | 14 | 2009-06-16T13:50:56Z | [
"python",
"merge",
"mergesort",
"large-file-support"
] |
Python class to merge sorted files, how can this be improved? | 1,001,569 | <p><strong>Background:</strong></p>
<p>I'm cleaning large (cannot be held in memory) tab-delimited files. As I clean the input file, I build up a list in memory; when it gets to 1,000,000 entries (about 1GB in memory) I sort it (using the default key below) and write the list to a file. This class is for putting the ... | 7 | 2009-06-16T13:42:24Z | 1,004,558 | <p><< This "answer" is a comment on the original questioner's resultant code >></p>
<p>Suggestion: using eval() is ummmm and what you are doing restricts the caller to using lambda -- key extraction may require more than a one-liner, and in any case don't you need the same function for the preliminary sort step?... | 2 | 2009-06-17T00:33:01Z | [
"python",
"merge",
"mergesort",
"large-file-support"
] |
Why are there extra blank lines in my python program output? | 1,001,601 | <p>I'm not particularly experienced with python, so may be doing something silly below. I have the following program:</p>
<pre><code>import os
import re
import linecache
LINENUMBER = 2
angles_file = open("d:/UserData/Robin Wilson/AlteredData/ncaveo/16-June/scan1_high/000/angles.txt")
lines = angles_file.readlines()... | 2 | 2009-06-16T13:47:10Z | 1,001,606 | <p>Change this:</p>
<pre><code>output_file.write("0\t" + str(DN) + "\t" + Zenith + "\n")
</code></pre>
<p>to this:</p>
<pre><code>output_file.write("0\t" + str(DN) + "\t" + Zenith)
</code></pre>
<p>The <code>Zenith</code> string already contains the trailing <code>\n</code> from the original file when you read it i... | 8 | 2009-06-16T13:48:18Z | [
"python"
] |
Why are there extra blank lines in my python program output? | 1,001,601 | <p>I'm not particularly experienced with python, so may be doing something silly below. I have the following program:</p>
<pre><code>import os
import re
import linecache
LINENUMBER = 2
angles_file = open("d:/UserData/Robin Wilson/AlteredData/ncaveo/16-June/scan1_high/000/angles.txt")
lines = angles_file.readlines()... | 2 | 2009-06-16T13:47:10Z | 1,001,655 | <p>Alternative solution (handy if you are processing lines from file) is to strip the whitespace: </p>
<pre><code>Zenith = Zenith.strip();
</code></pre>
| 2 | 2009-06-16T13:57:05Z | [
"python"
] |
Why are there extra blank lines in my python program output? | 1,001,601 | <p>I'm not particularly experienced with python, so may be doing something silly below. I have the following program:</p>
<pre><code>import os
import re
import linecache
LINENUMBER = 2
angles_file = open("d:/UserData/Robin Wilson/AlteredData/ncaveo/16-June/scan1_high/000/angles.txt")
lines = angles_file.readlines()... | 2 | 2009-06-16T13:47:10Z | 1,001,658 | <p>For a GENERAL solution, remove the trailing newline from your INPUT:</p>
<pre><code>splitted_line = line.rstrip("\n").split(";")
</code></pre>
<p>Removing the extraneous newline from your output "works" in this case but it's a kludge.</p>
<p>ALSO: (1) it's not a good idea to open your output file in the middle of... | 14 | 2009-06-16T13:58:32Z | [
"python"
] |
Why are there extra blank lines in my python program output? | 1,001,601 | <p>I'm not particularly experienced with python, so may be doing something silly below. I have the following program:</p>
<pre><code>import os
import re
import linecache
LINENUMBER = 2
angles_file = open("d:/UserData/Robin Wilson/AlteredData/ncaveo/16-June/scan1_high/000/angles.txt")
lines = angles_file.readlines()... | 2 | 2009-06-16T13:47:10Z | 1,001,672 | <p>If you want to make sure there's no whitespace on any of your tokens (not just the first and last), try this:</p>
<pre><code>splitted_line = map (str.strip, line.split (';'))
</code></pre>
| 1 | 2009-06-16T14:01:16Z | [
"python"
] |
Why are there extra blank lines in my python program output? | 1,001,601 | <p>I'm not particularly experienced with python, so may be doing something silly below. I have the following program:</p>
<pre><code>import os
import re
import linecache
LINENUMBER = 2
angles_file = open("d:/UserData/Robin Wilson/AlteredData/ncaveo/16-June/scan1_high/000/angles.txt")
lines = angles_file.readlines()... | 2 | 2009-06-16T13:47:10Z | 1,001,680 | <p><strong>EDIT:</strong> See comments for details, but there's definitely a better way. <code>[:-1]</code> isn't the best choice, no matter how cool it looks. Use <code>line.rstrip('\n')</code> instead.</p>
<p>The problem is that, unlike <code>file_text.split('\n')</code>, <code>file.readlines()</code> does not remov... | 2 | 2009-06-16T14:02:46Z | [
"python"
] |
Array division- translating from MATLAB to Python | 1,001,634 | <p>I have this line of code in MATLAB, written by someone else:</p>
<pre><code>c=a.'/b
</code></pre>
<p>I need to translate it into Python. a, b, and c are all arrays. The dimensions that I am currently using to test the code are:</p>
<p>a: 18x1,<br />
b: 25x18, ... | 6 | 2009-06-16T13:54:13Z | 1,001,716 | <p>In Matlab, <code>A.'</code> means transposing the A matrix. So mathematically, what is achieved in the code is A<sup>T</sup>/B.</p>
<p><hr /></p>
<p><strong>How to go about implementing matrix division in Python (or any language)</strong> <em>(Note: Let's go over a simple division of the form <code>A/B</code>; for... | 5 | 2009-06-16T14:07:05Z | [
"python",
"matlab",
"numpy",
"linear-algebra"
] |
Array division- translating from MATLAB to Python | 1,001,634 | <p>I have this line of code in MATLAB, written by someone else:</p>
<pre><code>c=a.'/b
</code></pre>
<p>I need to translate it into Python. a, b, and c are all arrays. The dimensions that I am currently using to test the code are:</p>
<p>a: 18x1,<br />
b: 25x18, ... | 6 | 2009-06-16T13:54:13Z | 1,001,727 | <p>The symbol "/" is the matrix right division operator in MATLAB, which calls the <a href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/mldivide.html">MRDIVIDE</a> function. From the documentation, matrix right division is related to matrix left division in the following way:</p>
<pre><code>B/A = (A'\B')... | 6 | 2009-06-16T14:07:57Z | [
"python",
"matlab",
"numpy",
"linear-algebra"
] |
Array division- translating from MATLAB to Python | 1,001,634 | <p>I have this line of code in MATLAB, written by someone else:</p>
<pre><code>c=a.'/b
</code></pre>
<p>I need to translate it into Python. a, b, and c are all arrays. The dimensions that I am currently using to test the code are:</p>
<p>a: 18x1,<br />
b: 25x18, ... | 6 | 2009-06-16T13:54:13Z | 1,001,888 | <p>[edited] As Suvesh pointed out, i was completely wrong before. however, numpy can still easily do the procedure he gives in his post:</p>
<pre><code>A = numpy.matrix(numpy.random.random((18, 1))) # as noted by others, your dimensions are off
B = numpy.matrix(numpy.random.random((25, 18)))
C = A.T * B.T * (B * B.T)... | 2 | 2009-06-16T14:34:35Z | [
"python",
"matlab",
"numpy",
"linear-algebra"
] |
Array division- translating from MATLAB to Python | 1,001,634 | <p>I have this line of code in MATLAB, written by someone else:</p>
<pre><code>c=a.'/b
</code></pre>
<p>I need to translate it into Python. a, b, and c are all arrays. The dimensions that I am currently using to test the code are:</p>
<p>a: 18x1,<br />
b: 25x18, ... | 6 | 2009-06-16T13:54:13Z | 1,008,869 | <p>The line</p>
<pre><code>c = a.' / b
</code></pre>
<p>computes the solution of the equation <i>c b = a<sup>T</sup></i> for <i>c</i>. Numpy does not have an operator that does this directly. Instead you should solve <i>b<sup>T</sup> c<sup>T</sup> = a</i> for <i>c<sup>T</sup></i> and transpose the result:</p>
<pre... | 7 | 2009-06-17T18:41:38Z | [
"python",
"matlab",
"numpy",
"linear-algebra"
] |
How To Reversibly Store Password With Python On Linux? | 1,001,744 | <p>First, my question is not about password hashing, but password encryption. I'm building a desktop application that needs to authentificate the user to a third party service. To speed up the login process, I want to give the user the option to save his credentials. Since I need the password to authentificate him to t... | 7 | 2009-06-16T14:09:44Z | 1,001,775 | <p>Password Safe is designed by Bruce Schneier and open source. It's for Windows, but you should be able to see what they are doing and possibly reuse it.</p>
<p><a href="http://www.schneier.com/passsafe.html" rel="nofollow">http://www.schneier.com/passsafe.html</a></p>
<p><a href="http://passwordsafe.sourceforge.ne... | 0 | 2009-06-16T14:15:39Z | [
"python",
"linux",
"encryption",
"passwords"
] |
How To Reversibly Store Password With Python On Linux? | 1,001,744 | <p>First, my question is not about password hashing, but password encryption. I'm building a desktop application that needs to authentificate the user to a third party service. To speed up the login process, I want to give the user the option to save his credentials. Since I need the password to authentificate him to t... | 7 | 2009-06-16T14:09:44Z | 1,001,815 | <p>Try using <a href="http://www.kernel.org/pub/linux/libs/pam/">PAM</a>. You can make a module that automatically un-encrypts the key when the user logs in. This is internally how GNOME-Keyring works (if possible). You can even write PAM modules in Python with <a href="http://ace-host.stuart.id.au/russell/files/pam%5F... | 5 | 2009-06-16T14:20:28Z | [
"python",
"linux",
"encryption",
"passwords"
] |
How To Reversibly Store Password With Python On Linux? | 1,001,744 | <p>First, my question is not about password hashing, but password encryption. I'm building a desktop application that needs to authentificate the user to a third party service. To speed up the login process, I want to give the user the option to save his credentials. Since I need the password to authentificate him to t... | 7 | 2009-06-16T14:09:44Z | 1,001,833 | <p>Encrypting the passwords doesn't really buy you a whole lot more protection than storing in plaintext. Anyone capable of accessing the database probably also has full access to your webserver machines.</p>
<p>However, if the loss of security is acceptable, and you really need this, I'd generate a new keyfile (from... | 5 | 2009-06-16T14:24:46Z | [
"python",
"linux",
"encryption",
"passwords"
] |
How to put variables on the stack/context in Python | 1,001,784 | <p>In essence, I want to put a variable on the stack, that will be reachable by all calls below that part on the stack until the block exits. In Java I would solve this using a static thread local with support methods, that then could be accessed from methods.</p>
<p>Typical example: you get a request, and open a data... | 2 | 2009-06-16T14:16:30Z | 1,001,849 | <p>You could use a global variable wrapped in a getter function:</p>
<pre><code>def getConnection():
global connection
if connection:
return connection
connection=createConnection()
return connection
</code></pre>
| 0 | 2009-06-16T14:27:36Z | [
"python",
"thread-local",
"contextmanager"
] |
How to put variables on the stack/context in Python | 1,001,784 | <p>In essence, I want to put a variable on the stack, that will be reachable by all calls below that part on the stack until the block exits. In Java I would solve this using a static thread local with support methods, that then could be accessed from methods.</p>
<p>Typical example: you get a request, and open a data... | 2 | 2009-06-16T14:16:30Z | 1,001,896 | <p>this question seems to be two question</p>
<ul>
<li>a) sharing db connection</li>
<li>b) caching/Memoizing</li>
</ul>
<p>b) you have answered yourselves</p>
<p>a) I don't seem to understand why you need to put it on stack?
you can do one of these</p>
<ol>
<li>you can use a class and connection
could be attri... | 2 | 2009-06-16T14:35:58Z | [
"python",
"thread-local",
"contextmanager"
] |
How to put variables on the stack/context in Python | 1,001,784 | <p>In essence, I want to put a variable on the stack, that will be reachable by all calls below that part on the stack until the block exits. In Java I would solve this using a static thread local with support methods, that then could be accessed from methods.</p>
<p>Typical example: you get a request, and open a data... | 2 | 2009-06-16T14:16:30Z | 1,001,927 | <p><strong>"you get a request, and open a database connection.... you close the database connection."</strong></p>
<p>This is what objects are for. Create the connection object, pass it to other objects, and then close it when you're done. Globals are not appropriate. Simply pass the value around as a parameter to ... | 0 | 2009-06-16T14:40:44Z | [
"python",
"thread-local",
"contextmanager"
] |
How to put variables on the stack/context in Python | 1,001,784 | <p>In essence, I want to put a variable on the stack, that will be reachable by all calls below that part on the stack until the block exits. In Java I would solve this using a static thread local with support methods, that then could be accessed from methods.</p>
<p>Typical example: you get a request, and open a data... | 2 | 2009-06-16T14:16:30Z | 1,003,253 | <p>I went ahead and made something that might just do what you want. It can be used as both a decorator and a context manager:</p>
<pre><code>from __future__ import with_statement
try:
import cPickle as pickle
except ImportError:
import pickle
class cached(object):
"""Decorator/context manager for cachin... | 5 | 2009-06-16T18:43:15Z | [
"python",
"thread-local",
"contextmanager"
] |
PYTHONPATH ignored | 1,001,851 | <p>Environment: debian 4.0</p>
<p>Python 2.4</p>
<p>My 'project' is installed in:</p>
<blockquote>
<p>/usr/lib/python2.4/site-packages/project. </p>
</blockquote>
<p>But I want to use my working copy instead of the installed one which is located in:</p>
<blockquote>
<p>/home/me/dev/project/src</p>
</blockquote... | 9 | 2009-06-16T14:27:44Z | 1,001,942 | <p>I think you set up PYTHONPATH to /home/me/build/project/src since /home/me/dev/project/src does not appear in sys.path, but /home/me/build/project/src does.</p>
| 0 | 2009-06-16T14:43:15Z | [
"python",
"path",
"debian"
] |
PYTHONPATH ignored | 1,001,851 | <p>Environment: debian 4.0</p>
<p>Python 2.4</p>
<p>My 'project' is installed in:</p>
<blockquote>
<p>/usr/lib/python2.4/site-packages/project. </p>
</blockquote>
<p>But I want to use my working copy instead of the installed one which is located in:</p>
<blockquote>
<p>/home/me/dev/project/src</p>
</blockquote... | 9 | 2009-06-16T14:27:44Z | 1,002,007 | <p>I see '/usr/lib/python2.4/site-packages' in your path prior to '/home/me/dev/project/src', does that matter? What happens when you switch the two?</p>
<p>From the docs: </p>
<blockquote>
<p>When PYTHONPATH is not set, or when the file is not found there, the search continues in an installation-dependent defaul... | 2 | 2009-06-16T14:53:05Z | [
"python",
"path",
"debian"
] |
PYTHONPATH ignored | 1,001,851 | <p>Environment: debian 4.0</p>
<p>Python 2.4</p>
<p>My 'project' is installed in:</p>
<blockquote>
<p>/usr/lib/python2.4/site-packages/project. </p>
</blockquote>
<p>But I want to use my working copy instead of the installed one which is located in:</p>
<blockquote>
<p>/home/me/dev/project/src</p>
</blockquote... | 9 | 2009-06-16T14:27:44Z | 1,002,042 | <p>I don't believe you have any control over where the PYTHONPATH gets inserted into the actual path list. But that's not the only way to modify the path - you can update sys.path yourself, before you try to import the project.</p>
<p><b>Edit:</b> In your specific case, you can modify the path with</p>
<pre><code>im... | 4 | 2009-06-16T14:58:43Z | [
"python",
"path",
"debian"
] |
PYTHONPATH ignored | 1,001,851 | <p>Environment: debian 4.0</p>
<p>Python 2.4</p>
<p>My 'project' is installed in:</p>
<blockquote>
<p>/usr/lib/python2.4/site-packages/project. </p>
</blockquote>
<p>But I want to use my working copy instead of the installed one which is located in:</p>
<blockquote>
<p>/home/me/dev/project/src</p>
</blockquote... | 9 | 2009-06-16T14:27:44Z | 1,002,096 | <p>According to python documentation, <strong>this is expected behavior</strong>: <a href="https://docs.python.org/2.4/lib/module-sys.html" rel="nofollow">https://docs.python.org/2.4/lib/module-sys.html</a>:</p>
<blockquote>
<p>Notice that the script directory is
inserted <strong>before</strong> the entries insert... | 6 | 2009-06-16T15:06:09Z | [
"python",
"path",
"debian"
] |
PYTHONPATH ignored | 1,001,851 | <p>Environment: debian 4.0</p>
<p>Python 2.4</p>
<p>My 'project' is installed in:</p>
<blockquote>
<p>/usr/lib/python2.4/site-packages/project. </p>
</blockquote>
<p>But I want to use my working copy instead of the installed one which is located in:</p>
<blockquote>
<p>/home/me/dev/project/src</p>
</blockquote... | 9 | 2009-06-16T14:27:44Z | 1,002,151 | <p>It sounds like the <code>src</code> directory doesn't have an <code>__init__.py</code> file. It's not a proper package.</p>
| 0 | 2009-06-16T15:12:44Z | [
"python",
"path",
"debian"
] |
PYTHONPATH ignored | 1,001,851 | <p>Environment: debian 4.0</p>
<p>Python 2.4</p>
<p>My 'project' is installed in:</p>
<blockquote>
<p>/usr/lib/python2.4/site-packages/project. </p>
</blockquote>
<p>But I want to use my working copy instead of the installed one which is located in:</p>
<blockquote>
<p>/home/me/dev/project/src</p>
</blockquote... | 9 | 2009-06-16T14:27:44Z | 1,002,305 | <p>Not a direct answer to you question, but you could also use a <a href="http://pypi.python.org/pypi/virtualenv" rel="nofollow" title="virtualenv">virtualenv</a> to create a development environment. In that virtualenv you can then install your product in /home/me/dev/project/src as a development package: "python setup... | 1 | 2009-06-16T15:39:10Z | [
"python",
"path",
"debian"
] |
PYTHONPATH ignored | 1,001,851 | <p>Environment: debian 4.0</p>
<p>Python 2.4</p>
<p>My 'project' is installed in:</p>
<blockquote>
<p>/usr/lib/python2.4/site-packages/project. </p>
</blockquote>
<p>But I want to use my working copy instead of the installed one which is located in:</p>
<blockquote>
<p>/home/me/dev/project/src</p>
</blockquote... | 9 | 2009-06-16T14:27:44Z | 1,002,608 | <p>I found the problem (I've missed early on when somebody pointed me to <a href="http://stackoverflow.com/questions/897792/pythons-sys-path-value">http://stackoverflow.com/questions/897792/pythons-sys-path-value</a>).</p>
<p>It seems that easy_install creates a pth file /usr/lib/python2.4/site-packages/easy-install.p... | 5 | 2009-06-16T16:31:17Z | [
"python",
"path",
"debian"
] |
Showing progress of python's XML parser when loading a huge file | 1,001,871 | <p>Im using Python's built in XML parser to load a 1.5 gig XML file and it takes all day.</p>
<pre><code>from xml.dom import minidom
xmldoc = minidom.parse('events.xml')
</code></pre>
<p>I need to know how to get inside that and measure its progress so I can show a progress bar.
any ideas?</p>
<p>minidom has anothe... | 2 | 2009-06-16T14:32:25Z | 1,001,895 | <p>Merging the tree at the end would be pretty easy. You could just create a new DOM, and basically append the individual trees to it one by one. This would give you pretty finely tuned control over the progress of the parsing too. You could even parallelize it if you wanted by spawning different processes to parse ... | 2 | 2009-06-16T14:35:52Z | [
"python",
"xml",
"pyqt"
] |
Showing progress of python's XML parser when loading a huge file | 1,001,871 | <p>Im using Python's built in XML parser to load a 1.5 gig XML file and it takes all day.</p>
<pre><code>from xml.dom import minidom
xmldoc = minidom.parse('events.xml')
</code></pre>
<p>I need to know how to get inside that and measure its progress so I can show a progress bar.
any ideas?</p>
<p>minidom has anothe... | 2 | 2009-06-16T14:32:25Z | 1,002,037 | <p>Did you consider to use other means of parsing XML? Building a tree of such big XML files will always be slow and memory intensive. If you don't need the whole tree in memory, stream based parsing will be <em>much</em> faster. It can be a little daunting if you're used to tree based XML manipulation, but it will pay... | 5 | 2009-06-16T14:57:35Z | [
"python",
"xml",
"pyqt"
] |
Showing progress of python's XML parser when loading a huge file | 1,001,871 | <p>Im using Python's built in XML parser to load a 1.5 gig XML file and it takes all day.</p>
<pre><code>from xml.dom import minidom
xmldoc = minidom.parse('events.xml')
</code></pre>
<p>I need to know how to get inside that and measure its progress so I can show a progress bar.
any ideas?</p>
<p>minidom has anothe... | 2 | 2009-06-16T14:32:25Z | 1,002,122 | <p>I have something very similar for PyGTK, not PyQt, using the pulldom api. It gets called a little bit at a time using Gtk idle events (so the GUI doesn't lock up) and Python generators (to save the parsing state).</p>
<pre><code>def idle_handler (fn):
fh = open (fn) # file handle
doc = xml.dom.pulldom.parse (... | 3 | 2009-06-16T15:09:39Z | [
"python",
"xml",
"pyqt"
] |
Showing progress of python's XML parser when loading a huge file | 1,001,871 | <p>Im using Python's built in XML parser to load a 1.5 gig XML file and it takes all day.</p>
<pre><code>from xml.dom import minidom
xmldoc = minidom.parse('events.xml')
</code></pre>
<p>I need to know how to get inside that and measure its progress so I can show a progress bar.
any ideas?</p>
<p>minidom has anothe... | 2 | 2009-06-16T14:32:25Z | 1,002,132 | <p>you usecase requires that you use sax parser instead of dom, dom loads everything in memory , sax instead will do line by line parsing and you write handlers for events as you need
so could be effective and you would be able to write progress indicator also</p>
<p>I also recommend trying expat parser sometime it is... | 5 | 2009-06-16T15:10:21Z | [
"python",
"xml",
"pyqt"
] |
What is the best approach for creating an agent framework in python for flexible script distribution and data collection | 1,002,002 | <p>What I am trying to do: I have hundreds of servers with very large log files spread out at dozens of different clients. I am creating nice python scripts to parse the logs in different ways and would like to aggregate the data I am collecting from all of the different servers. I would also like to keep the changi... | 0 | 2009-06-16T14:52:35Z | 1,002,028 | <p>Parallel Python provides some functionality for distributed computing and communication:</p>
<p><a href="http://www.parallelpython.com/" rel="nofollow">http://www.parallelpython.com/</a></p>
| 1 | 2009-06-16T14:56:13Z | [
"python"
] |
What is the best approach for creating an agent framework in python for flexible script distribution and data collection | 1,002,002 | <p>What I am trying to do: I have hundreds of servers with very large log files spread out at dozens of different clients. I am creating nice python scripts to parse the logs in different ways and would like to aggregate the data I am collecting from all of the different servers. I would also like to keep the changi... | 0 | 2009-06-16T14:52:35Z | 1,002,095 | <p>Take a look at <a href="https://fedorahosted.org/func/" rel="nofollow">Func</a>. It's a framework for rpc-style communication with a large number of machines using python. As a bonus, it comes with built-in TLS, so you don't need to layer on top of ssh tunneling for security.</p>
| 1 | 2009-06-16T15:06:08Z | [
"python"
] |
What is the best approach for creating an agent framework in python for flexible script distribution and data collection | 1,002,002 | <p>What I am trying to do: I have hundreds of servers with very large log files spread out at dozens of different clients. I am creating nice python scripts to parse the logs in different ways and would like to aggregate the data I am collecting from all of the different servers. I would also like to keep the changi... | 0 | 2009-06-16T14:52:35Z | 1,002,186 | <p>Looks like <a href="http://hadoop.apache.org/core/" rel="nofollow">hadoop</a> is your answer
<a href="http://www.michael-noll.com/wiki/Writing_An_Hadoop_MapReduce_Program_In_Python" rel="nofollow">http://www.michael-noll.com/wiki/Writing_An_Hadoop_MapReduce_Program_In_Python</a></p>
<p>or Pyro is also good but I am... | 3 | 2009-06-16T15:19:19Z | [
"python"
] |
Handle sys.exit() in cherrypy service | 1,002,072 | <p>When you start/stop a python cherrypy service (compiled with py2exe), this works fine When I get a <code>sys.exit()</code> call (from my error handler), cherrypy quits, but the service remains hanging.</p>
<p>Code:</p>
<pre><code>import cherrypy
import win32serviceutil
import win32service
import sys
SERVICE = No... | 2 | 2009-06-16T15:02:36Z | 1,081,081 | <p>I'm not entirely sure where the <code>sys.exit</code> call is coming from or what your preferred behavior is. When <a href="http://docs.python.org/library/sys.html#sys.exit" rel="nofollow"><code>sys.exit</code></a> is called, however, it raises a <a href="http://docs.python.org/library/exceptions.html#exceptions.Sys... | 2 | 2009-07-03T22:55:49Z | [
"python",
"windows-services",
"cherrypy"
] |
Handle sys.exit() in cherrypy service | 1,002,072 | <p>When you start/stop a python cherrypy service (compiled with py2exe), this works fine When I get a <code>sys.exit()</code> call (from my error handler), cherrypy quits, but the service remains hanging.</p>
<p>Code:</p>
<pre><code>import cherrypy
import win32serviceutil
import win32service
import sys
SERVICE = No... | 2 | 2009-06-16T15:02:36Z | 8,210,435 | <p><a href="http://stackoverflow.com/questions/2125175/stopping-a-cherrypy-server-over-http/2130438#2130438">stopping a cherrypy server over http</a> recommends <code>cherrypy.engine.exit()</code> instead of <code>sys.exit()</code>.</p>
| 1 | 2011-11-21T10:36:01Z | [
"python",
"windows-services",
"cherrypy"
] |
Can bin() be overloaded like oct() and hex() in Python 2.6? | 1,002,116 | <p>In Python 2.6 (and earlier) the <code>hex()</code> and <code>oct()</code> built-in functions can be overloaded in a class by defining <code>__hex__</code> and <code>__oct__</code> special functions. However there is not a <code>__bin__</code> special function for overloading the behaviour of Python 2.6's new <code>b... | 12 | 2009-06-16T15:08:55Z | 1,002,214 | <p>The bin function receives it's value from the object's <code>__index__</code> function. So for an object, you can define the value converted to binary, but you can't define the format of the string.</p>
| 1 | 2009-06-16T15:23:38Z | [
"python",
"binary",
"overloading",
"python-2.6"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.