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 |
|---|---|---|---|---|---|---|---|---|---|
How to exit from Python without traceback? | 1,187,970 | <p>I would like to know how to I exit from Python without having an traceback dump on the output. </p>
<p>I still want want to be able to return an error code but I do not want to display the traceback log.</p>
<p>I want to be able to exit using <code>exit(number)</code> without trace but in case of an Exception (not... | 156 | 2009-07-27T12:44:15Z | 1,190,864 | <p>Perhaps you're trying to catch all exceptions and this is catching the <code>SystemExit</code> exception raised by <code>sys.exit()</code>?</p>
<pre><code>import sys
try:
sys.exit(1) # Or something that calls sys.exit()
except SystemExit as e:
sys.exit(e)
except:
# Cleanup and reraise. This will print ... | 49 | 2009-07-27T21:55:27Z | [
"python",
"exit",
"traceback"
] |
How to exit from Python without traceback? | 1,187,970 | <p>I would like to know how to I exit from Python without having an traceback dump on the output. </p>
<p>I still want want to be able to return an error code but I do not want to display the traceback log.</p>
<p>I want to be able to exit using <code>exit(number)</code> without trace but in case of an Exception (not... | 156 | 2009-07-27T12:44:15Z | 24,333,416 | <pre><code># Pygame Example
import pygame, sys
from pygame.locals import *
pygame.init()
DISPLAYSURF = pygame.display.set_mode((400, 300))
pygame.display.set_caption('IBM Emulator')
BLACK = (0, 0, 0)
GREEN = (0, 255, 0)
fontObj = pygame.font.Font('freesansbold.ttf', 32)
textSurfaceObj = fontObj.render('... | -5 | 2014-06-20T18:21:48Z | [
"python",
"exit",
"traceback"
] |
How to exit from Python without traceback? | 1,187,970 | <p>I would like to know how to I exit from Python without having an traceback dump on the output. </p>
<p>I still want want to be able to return an error code but I do not want to display the traceback log.</p>
<p>I want to be able to exit using <code>exit(number)</code> without trace but in case of an Exception (not... | 156 | 2009-07-27T12:44:15Z | 26,246,313 | <p>I would do it this way:</p>
<pre><code>import sys
def do_my_stuff():
pass
if __name__ == "__main__":
try:
do_my_stuff()
except SystemExit, e:
print(e)
</code></pre>
| 1 | 2014-10-07T22:27:04Z | [
"python",
"exit",
"traceback"
] |
How to exit from Python without traceback? | 1,187,970 | <p>I would like to know how to I exit from Python without having an traceback dump on the output. </p>
<p>I still want want to be able to return an error code but I do not want to display the traceback log.</p>
<p>I want to be able to exit using <code>exit(number)</code> without trace but in case of an Exception (not... | 156 | 2009-07-27T12:44:15Z | 39,143,539 | <p>It's much better practise to avoid using sys.exit() and instead raise/handle exceptions to allow the program to finish cleanly. If you want to turn off traceback, simply use:</p>
<pre><code>sys.trackbacklimit=0
</code></pre>
<p>You can set this at the top of your script to squash all traceback output, but I prefe... | 2 | 2016-08-25T11:03:05Z | [
"python",
"exit",
"traceback"
] |
Reusing a Django app within a single project | 1,188,052 | <p>In trying to save as much time as possible in my development and make as many of my apps as reusable as possible, I have run into a bit of a roadblock. In one site I have a blog app and a news app, which are largely identical, and obviously it would be easier if I could make a single app and extend it where necessar... | 3 | 2009-07-27T13:02:10Z | 1,188,120 | <p>In this case you could create the common piece of code as a Python module instead of a whole new application.</p>
<p>Then for each instance you would like to use it, create an app and import the bits from that module.</p>
| 2 | 2009-07-27T13:18:51Z | [
"python",
"django"
] |
Reusing a Django app within a single project | 1,188,052 | <p>In trying to save as much time as possible in my development and make as many of my apps as reusable as possible, I have run into a bit of a roadblock. In one site I have a blog app and a news app, which are largely identical, and obviously it would be easier if I could make a single app and extend it where necessar... | 3 | 2009-07-27T13:02:10Z | 1,188,246 | <p>What's the actual difference between blogs and news? Perhaps that difference ought to be part of the blog/news app and you include it just once.</p>
<p>If you have a blog page with blog entries and a news page with news entries and the only difference is a field in the database (kind_of_item = "blog" vs. kind_of_i... | 3 | 2009-07-27T13:47:35Z | [
"python",
"django"
] |
Reusing a Django app within a single project | 1,188,052 | <p>In trying to save as much time as possible in my development and make as many of my apps as reusable as possible, I have run into a bit of a roadblock. In one site I have a blog app and a news app, which are largely identical, and obviously it would be easier if I could make a single app and extend it where necessar... | 3 | 2009-07-27T13:02:10Z | 1,188,819 | <p>I'm not 100% sure I understand your question, so I'm going to list my understanding, and let me know if it is different from yours.</p>
<ol>
<li>You want to have a "news" and a "blog" section of your website with identical functionality.</li>
<li>You want to have "news" and "blog" entries stored separately in the d... | 1 | 2009-07-27T15:23:19Z | [
"python",
"django"
] |
Bizzare eclipse-pydev console behavior | 1,188,103 | <p>Stumbled upon some seemingly random character mangling in eclipse-pydev console:
specific characters are read from stdout as '\xd0?' (first byte correct, second "?")</p>
<p>Is there some solution to this?</p>
<p>(PyDEV 1.4.6, Python 2.6, console encoding - inherited UTF-8, Eclipse 3.5, WinXP with UK locale)</p>
<... | 1 | 2009-07-27T13:15:32Z | 1,188,516 | <p>I'm not too sure about input encoding, but I've found that with output encoding to tty streams, an explicit encoding step was needed for Python 2.x but not for Python 3.x.</p>
<p>So for input you may need an explicit decode step using e.g. <code>l.decode(sys.stdin.encoding)</code>.</p>
<p>Does it work OK in a vani... | 0 | 2009-07-27T14:31:48Z | [
"python",
"utf-8",
"pydev"
] |
Bizzare eclipse-pydev console behavior | 1,188,103 | <p>Stumbled upon some seemingly random character mangling in eclipse-pydev console:
specific characters are read from stdout as '\xd0?' (first byte correct, second "?")</p>
<p>Is there some solution to this?</p>
<p>(PyDEV 1.4.6, Python 2.6, console encoding - inherited UTF-8, Eclipse 3.5, WinXP with UK locale)</p>
<... | 1 | 2009-07-27T13:15:32Z | 1,189,434 | <p>Well, I don't know how to fix it, but I have deduced the pattern in what goes wrong.</p>
<p>The bytes that get replaced with "?" are precisely those bytes that are not defined in <a href="http://en.wikipedia.org/wiki/Windows-1252" rel="nofollow">windows-1252</a> - that is, bytes 0x81, 0x8d, 0x8f, 0x90, and 0x9d.</p... | 2 | 2009-07-27T17:15:26Z | [
"python",
"utf-8",
"pydev"
] |
How to specify which eth interface Django test server should listen on? | 1,188,205 | <p>As the title says, in a multiple ethernet interfaces with multiple IP environment, the default Django test server is not attached to the network that I can access from my PC. Is there any way to specify the interface which Django test server should use?</p>
<p>-- Added --</p>
<p>The network configuration is here.
... | 11 | 2009-07-27T13:38:43Z | 1,188,299 | <p>No. It's not how it works. The interfase has an IP address, you have a network with the test server and your PC. You should connect to that IP (possibly with an alternative port that you specified), and that's all. If you only have these two devices in the network, it is most likely that both of them should have sta... | 0 | 2009-07-27T13:58:00Z | [
"python",
"django",
"networking",
"ethernet"
] |
How to specify which eth interface Django test server should listen on? | 1,188,205 | <p>As the title says, in a multiple ethernet interfaces with multiple IP environment, the default Django test server is not attached to the network that I can access from my PC. Is there any way to specify the interface which Django test server should use?</p>
<p>-- Added --</p>
<p>The network configuration is here.
... | 11 | 2009-07-27T13:38:43Z | 1,188,333 | <p>Yes, if the IP of your interface is for example 192.168.1.2 and you want to run on port 8080, start the development server like this:</p>
<pre><code>./manage.py runserver 192.168.1.2:8080
</code></pre>
| 2 | 2009-07-27T14:05:11Z | [
"python",
"django",
"networking",
"ethernet"
] |
How to specify which eth interface Django test server should listen on? | 1,188,205 | <p>As the title says, in a multiple ethernet interfaces with multiple IP environment, the default Django test server is not attached to the network that I can access from my PC. Is there any way to specify the interface which Django test server should use?</p>
<p>-- Added --</p>
<p>The network configuration is here.
... | 11 | 2009-07-27T13:38:43Z | 1,188,359 | <p>I think the OP is referring to having multiple interfaces configured on the test machine.</p>
<p>You can specify the IP address that Django will bind to as follows:</p>
<pre><code># python manage.py runserver 0.0.0.0:8000
</code></pre>
<p>This would bind Django to all interfaces on port 8000. You can pass any act... | 27 | 2009-07-27T14:09:34Z | [
"python",
"django",
"networking",
"ethernet"
] |
Writing in file's actual position in Python | 1,188,214 | <p>I want to read a line in a file and insert the new line ("\n") character in the n position on a line, so that a 9-character line, for instance, gets converted into three 3-character lines, like this:</p>
<pre><code>"123456789" (before)
"123\n456\n789" (after)
</code></pre>
<p>I've tried with this:</p>
<pre><code>... | 2 | 2009-07-27T13:40:53Z | 1,188,221 | <p>I don't think there is any way to do that in the way you are trying to: you would have to read in to the end of the file from the position you want to insert, then write your new character at the position you wish it to be, then write the original data back after it. This is the same way things would work in C or a... | 7 | 2009-07-27T13:43:45Z | [
"python",
"file"
] |
Writing in file's actual position in Python | 1,188,214 | <p>I want to read a line in a file and insert the new line ("\n") character in the n position on a line, so that a 9-character line, for instance, gets converted into three 3-character lines, like this:</p>
<pre><code>"123456789" (before)
"123\n456\n789" (after)
</code></pre>
<p>I've tried with this:</p>
<pre><code>... | 2 | 2009-07-27T13:40:53Z | 1,188,262 | <pre><code>with open(file, 'r+') as f:
data = f.read()
f.seek(0)
for i in range(len(data)): # could also use 'for i, chara in enumerate(data):' and then 'f.write(chara)' instead of 'f.write(data[i])'
if (i + 1) % 3 == 0: # could also do 'if i % 3 == 2:', but that may be slightly confusing
... | 1 | 2009-07-27T13:50:48Z | [
"python",
"file"
] |
Writing in file's actual position in Python | 1,188,214 | <p>I want to read a line in a file and insert the new line ("\n") character in the n position on a line, so that a 9-character line, for instance, gets converted into three 3-character lines, like this:</p>
<pre><code>"123456789" (before)
"123\n456\n789" (after)
</code></pre>
<p>I've tried with this:</p>
<pre><code>... | 2 | 2009-07-27T13:40:53Z | 1,188,527 | <p>You can think a file is just an array of characters, and if you want to insert a new element in the middle of an array, then you have to shift all the elements that are after it.</p>
<p>You could do what you say if the file contained a "linked list" of chars or "extends", but then you would need a special editor to... | 0 | 2009-07-27T14:33:55Z | [
"python",
"file"
] |
Why Python omits attribute in the SOAP message? | 1,188,367 | <p>I have a web service that returns following type:</p>
<pre><code><xsd:complexType name="TaggerResponse">
<xsd:sequence>
<xsd:element name="msg" type="xsd:string"></xsd:element>
</xsd:sequence>
<xsd:attribute name="status" type="tns:Status"></xsd:attribute>
... | 0 | 2009-07-27T14:10:55Z | 1,188,395 | <p>The response example you posted (the actual XML coming back from the WS request) does not have the value in it you are looking for! I would suggest this is why SOAPpy cannot return it to you.</p>
<p>If it is a case of making your code have consistent behaviour in cases where the value is returned and when it isn't... | 1 | 2009-07-27T14:15:21Z | [
"python",
"web-services",
"soap",
"wsdl",
"soappy"
] |
What are the benefits of not using cPickle to create a persistent storage for data? | 1,188,585 | <p>I'm considering the idea of creating a persistent storage like a dbms engine, what would be the benefits to create a custom binary format over directly cPickling the object and/or using the shelve module?</p>
| 5 | 2009-07-27T14:45:12Z | 1,188,679 | <p>Note that not all objects may be directly pickled - only basic types, or objects that have defined the pickle protocol.<br />
Using your own binary format would allow you to potentially store any kind of object.</p>
<p>Just for note, Zope Object DB (ZODB) is following that very same approach, storing objects with t... | 2 | 2009-07-27T14:59:48Z | [
"python",
"database",
"data-structures",
"persistence"
] |
What are the benefits of not using cPickle to create a persistent storage for data? | 1,188,585 | <p>I'm considering the idea of creating a persistent storage like a dbms engine, what would be the benefits to create a custom binary format over directly cPickling the object and/or using the shelve module?</p>
| 5 | 2009-07-27T14:45:12Z | 1,188,704 | <p>Pickling is a two-face coin.</p>
<p>On one side, you have a way to store your object in a very easy way. Just four lines of code and you pickle. You have the object exactly as it is.</p>
<p>On the other side, it can become a compatibility nightmare. You cannot unpickle objects if they are not defined in your code,... | 9 | 2009-07-27T15:04:38Z | [
"python",
"database",
"data-structures",
"persistence"
] |
What are the benefits of not using cPickle to create a persistent storage for data? | 1,188,585 | <p>I'm considering the idea of creating a persistent storage like a dbms engine, what would be the benefits to create a custom binary format over directly cPickling the object and/or using the shelve module?</p>
| 5 | 2009-07-27T14:45:12Z | 1,188,711 | <p>The potential advantages of a custom format over a pickle are:</p>
<ul>
<li>you can selectively get individual objects, rather than having to incarnate the full set of objects</li>
<li>you can query subsets of objects by properties, and only load those objects that match your criteria</li>
</ul>
<p>Whether these a... | 1 | 2009-07-27T15:06:16Z | [
"python",
"database",
"data-structures",
"persistence"
] |
What are the benefits of not using cPickle to create a persistent storage for data? | 1,188,585 | <p>I'm considering the idea of creating a persistent storage like a dbms engine, what would be the benefits to create a custom binary format over directly cPickling the object and/or using the shelve module?</p>
| 5 | 2009-07-27T14:45:12Z | 1,188,810 | <p>One reason to define your own custom binary format could be optimization. pickle (and shelve, which uses pickle) is a generic serialization framework; it can store almost any Python data. It's easy to use pickle in a lot of situations, but it takes time to inspect all the objects and serialize their data and the da... | 3 | 2009-07-27T15:20:59Z | [
"python",
"database",
"data-structures",
"persistence"
] |
What are the benefits of not using cPickle to create a persistent storage for data? | 1,188,585 | <p>I'm considering the idea of creating a persistent storage like a dbms engine, what would be the benefits to create a custom binary format over directly cPickling the object and/or using the shelve module?</p>
| 5 | 2009-07-27T14:45:12Z | 1,189,525 | <p>If you are going to do that (implement your own binary format), you should first know that python has a good library to handle HDF5, a binary format used in physics and astronomy to dump huge amounts of data.</p>
<p>This is the home page of the library:</p>
<ul>
<li><a href="http://www.pytables.org/moin" rel="nofo... | 1 | 2009-07-27T17:29:00Z | [
"python",
"database",
"data-structures",
"persistence"
] |
What are the benefits of not using cPickle to create a persistent storage for data? | 1,188,585 | <p>I'm considering the idea of creating a persistent storage like a dbms engine, what would be the benefits to create a custom binary format over directly cPickling the object and/or using the shelve module?</p>
| 5 | 2009-07-27T14:45:12Z | 1,189,928 | <p>Will you ever need to process data from untrusted sources? If so, you should know that the pickle format is actually a virtual machine that is capable of executing arbitrary code on behalf of the process doing the unpickling.</p>
| 0 | 2009-07-27T18:49:42Z | [
"python",
"database",
"data-structures",
"persistence"
] |
What are the benefits of not using cPickle to create a persistent storage for data? | 1,188,585 | <p>I'm considering the idea of creating a persistent storage like a dbms engine, what would be the benefits to create a custom binary format over directly cPickling the object and/or using the shelve module?</p>
| 5 | 2009-07-27T14:45:12Z | 1,416,946 | <p>See this solution at SourceForge:</p>
<p>y_serial.py module :: warehouse Python objects with SQLite</p>
<p>"Serialization + persistance :: in a few lines of code, compress and annotate Python objects into SQLite; then later retrieve them chronologically by keywords without any SQL. Most useful "standard" module fo... | 1 | 2009-09-13T05:42:39Z | [
"python",
"database",
"data-structures",
"persistence"
] |
Good or bad practice in Python: import in the middle of a file | 1,188,640 | <p>Suppose I have a relatively long module, but need an external module or method only once.</p>
<p>Is it considered OK to import that method or module in the middle of the module?</p>
<p>Or should <code>import</code>s only be in the first part of the module.</p>
<p>Example:</p>
<pre><code>import string, pythis, py... | 38 | 2009-07-27T14:53:25Z | 1,188,657 | <p>It is considered "Good Form" to group all imports together at the start of the file.</p>
<blockquote>
<p>Modules can import other modules. It is customary but not required to place all import statements at the beginning of a module (or script, for that matter). The imported module names are placed in the importin... | 7 | 2009-07-27T14:57:15Z | [
"python",
"python-import"
] |
Good or bad practice in Python: import in the middle of a file | 1,188,640 | <p>Suppose I have a relatively long module, but need an external module or method only once.</p>
<p>Is it considered OK to import that method or module in the middle of the module?</p>
<p>Or should <code>import</code>s only be in the first part of the module.</p>
<p>Example:</p>
<pre><code>import string, pythis, py... | 38 | 2009-07-27T14:53:25Z | 1,188,662 | <p>It's generally considered bad practice, but sometimes it's unavoidable (say when you have to avoid a circular import).</p>
<p>An example of a time when it is necessary: I use <a href="http://code.google.com/p/waf/">Waf</a> to build all our code. The system is split into tools, and each tool is implemented in it's ... | 5 | 2009-07-27T14:57:40Z | [
"python",
"python-import"
] |
Good or bad practice in Python: import in the middle of a file | 1,188,640 | <p>Suppose I have a relatively long module, but need an external module or method only once.</p>
<p>Is it considered OK to import that method or module in the middle of the module?</p>
<p>Or should <code>import</code>s only be in the first part of the module.</p>
<p>Example:</p>
<pre><code>import string, pythis, py... | 38 | 2009-07-27T14:53:25Z | 1,188,672 | <p><a href="http://www.python.org/dev/peps/pep-0008/">PEP 8</a> authoritatively states:</p>
<blockquote>
<p>Imports are always put at the top of
the file, just after any module
comments and docstrings, and before module globals and constants.</p>
</blockquote>
<p>PEP 8 should be the basis of any "in-house... | 41 | 2009-07-27T14:59:05Z | [
"python",
"python-import"
] |
Good or bad practice in Python: import in the middle of a file | 1,188,640 | <p>Suppose I have a relatively long module, but need an external module or method only once.</p>
<p>Is it considered OK to import that method or module in the middle of the module?</p>
<p>Or should <code>import</code>s only be in the first part of the module.</p>
<p>Example:</p>
<pre><code>import string, pythis, py... | 38 | 2009-07-27T14:53:25Z | 1,188,674 | <p>If the imported module is infrequently used and the import is expensive, the in-the-middle-import is OK.</p>
<p><strong>Otherwise, is it wise to follow Alex Martelli's suggestion.</strong></p>
| 9 | 2009-07-27T14:59:13Z | [
"python",
"python-import"
] |
Good or bad practice in Python: import in the middle of a file | 1,188,640 | <p>Suppose I have a relatively long module, but need an external module or method only once.</p>
<p>Is it considered OK to import that method or module in the middle of the module?</p>
<p>Or should <code>import</code>s only be in the first part of the module.</p>
<p>Example:</p>
<pre><code>import string, pythis, py... | 38 | 2009-07-27T14:53:25Z | 1,188,676 | <p><a href="http://www.python.org/dev/peps/pep-0008/" rel="nofollow">PEP8</a>:</p>
<blockquote>
<p>Imports are always put at the top of
the file, just after any module
comments and docstrings, and before module globals and constants.</p>
</blockquote>
<p>It is not bad practice to have scopped imports. So... | 2 | 2009-07-27T14:59:36Z | [
"python",
"python-import"
] |
Good or bad practice in Python: import in the middle of a file | 1,188,640 | <p>Suppose I have a relatively long module, but need an external module or method only once.</p>
<p>Is it considered OK to import that method or module in the middle of the module?</p>
<p>Or should <code>import</code>s only be in the first part of the module.</p>
<p>Example:</p>
<pre><code>import string, pythis, py... | 38 | 2009-07-27T14:53:25Z | 1,188,684 | <p>Well, I think it is a good practice to group all imports together at start of file since everyone knows where to look if want to know which libs are loaded</p>
| 2 | 2009-07-27T15:00:08Z | [
"python",
"python-import"
] |
Good or bad practice in Python: import in the middle of a file | 1,188,640 | <p>Suppose I have a relatively long module, but need an external module or method only once.</p>
<p>Is it considered OK to import that method or module in the middle of the module?</p>
<p>Or should <code>import</code>s only be in the first part of the module.</p>
<p>Example:</p>
<pre><code>import string, pythis, py... | 38 | 2009-07-27T14:53:25Z | 1,188,693 | <p>There was a detailed discussion of this topic on the Python mailing list in 2001:</p>
<p><a href="https://mail.python.org/pipermail/python-list/2001-July/071567.html" rel="nofollow">https://mail.python.org/pipermail/python-list/2001-July/071567.html</a></p>
| 13 | 2009-07-27T15:02:08Z | [
"python",
"python-import"
] |
Good or bad practice in Python: import in the middle of a file | 1,188,640 | <p>Suppose I have a relatively long module, but need an external module or method only once.</p>
<p>Is it considered OK to import that method or module in the middle of the module?</p>
<p>Or should <code>import</code>s only be in the first part of the module.</p>
<p>Example:</p>
<pre><code>import string, pythis, py... | 38 | 2009-07-27T14:53:25Z | 1,188,862 | <p>95% of the time, you should put all your imports at the top of the file. One case where you might want to do a function-local import is if you have to do it in order to avoid circular imports. Say foo.py imports bar.py, and a function in bar.py needs to import something from foo.py. If you put all your imports at... | 3 | 2009-07-27T15:30:42Z | [
"python",
"python-import"
] |
Good or bad practice in Python: import in the middle of a file | 1,188,640 | <p>Suppose I have a relatively long module, but need an external module or method only once.</p>
<p>Is it considered OK to import that method or module in the middle of the module?</p>
<p>Or should <code>import</code>s only be in the first part of the module.</p>
<p>Example:</p>
<pre><code>import string, pythis, py... | 38 | 2009-07-27T14:53:25Z | 1,189,199 | <p>Everyone else has already mentioned the PEPs, but also take care to <strong>not</strong> have import statements in the middle of critical code. At least under Python 2.6, there are several more bytecode instructions required when a function has an import statement.</p>
<pre><code>>>> def f():
from tim... | 12 | 2009-07-27T16:27:29Z | [
"python",
"python-import"
] |
Python POST ordered params | 1,188,737 | <p>I have a web service that accepts passed in params using http POST but in a specific order, eg (name,password,data). I have tried to use httplib but all the Python http POST libraries seem to take a dictionary, which is an unordered data structure. Any thoughts on how to http POST params in order for Python?</p>
... | 2 | 2009-07-27T15:11:19Z | 1,188,759 | <p>Why would you need a specific order in the POST parameters in the first place? As far as I know there are no requirements that POST parameter order is preserved by web servers.</p>
<p>Every language I have used, has used a dictionary type object to hold these parameters as they are inherently key/value pairs.</p>
| 2 | 2009-07-27T15:14:21Z | [
"python",
"http"
] |
Make SetupTools/easy_install aware of installed Debian Packages? | 1,188,812 | <p>I'm installing an egg with <code>easy_install</code> which requires <code>ruledispatch</code>. It isn't available in PyPI, and when I use PEAK's version it <a href="http://en.wikipedia.org/wiki/FTBFS" rel="nofollow">FTBFS</a>. There is, however, a <code>python-dispatch</code> package which provides the same function... | 1 | 2009-07-27T15:21:20Z | 1,188,915 | <p>The path least fiddly is likely:</p>
<ol>
<li>easy_install --no-deps</li>
<li>Look at the egginfo of what you just installed</li>
<li>Install all dependencies except ruledispatch by hand</li>
<li>Optionally, prod the people responsible to list their stuff on pypi / not have dependencies that the package installer c... | 3 | 2009-07-27T15:40:16Z | [
"python",
"debian",
"setuptools",
"easy-install",
"etch"
] |
Django: Easily add extra manager for child class, still use default manager from AbstractBase | 1,188,899 | <p>this question is about the last example on <a href="http://docs.djangoproject.com/en/dev/topics/db/managers/#custom-managers-and-model-inheritance" rel="nofollow">Custom managers and model inheritance</a>.</p>
<p>I want to be able to do something similar to the following:</p>
<pre><code>class ExtraManagerModel(mod... | 1 | 2009-07-27T15:37:16Z | 1,189,025 | <p>I am absolutely not sure that I understand your question. Your code snippet seems to be contradicting the comment underneath it.</p>
<p>Your code snippet looks like you want to be able to have different ExtraManagerModel classes. If that is the case, you can use an abstract class that is implemented by those ExtraM... | 0 | 2009-07-27T16:02:11Z | [
"python",
"django",
"django-models"
] |
How can I get nose to find class attributes defined on a base test class? | 1,188,922 | <p>I'm getting some integration tests running against the database, and I'd like to have a structure that looks something like this:</p>
<pre><code>class OracleMixin(object):
oracle = True
# ... set up the oracle connection
class SqlServerMixin(object):
sql_server = True
# ... set up the sql server co... | 4 | 2009-07-27T15:41:55Z | 1,189,540 | <p>I do not think you can without making your own plugin. The the code in the attrib plugin only looks at the classes <code>__dict__</code>. Here is the <a href="http://somethingaboutorange.com/mrl/projects/nose/0.11.1/plugins/attrib.html" rel="nofollow">code</a> </p>
<pre><code>def wantClass(self, cls):
"""Accep... | 4 | 2009-07-27T17:30:59Z | [
"python",
"integration-testing",
"multiple-inheritance",
"nose",
"mixins"
] |
How can I get nose to find class attributes defined on a base test class? | 1,188,922 | <p>I'm getting some integration tests running against the database, and I'd like to have a structure that looks something like this:</p>
<pre><code>class OracleMixin(object):
oracle = True
# ... set up the oracle connection
class SqlServerMixin(object):
sql_server = True
# ... set up the sql server co... | 4 | 2009-07-27T15:41:55Z | 1,190,946 | <p>If you want to find an attribute defined on a parent class, and you have an attribute of the same name in the subclass you will need to add the name of the parent class to access the scope you want</p>
<p><em>I believe this is what you want:</em></p>
<pre><code>class Parent:
prop = 'a property'
def self_pro... | 0 | 2009-07-27T22:11:54Z | [
"python",
"integration-testing",
"multiple-inheritance",
"nose",
"mixins"
] |
Why the trailing slash in the web service is so important? | 1,188,927 | <p>I was testing a web service in PHP and Python. The address of the web service was, let's say, <code>http://my.domain.com/my/webservice</code>. When I tested the web service in PHP using that URL everything worked fine. But, when I used the same location but in Python using SOAPpy I got an error.</p>
<p>Below is the... | 7 | 2009-07-27T15:43:16Z | 1,188,941 | <p>Because the actual server URL is:
<a href="http://my.domain.com/my/webservice/" rel="nofollow">http://my.domain.com/my/webservice/</a></p>
<p>The PHP library must be following redirects by default.</p>
| 3 | 2009-07-27T15:45:14Z | [
"php",
"python",
"wsdl",
"soappy"
] |
Why the trailing slash in the web service is so important? | 1,188,927 | <p>I was testing a web service in PHP and Python. The address of the web service was, let's say, <code>http://my.domain.com/my/webservice</code>. When I tested the web service in PHP using that URL everything worked fine. But, when I used the same location but in Python using SOAPpy I got an error.</p>
<p>Below is the... | 7 | 2009-07-27T15:43:16Z | 1,188,943 | <p>They're different URLs. <code>http://my.domain.com/my/webservice</code> implies a file <code>webservice</code> in the <code>my</code> folder. <code>http://my.domain.com/my/webservice/</code> implies the default document inside the my/webservice folder.</p>
<p>Many webservers will automatically correct such URLs, bu... | 19 | 2009-07-27T15:46:21Z | [
"php",
"python",
"wsdl",
"soappy"
] |
Why the trailing slash in the web service is so important? | 1,188,927 | <p>I was testing a web service in PHP and Python. The address of the web service was, let's say, <code>http://my.domain.com/my/webservice</code>. When I tested the web service in PHP using that URL everything worked fine. But, when I used the same location but in Python using SOAPpy I got an error.</p>
<p>Below is the... | 7 | 2009-07-27T15:43:16Z | 1,188,967 | <p>[Disclaimer: This is a copy of my answer <a href="http://stackoverflow.com/questions/1160329/question-about-simplehttpserver-py/1160445#1160445">from here</a>. I know some people don't like this kind of copying, but this explains why the slash is important.]</p>
<p>Imagine you serve a page</p>
<pre><code>http://my... | 2 | 2009-07-27T15:50:33Z | [
"php",
"python",
"wsdl",
"soappy"
] |
Why the trailing slash in the web service is so important? | 1,188,927 | <p>I was testing a web service in PHP and Python. The address of the web service was, let's say, <code>http://my.domain.com/my/webservice</code>. When I tested the web service in PHP using that URL everything worked fine. But, when I used the same location but in Python using SOAPpy I got an error.</p>
<p>Below is the... | 7 | 2009-07-27T15:43:16Z | 1,188,995 | <p>The error is a 301 redirect meaning the you are being redirected to the URL with the slash on the end by the web server. </p>
<p>It seems that PHP will auto follow this redirect and thus not throw the error, whereas Python won't. You will need to do the following:</p>
<ol>
<li>Try to Connect to the initial URL</li... | 3 | 2009-07-27T15:56:07Z | [
"php",
"python",
"wsdl",
"soappy"
] |
Why the trailing slash in the web service is so important? | 1,188,927 | <p>I was testing a web service in PHP and Python. The address of the web service was, let's say, <code>http://my.domain.com/my/webservice</code>. When I tested the web service in PHP using that URL everything worked fine. But, when I used the same location but in Python using SOAPpy I got an error.</p>
<p>Below is the... | 7 | 2009-07-27T15:43:16Z | 1,189,018 | <p>What a SOAP-URL looks like is up to the server, if a slash is necessary depends on the server and the SOAP implementation.</p>
<p>In your case, I assume that the target server is an apache server and the SOAP URL is actually a directory that contains your SOAP handling script.
When you access <a href="http://my.dom... | 0 | 2009-07-27T16:01:16Z | [
"php",
"python",
"wsdl",
"soappy"
] |
Reason for unintuitive UnboundLocalError behaviour | 1,188,944 | <p>Note: There is a very similar question <a href="http://stackoverflow.com/questions/404534/python-globals-locals-and-unboundlocalerror">here</a>. Bear with me, however; my question is not "Why does the error happen," but "Why was Python implemented as to throw an error in this case."</p>
<p>I just stumbled over this... | 4 | 2009-07-27T15:46:35Z | 1,189,075 | <p>Having the same, identical name refer to completely different variables within the same flow of linear code is such a mind-boggling complexity that it staggers the mind. Consider:</p>
<pre><code>def aaaargh(alist):
for x in alist:
print a
a = 23
</code></pre>
<p>what is THIS code supposed to do in your d... | 5 | 2009-07-27T16:08:56Z | [
"python"
] |
Reason for unintuitive UnboundLocalError behaviour | 1,188,944 | <p>Note: There is a very similar question <a href="http://stackoverflow.com/questions/404534/python-globals-locals-and-unboundlocalerror">here</a>. Bear with me, however; my question is not "Why does the error happen," but "Why was Python implemented as to throw an error in this case."</p>
<p>I just stumbled over this... | 4 | 2009-07-27T15:46:35Z | 1,189,081 | <p>I believe there is a possible ambiguity.</p>
<pre><code>a = 5
def x():
print a
a = 6 # could be local or trying to update the global variable
x()
</code></pre>
<p>It could be as you assumed:</p>
<pre><code>a = 5
def x():
print globals()["a"]
a = 6 # local assignment
x()
</code></pre>
<p>Or it co... | 1 | 2009-07-27T16:09:36Z | [
"python"
] |
Reason for unintuitive UnboundLocalError behaviour | 1,188,944 | <p>Note: There is a very similar question <a href="http://stackoverflow.com/questions/404534/python-globals-locals-and-unboundlocalerror">here</a>. Bear with me, however; my question is not "Why does the error happen," but "Why was Python implemented as to throw an error in this case."</p>
<p>I just stumbled over this... | 4 | 2009-07-27T15:46:35Z | 1,189,177 | <p>This is a basic side effect of scoping. The python developers decided that global variables shouldn't be available in the scope you are trying to use it in. Take this for example:</p>
<pre><code>a = 5
def x():
a = 6
print a
x()
print a
</code></pre>
<p>This outputs <code>6 5</code>.</p>
<p>It is <a href... | 0 | 2009-07-27T16:23:53Z | [
"python"
] |
What are the Python thread + Unix signals semantics? | 1,189,072 | <p>What are the rules surrounding Python threads and how Unix signals are handled?</p>
<p>Is <code>KeyboardInterrupt</code>, which is triggered by <code>SIGINT</code> but handled internally by the Python runtime, handled differently?</p>
| 8 | 2009-07-27T16:08:34Z | 1,189,100 | <p>From the <a href="http://docs.python.org/library/signal.html" rel="nofollow"><code>signal</code></a> documentation:</p>
<blockquote>
<p>Some care must be taken if both signals and threads are used in the same program. The fundamental thing to remember in using signals and threads simultaneously is: always perform... | 4 | 2009-07-27T16:11:52Z | [
"python",
"unix",
"multithreading",
"posix",
"signals"
] |
What are the Python thread + Unix signals semantics? | 1,189,072 | <p>What are the rules surrounding Python threads and how Unix signals are handled?</p>
<p>Is <code>KeyboardInterrupt</code>, which is triggered by <code>SIGINT</code> but handled internally by the Python runtime, handled differently?</p>
| 8 | 2009-07-27T16:08:34Z | 1,189,162 | <p>First, when setting up signal handlers using the <a href="http://docs.python.org/library/signal.html"><code>signal</code></a> module, you must create them in the main thread. You will receive an exception if you try to create them in a separate thread.</p>
<p>Signal handlers registered via the <code>signal.signal(... | 9 | 2009-07-27T16:21:02Z | [
"python",
"unix",
"multithreading",
"posix",
"signals"
] |
Unicode to UTF8 for CSV Files - Python via xlrd | 1,189,111 | <p>I'm trying to translate an Excel spreadsheet to CSV using the Python xlrd and csv modules, but am getting hung up on encoding issues. Xlrd produces output from Excel in Unicode, and the CSV module requires UTF-8.</p>
<p>I imaging that this has nothing to do with the xlrd module: everything works fine outputing to s... | 18 | 2009-07-27T16:13:48Z | 1,189,195 | <p>There appear to be two possibilities. One is that you have not perhaps opened the output file correctly:</p>
<p>"If csvfile is a file object, it must be opened with the âbâ flag on platforms where that makes a difference." ( <a href="http://docs.python.org/library/csv.html#module-csv" rel="nofollow">http://doc... | 0 | 2009-07-27T16:26:45Z | [
"python",
"unicode",
"encoding",
"csv",
"xlrd"
] |
Unicode to UTF8 for CSV Files - Python via xlrd | 1,189,111 | <p>I'm trying to translate an Excel spreadsheet to CSV using the Python xlrd and csv modules, but am getting hung up on encoding issues. Xlrd produces output from Excel in Unicode, and the CSV module requires UTF-8.</p>
<p>I imaging that this has nothing to do with the xlrd module: everything works fine outputing to s... | 18 | 2009-07-27T16:13:48Z | 1,189,198 | <p>Looks like you've got 2 problems.</p>
<p>There's something screwed up in that cell - '7' should be encoded as u'x37' I think, since it's within the ASCII-range.</p>
<p>More importantly though, the fact that you're getting an error message specifying that the <code>ascii</code> codec can't be used suggests somethin... | 0 | 2009-07-27T16:27:06Z | [
"python",
"unicode",
"encoding",
"csv",
"xlrd"
] |
Unicode to UTF8 for CSV Files - Python via xlrd | 1,189,111 | <p>I'm trying to translate an Excel spreadsheet to CSV using the Python xlrd and csv modules, but am getting hung up on encoding issues. Xlrd produces output from Excel in Unicode, and the CSV module requires UTF-8.</p>
<p>I imaging that this has nothing to do with the xlrd module: everything works fine outputing to s... | 18 | 2009-07-27T16:13:48Z | 1,189,575 | <p>I expect the <code>cell_value</code> return value is the unicode string that's giving you problems (please print its <code>type()</code> to confirm that), in which case you should be able to solve it by changing this one line:</p>
<pre><code>this_row.append(s.cell_value(row,col))
</code></pre>
<p>to:</p>
<pre><co... | 24 | 2009-07-27T17:37:03Z | [
"python",
"unicode",
"encoding",
"csv",
"xlrd"
] |
Unicode to UTF8 for CSV Files - Python via xlrd | 1,189,111 | <p>I'm trying to translate an Excel spreadsheet to CSV using the Python xlrd and csv modules, but am getting hung up on encoding issues. Xlrd produces output from Excel in Unicode, and the CSV module requires UTF-8.</p>
<p>I imaging that this has nothing to do with the xlrd module: everything works fine outputing to s... | 18 | 2009-07-27T16:13:48Z | 1,193,301 | <p>You asked for explanations, but some of the phenomena are inexplicable without your help.</p>
<p>(A) Strings in XLS files created by Excel 97 onwards are encoded in Latin1 if possible otherwise in UTF16LE. Each string carries a flag telling which was used. Earlier Excels encoded strings according to the user's "co... | 8 | 2009-07-28T10:45:53Z | [
"python",
"unicode",
"encoding",
"csv",
"xlrd"
] |
Is there a Python module to access Advantage Database Server? | 1,189,146 | <p>As the title suggest, I was wondering if there is a Python module that can access an Advantage Database Server (Sybase) files such as ADT and DBF.</p>
<p>I have searched the web and couldn't find what I'm looking for this is why I wanted to ask it here.</p>
| 3 | 2009-07-27T16:18:59Z | 1,189,539 | <p><a href="http://www.fiby.at/dbfpy/" rel="nofollow">dbfpy</a> (and many other modules) let you read and write DBF files. I'm not aware of similar modules dealing with ADT files directly, but I think there are converters to make DBF files to/from ADT, if worse comes to worst.</p>
<p>Another alternative for accessing ... | 1 | 2009-07-27T17:30:54Z | [
"python",
"database",
"module",
"dbf",
"advantage-database-server"
] |
Is there a Python module to access Advantage Database Server? | 1,189,146 | <p>As the title suggest, I was wondering if there is a Python module that can access an Advantage Database Server (Sybase) files such as ADT and DBF.</p>
<p>I have searched the web and couldn't find what I'm looking for this is why I wanted to ask it here.</p>
| 3 | 2009-07-27T16:18:59Z | 2,186,332 | <p>I have used pyodbc with the Advantage ODBC driver, <a href="http://code.google.com/p/pyodbc/" rel="nofollow">http://code.google.com/p/pyodbc/</a> and pywin32 <a href="http://sourceforge.net/projects/pywin32/" rel="nofollow">http://sourceforge.net/projects/pywin32/</a> with the Advantage OLE DB provider successfully.... | 2 | 2010-02-02T17:50:20Z | [
"python",
"database",
"module",
"dbf",
"advantage-database-server"
] |
How do I resolve an SRV record in Python? | 1,189,253 | <p>Something which doesn't rely on native libraries would be better.</p>
| 4 | 2009-07-27T16:40:11Z | 1,189,427 | <p><a href="http://twistedmatrix.com/trac/">twisted</a> has an excellent pure-python implementation, see <a href="http://twistedmatrix.com/trac/browser/trunk/twisted/names">twisted.names</a> sources (especially <a href="http://twistedmatrix.com/trac/browser/trunk/twisted/names/dns.py">dns.py</a>). If you can't use all ... | 7 | 2009-07-27T17:14:00Z | [
"python",
"networking",
"dns",
"srv"
] |
How do I resolve an SRV record in Python? | 1,189,253 | <p>Something which doesn't rely on native libraries would be better.</p>
| 4 | 2009-07-27T16:40:11Z | 1,191,670 | <p>You could try the dnspython library:</p>
<ul>
<li><a href="http://www.dnspython.org/examples.html">http://www.dnspython.org/examples.html</a></li>
<li><a href="http://www.dnspython.org/docs/1.7.1/html/dns.rdtypes.IN.SRV.SRV-class.html">http://www.dnspython.org/docs/1.7.1/html/dns.rdtypes.IN.SRV.SRV-class.html</a></... | 6 | 2009-07-28T02:33:54Z | [
"python",
"networking",
"dns",
"srv"
] |
How do I resolve an SRV record in Python? | 1,189,253 | <p>Something which doesn't rely on native libraries would be better.</p>
| 4 | 2009-07-27T16:40:11Z | 15,123,686 | <p>Using <a href="http://sourceforge.net/projects/pydns/" rel="nofollow">pydns</a>:</p>
<pre><code>import DNS
DNS.ParseResolvConf()
srv_req = DNS.Request(qtype = 'srv')
srv_result = srv_req.req('_ldap._tcp.example.org')
for result in srv_result.answers:
if result['typename'] == 'SRV':
print result['data']... | 1 | 2013-02-27T22:25:01Z | [
"python",
"networking",
"dns",
"srv"
] |
Does YouTube's API allow uploading and setting of thumbnails? | 1,189,365 | <p>I haven't found anything in their documentation or on the web that says yes or no. Using the Python library.</p>
| 0 | 2009-07-27T16:59:12Z | 1,189,511 | <p>Apparently thumbnails can't be <em>updated</em>, per <a href="http://code.google.com/apis/youtube/2.0/developers%5Fguide%5Fprotocol.html#Updating%5FVideo%5FEntry" rel="nofollow">the docs</a> -- <a href="http://code.google.com/apis/youtube/2.0/reference.html#youtube%5Fdata%5Fapi%5Ftag%5Fmedia:thumbnail" rel="nofollow... | 2 | 2009-07-27T17:27:07Z | [
"python",
"api",
"youtube"
] |
python non-privileged ICMP | 1,189,389 | <p>While trying to figure out the best method to ping (ICMP) something from python, I came across these questions:</p>
<ul>
<li><a href="http://stackoverflow.com/questions/1151897/how-can-i-perform-a-ping-or-traceroute-in-python-accessing-the-output-as-it-is-p">How can I perform a ping or traceroute in python, accessi... | 15 | 2009-07-27T17:02:54Z | 1,189,445 | <p>The ping program is installed setuid root. This allows any user to use the program, and still be able to open a raw socket.</p>
<p>After it opens the raw socket, it typically drops root privs.</p>
<p>You generally need a raw socket to do ICMP correctly, and raw sockets are usually restricted. So it's not really p... | 10 | 2009-07-27T17:17:25Z | [
"python",
"ping",
"icmp"
] |
python non-privileged ICMP | 1,189,389 | <p>While trying to figure out the best method to ping (ICMP) something from python, I came across these questions:</p>
<ul>
<li><a href="http://stackoverflow.com/questions/1151897/how-can-i-perform-a-ping-or-traceroute-in-python-accessing-the-output-as-it-is-p">How can I perform a ping or traceroute in python, accessi... | 15 | 2009-07-27T17:02:54Z | 1,189,449 | <p>Here's how /sbin/ping "somehow manages" (on most Unix-y systems):</p>
<pre><code>$ ls -l /sbin/ping
-r-sr-xr-x 1 root wheel 68448 Jan 26 10:00 /sbin/ping
</code></pre>
<p>See? It's owned by <code>root</code> and has that crucial <code>s</code> bit in the permission -- setuserid. So, no matter what user is runn... | 9 | 2009-07-27T17:18:06Z | [
"python",
"ping",
"icmp"
] |
python non-privileged ICMP | 1,189,389 | <p>While trying to figure out the best method to ping (ICMP) something from python, I came across these questions:</p>
<ul>
<li><a href="http://stackoverflow.com/questions/1151897/how-can-i-perform-a-ping-or-traceroute-in-python-accessing-the-output-as-it-is-p">How can I perform a ping or traceroute in python, accessi... | 15 | 2009-07-27T17:02:54Z | 3,414,737 | <p>I'm not sure if it is OK to post something in a question that seems it has already been answered a while ago.</p>
<p>I have been searching for the same implementation and found a way to do ICMP via Python with non-root privileges.</p>
<p><code>python-ping</code> uses the same 'need-root' way to do a ping, but came... | 0 | 2010-08-05T12:40:24Z | [
"python",
"ping",
"icmp"
] |
python non-privileged ICMP | 1,189,389 | <p>While trying to figure out the best method to ping (ICMP) something from python, I came across these questions:</p>
<ul>
<li><a href="http://stackoverflow.com/questions/1151897/how-can-i-perform-a-ping-or-traceroute-in-python-accessing-the-output-as-it-is-p">How can I perform a ping or traceroute in python, accessi... | 15 | 2009-07-27T17:02:54Z | 5,362,316 | <p>I was also looking for an implementation of ping without using subprocess or needing root to ping. My solution needed to be cross-platform, namely Windows and Linux.</p>
<p>Changing the socket on Windows to SOCK_DGRAM results in a "protocol not supported 100043" exception. So it looks like Windows correctly check... | 0 | 2011-03-19T13:18:43Z | [
"python",
"ping",
"icmp"
] |
python non-privileged ICMP | 1,189,389 | <p>While trying to figure out the best method to ping (ICMP) something from python, I came across these questions:</p>
<ul>
<li><a href="http://stackoverflow.com/questions/1151897/how-can-i-perform-a-ping-or-traceroute-in-python-accessing-the-output-as-it-is-p">How can I perform a ping or traceroute in python, accessi... | 15 | 2009-07-27T17:02:54Z | 5,572,176 | <p>Actually, on Windows 7 and Vista you do need to 'Run as Administrator' to do:</p>
<pre><code>my_socket = socket.socket(socket.AF_INET, socket.SOCK_RAW, icmp)
</code></pre>
<p>and as you note, doing it over a datagram socket causes an error.</p>
| 1 | 2011-04-06T19:51:46Z | [
"python",
"ping",
"icmp"
] |
python non-privileged ICMP | 1,189,389 | <p>While trying to figure out the best method to ping (ICMP) something from python, I came across these questions:</p>
<ul>
<li><a href="http://stackoverflow.com/questions/1151897/how-can-i-perform-a-ping-or-traceroute-in-python-accessing-the-output-as-it-is-p">How can I perform a ping or traceroute in python, accessi... | 15 | 2009-07-27T17:02:54Z | 6,281,194 | <p>I am running python under windows 7 ,
Since i am editing and "compiling" the code under Eclipse pydev plugin,
My solution was : Running the eclipse.exe as an administrator : this solved the problem,</p>
<p>This solution is similar to running the cmd as an administrator.</p>
| -6 | 2011-06-08T15:18:33Z | [
"python",
"ping",
"icmp"
] |
python non-privileged ICMP | 1,189,389 | <p>While trying to figure out the best method to ping (ICMP) something from python, I came across these questions:</p>
<ul>
<li><a href="http://stackoverflow.com/questions/1151897/how-can-i-perform-a-ping-or-traceroute-in-python-accessing-the-output-as-it-is-p">How can I perform a ping or traceroute in python, accessi... | 15 | 2009-07-27T17:02:54Z | 21,308,054 | <p>The man page you're reading is about "BSD Kernel Interfaces Manual" and seems to come from "Mac OS X 10.9". I don't have a Mac OS X machine to try, but under Linux, <strong>as root or as user</strong> I get a permission denied error when I try to open such an ICMP:</p>
<pre><code>$ strace -e trace=socket python
Pyt... | 0 | 2014-01-23T12:23:12Z | [
"python",
"ping",
"icmp"
] |
python non-privileged ICMP | 1,189,389 | <p>While trying to figure out the best method to ping (ICMP) something from python, I came across these questions:</p>
<ul>
<li><a href="http://stackoverflow.com/questions/1151897/how-can-i-perform-a-ping-or-traceroute-in-python-accessing-the-output-as-it-is-p">How can I perform a ping or traceroute in python, accessi... | 15 | 2009-07-27T17:02:54Z | 27,059,188 | <p>Modern Linuxes ping uses libcap and asks libcap to do the work.This checks (capget/set funcitons) and manage permissions:</p>
<pre><code>linux@jacax:~/WORK$ ldd /bin/ping
linux-gate.so.1 => (0xb77b6000)
libcap.so.2 => /lib/i386-linux-gnu/libcap.so.2 (0xb7796000)
libc.so.6 => /lib/i386-li... | 2 | 2014-11-21T10:30:35Z | [
"python",
"ping",
"icmp"
] |
Django cache.set() causing duplicate key error | 1,189,541 | <p>My Django site recently started throwing errors from my caching code and I can't figure out why...</p>
<p>I call:</p>
<pre><code>from django.core.cache import cache
cache.set('blogentry', some_value)
</code></pre>
<p>And the error thrown by Django is:</p>
<pre><code>TransactionManagementError: This code isn't un... | 4 | 2009-07-27T17:31:09Z | 1,190,725 | <p>The code in core/cache/backend/db.py reads in part:</p>
<pre><code>cursor.execute("SELECT cache_key, expires FROM %s WHERE cache_key = %%s" % self._table, [key])
try:
result = cursor.fetchone()
if result and (mode == 'set' or
(mode == 'add' and result[1] < now)):
cursor.execute("UPDAT... | 0 | 2009-07-27T21:25:55Z | [
"python",
"django",
"postgresql",
"caching"
] |
Django cache.set() causing duplicate key error | 1,189,541 | <p>My Django site recently started throwing errors from my caching code and I can't figure out why...</p>
<p>I call:</p>
<pre><code>from django.core.cache import cache
cache.set('blogentry', some_value)
</code></pre>
<p>And the error thrown by Django is:</p>
<pre><code>TransactionManagementError: This code isn't un... | 4 | 2009-07-27T17:31:09Z | 1,190,793 | <p>That's a typical race. It checks if the key you inserted exists; if it doesn't, it does an insert, but someone else can insert the key between the count and the insert. Transactions don't prevent this.</p>
<p>The code appears to expect this and to try to deal with it, but when I looked at the code to handle this ... | 4 | 2009-07-27T21:38:55Z | [
"python",
"django",
"postgresql",
"caching"
] |
Django cache.set() causing duplicate key error | 1,189,541 | <p>My Django site recently started throwing errors from my caching code and I can't figure out why...</p>
<p>I call:</p>
<pre><code>from django.core.cache import cache
cache.set('blogentry', some_value)
</code></pre>
<p>And the error thrown by Django is:</p>
<pre><code>TransactionManagementError: This code isn't un... | 4 | 2009-07-27T17:31:09Z | 7,854,628 | <p>I solved this problem by creating a custom cache backend, overriding the _base_set() function and changing the INSERT INTO statement like this. This SQL trick prevents the INSERT from happening in the case the cache_key already exists.</p>
<pre><code>cursor.execute("INSERT INTO %s (cache_key, value, expires) SELECT... | 0 | 2011-10-21T19:57:42Z | [
"python",
"django",
"postgresql",
"caching"
] |
In Python, what's the correct way to instantiate a class from a variable? | 1,189,649 | <p>Suppose that I have class <code>C</code>.</p>
<p>I can write <code>o = C()</code> to create an instance of <code>C</code> and assign it to <code>o</code>.</p>
<p>However, what if I want to assign the class itself into a variable and then instantiate it?</p>
<p>For example, suppose that I have two classes, such as... | 4 | 2009-07-27T17:58:59Z | 1,189,668 | <pre><code>o = C2()
</code></pre>
<p>This will accomplish what you want. Or, in case you meant to use classToUse, simply use:</p>
<pre><code>o = classToUse()
</code></pre>
<p>Hope this helps.</p>
| 14 | 2009-07-27T18:01:23Z | [
"python",
"instantiation"
] |
In Python, what's the correct way to instantiate a class from a variable? | 1,189,649 | <p>Suppose that I have class <code>C</code>.</p>
<p>I can write <code>o = C()</code> to create an instance of <code>C</code> and assign it to <code>o</code>.</p>
<p>However, what if I want to assign the class itself into a variable and then instantiate it?</p>
<p>For example, suppose that I have two classes, such as... | 4 | 2009-07-27T17:58:59Z | 1,189,673 | <p>It's simple, Python don't recognize where a varible is a class or function. It's just call that value.</p>
<pre><code>class A:
pass
B=A
b=B()
</code></pre>
| 1 | 2009-07-27T18:02:42Z | [
"python",
"instantiation"
] |
In Python, what's the correct way to instantiate a class from a variable? | 1,189,649 | <p>Suppose that I have class <code>C</code>.</p>
<p>I can write <code>o = C()</code> to create an instance of <code>C</code> and assign it to <code>o</code>.</p>
<p>However, what if I want to assign the class itself into a variable and then instantiate it?</p>
<p>For example, suppose that I have two classes, such as... | 4 | 2009-07-27T17:58:59Z | 1,189,701 | <p>You're almost there. Instead of calling an instantiate() method, just call the variable directly. It's assigned to the class, and classes are callable:</p>
<pre><code>if (something):
classToUse = C1
else:
classToUse = C2
o = classToUse()
</code></pre>
| 10 | 2009-07-27T18:06:31Z | [
"python",
"instantiation"
] |
In Python, what's the correct way to instantiate a class from a variable? | 1,189,649 | <p>Suppose that I have class <code>C</code>.</p>
<p>I can write <code>o = C()</code> to create an instance of <code>C</code> and assign it to <code>o</code>.</p>
<p>However, what if I want to assign the class itself into a variable and then instantiate it?</p>
<p>For example, suppose that I have two classes, such as... | 4 | 2009-07-27T17:58:59Z | 1,191,448 | <p>A class is an object just like anything else, like an instance, a function, a string... a class is an instance too. So you can store it in a variable (or anywhere else that you can store stuff), and call it with () no matter where it comes from. </p>
<pre><code>def f(): print "foo"
class C: pass
x = f
x() # print... | 0 | 2009-07-28T01:11:32Z | [
"python",
"instantiation"
] |
Event Handling in Chaco | 1,189,864 | <p>When hovering over a data point in Chaco, I would like a small text box to appear, with the text I desire. Also, when I click on a data point (or close enough), I would like my program to take a certain action. I have seen relevant parts of the Chaco documentation, but implementing them has proved difficult. Any hel... | 0 | 2009-07-27T18:40:13Z | 1,189,980 | <p>Focusing first on the first (hover->textbox) issue, can you better explain what you've tried so far and how it's not working? E.g.,</p>
<pre><code>from enthought.enable.tools import hover_tool
tool = hover_tool.HoverTool(theplot, callback=showtext)
</code></pre>
<p>etc? There's a more complex example of hover-t... | 0 | 2009-07-27T19:01:40Z | [
"python"
] |
Alternative to cvs2svn for performing cvs to svn migration | 1,190,413 | <p>I am trying to perform a migration from cvs to svn on my our new XServe server which is running OS X Server. There is a known conflict between the cvs2svn and dbm libraries that come pre-installed with OS X. The error is:</p>
<blockquote>
<p>ERROR: cvs2svn uses the anydbm package, which depends on lower level d... | 3 | 2009-07-27T20:24:55Z | 1,190,431 | <p>You could always manually install other dbm libraries using e.g. MacPorts.</p>
| 1 | 2009-07-27T20:28:23Z | [
"python",
"osx",
"xserver",
"cvs2svn",
"gdbm"
] |
Alternative to cvs2svn for performing cvs to svn migration | 1,190,413 | <p>I am trying to perform a migration from cvs to svn on my our new XServe server which is running OS X Server. There is a known conflict between the cvs2svn and dbm libraries that come pre-installed with OS X. The error is:</p>
<blockquote>
<p>ERROR: cvs2svn uses the anydbm package, which depends on lower level d... | 3 | 2009-07-27T20:24:55Z | 1,190,437 | <p>Since CVS and Subversion repositories are really just collections of files, one way to work around this problem might be to copy your CVS repository to a machine where cvs2svn can run successfully, run it to convert to Subversion, and then copy the new repository back to your server. The added benefit of this method... | 7 | 2009-07-27T20:29:25Z | [
"python",
"osx",
"xserver",
"cvs2svn",
"gdbm"
] |
Alternative to cvs2svn for performing cvs to svn migration | 1,190,413 | <p>I am trying to perform a migration from cvs to svn on my our new XServe server which is running OS X Server. There is a known conflict between the cvs2svn and dbm libraries that come pre-installed with OS X. The error is:</p>
<blockquote>
<p>ERROR: cvs2svn uses the anydbm package, which depends on lower level d... | 3 | 2009-07-27T20:24:55Z | 1,190,742 | <p>Maybe sounds a bit crazy or overkill, but think about using 'git' (e.g. MacPorts version). It clones the complete CVS history and pushes it into a Subversion repository. The following steps should do the work (look at the command's manuals, git help ´cmd´): </p>
<pre>
port install git-core cvs cvsps svn (if n... | 0 | 2009-07-27T21:28:39Z | [
"python",
"osx",
"xserver",
"cvs2svn",
"gdbm"
] |
Alternative to cvs2svn for performing cvs to svn migration | 1,190,413 | <p>I am trying to perform a migration from cvs to svn on my our new XServe server which is running OS X Server. There is a known conflict between the cvs2svn and dbm libraries that come pre-installed with OS X. The error is:</p>
<blockquote>
<p>ERROR: cvs2svn uses the anydbm package, which depends on lower level d... | 3 | 2009-07-27T20:24:55Z | 1,191,095 | <p>cvs2svn itself is available in MacPorts so, instead of just the dbm libraries, you could install cvs2svn using MacPorts:</p>
<pre><code>port install cvs2svn
</code></pre>
<p>If not already installed, it will also install the MacPorts version of python2.5 and other dependencies. There's no harm in that but it will... | 3 | 2009-07-27T22:56:40Z | [
"python",
"osx",
"xserver",
"cvs2svn",
"gdbm"
] |
Alternative to cvs2svn for performing cvs to svn migration | 1,190,413 | <p>I am trying to perform a migration from cvs to svn on my our new XServe server which is running OS X Server. There is a known conflict between the cvs2svn and dbm libraries that come pre-installed with OS X. The error is:</p>
<blockquote>
<p>ERROR: cvs2svn uses the anydbm package, which depends on lower level d... | 3 | 2009-07-27T20:24:55Z | 11,745,542 | <p>If you already have subversion installed , Did you make sure that the path is set right in your system variables?</p>
<p>I had that same issue on mine and I ended up having to add the variables in Python_Home and path to use </p>
<p>C:\Pyton27\ </p>
| 1 | 2012-07-31T17:15:54Z | [
"python",
"osx",
"xserver",
"cvs2svn",
"gdbm"
] |
Executing current Python script in Emacs on Windows | 1,190,595 | <p>I've just started learning Emacs, and decided to start writing Python in it. I tried using C-c C-c to execute the current buffer, but I get the message <code>Searching for program: no such file or directory, python</code>.</p>
<p>I've looked on google, but I'm none the wiser as to how to sort this out (bear in mind... | 3 | 2009-07-27T21:04:09Z | 1,190,812 | <p>I managed to work it out, following the instructions <a href="http://www.emacswiki.org/emacs/PythonMode" rel="nofollow">here</a>. I used python-mode.el, when before I had been using Emacs' built-in python.el, but according to <a href="http://www.emacswiki.org/emacs/PythonMode" rel="nofollow">emacswiki</a>, "The vers... | 3 | 2009-07-27T21:43:22Z | [
"python",
"emacs"
] |
Executing current Python script in Emacs on Windows | 1,190,595 | <p>I've just started learning Emacs, and decided to start writing Python in it. I tried using C-c C-c to execute the current buffer, but I get the message <code>Searching for program: no such file or directory, python</code>.</p>
<p>I've looked on google, but I'm none the wiser as to how to sort this out (bear in mind... | 3 | 2009-07-27T21:04:09Z | 1,191,489 | <p>Try adding <code>C:\Python26</code> (or whatever Python you have installed) to the <code>PATH</code> environment variable. </p>
<p>I find <a href="http://www.emacswiki.org/emacs/PythonMode" rel="nofollow">python-mode</a> and <a href="http://code.google.com/p/yasnippet/" rel="nofollow">yasnippet</a> to be useful for... | 2 | 2009-07-28T01:24:26Z | [
"python",
"emacs"
] |
Django FileField with upload_to determined at runtime | 1,190,697 | <p>I'm trying to set up my uploads so that if user joe uploads a file it goes to MEDIA_ROOT/joe as opposed to having everyone's files go to MEDIA_ROOT. The problem is I don't know how to define this in the model. Here is how it currently looks:</p>
<pre><code>class Content(models.Model):
name = models.CharField(ma... | 110 | 2009-07-27T21:22:38Z | 1,190,866 | <p>You've probably read <a href="http://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.FileField.upload%5Fto">the documentation</a>, so here's an easy example to make it make sense:</p>
<pre><code>def content_file_name(instance, filename):
return '/'.join(['content', instance.user.username, file... | 225 | 2009-07-27T21:56:18Z | [
"python",
"django",
"django-models"
] |
Django FileField with upload_to determined at runtime | 1,190,697 | <p>I'm trying to set up my uploads so that if user joe uploads a file it goes to MEDIA_ROOT/joe as opposed to having everyone's files go to MEDIA_ROOT. The problem is I don't know how to define this in the model. Here is how it currently looks:</p>
<pre><code>class Content(models.Model):
name = models.CharField(ma... | 110 | 2009-07-27T21:22:38Z | 21,841,322 | <p>This really helped. For a bit more brevity's sake, decided to use lambda in my case:</p>
<pre><code>file = models.FileField(
upload_to=lambda instance, filename: '/'.join(['mymodel', str(instance.pk), filename]),
)
</code></pre>
| 8 | 2014-02-17T23:23:23Z | [
"python",
"django",
"django-models"
] |
Automatically Generated Python Code from an UML diagram? | 1,190,854 | <p><em>The question is not the same as <a href="http://stackoverflow.com/questions/260165/whats-the-best-way-to-generate-a-uml-diagram-from-python-source-code">Whatâs the best way to generate a UML diagram from Python source code?</a>, but the other way around.</em></p>
<p><a href="http://www.topcoder.com/tc?module=... | 15 | 2009-07-27T21:53:05Z | 1,190,892 | <ul>
<li><a href="http://sourceforge.net/projects/eclipse-pyuml/">PyUML</a> - a Python Roundtrip Tool for Eclipse</li>
<li><a href="http://sourceforge.net/projects/pyidea/">PyIdea</a>: PyNSource UML & Patterns IDE for Python</li>
</ul>
| 6 | 2009-07-27T22:00:14Z | [
"python",
"uml"
] |
Automatically Generated Python Code from an UML diagram? | 1,190,854 | <p><em>The question is not the same as <a href="http://stackoverflow.com/questions/260165/whats-the-best-way-to-generate-a-uml-diagram-from-python-source-code">Whatâs the best way to generate a UML diagram from Python source code?</a>, but the other way around.</em></p>
<p><a href="http://www.topcoder.com/tc?module=... | 15 | 2009-07-27T21:53:05Z | 1,190,899 | <p>Some tools:</p>
<ul>
<li><a href="http://gaphor.devjavu.com/" rel="nofollow">Gaphor</a></li>
<li><a href="http://eclipse-pyuml.sourceforge.net/" rel="nofollow">pyUML for Eclipse</a></li>
<li><a href="http://www.andypatterns.com/index.php?cID=65" rel="nofollow">pyNSource</a></li>
</ul>
| 0 | 2009-07-27T22:02:05Z | [
"python",
"uml"
] |
Automatically Generated Python Code from an UML diagram? | 1,190,854 | <p><em>The question is not the same as <a href="http://stackoverflow.com/questions/260165/whats-the-best-way-to-generate-a-uml-diagram-from-python-source-code">Whatâs the best way to generate a UML diagram from Python source code?</a>, but the other way around.</em></p>
<p><a href="http://www.topcoder.com/tc?module=... | 15 | 2009-07-27T21:53:05Z | 1,190,901 | <p>The <a href="http://uml.sourceforge.net/" rel="nofollow">Umbrello</a> UML modeller for KDE support Python as an export language.</p>
| 2 | 2009-07-27T22:02:25Z | [
"python",
"uml"
] |
Automatically Generated Python Code from an UML diagram? | 1,190,854 | <p><em>The question is not the same as <a href="http://stackoverflow.com/questions/260165/whats-the-best-way-to-generate-a-uml-diagram-from-python-source-code">Whatâs the best way to generate a UML diagram from Python source code?</a>, but the other way around.</em></p>
<p><a href="http://www.topcoder.com/tc?module=... | 15 | 2009-07-27T21:53:05Z | 1,191,770 | <p>Search with Ubuntu found:</p>
<pre><code>$ apt-cache search python uml
boa-constructor - RAD tool for Python and WxWindows application
dia2code - a dia-UML code generator
spe - Stani's Python Editor
</code></pre>
<p>Quick testing revealed that DIA is the only program, where you can export your UML diagram to Pytho... | 0 | 2009-07-28T03:18:14Z | [
"python",
"uml"
] |
Automatically Generated Python Code from an UML diagram? | 1,190,854 | <p><em>The question is not the same as <a href="http://stackoverflow.com/questions/260165/whats-the-best-way-to-generate-a-uml-diagram-from-python-source-code">Whatâs the best way to generate a UML diagram from Python source code?</a>, but the other way around.</em></p>
<p><a href="http://www.topcoder.com/tc?module=... | 15 | 2009-07-27T21:53:05Z | 1,194,326 | <p><a href="http://www.sparxsystems.com.au/products/ea/index.html">Enterprise Architect</a> is able to generate python code code from UML diagrams.<br />
It is also able to also perform some reverse engineering, and therefore maintain the two versions (UML and python) synchronized together.</p>
<p>However, I have neve... | 9 | 2009-07-28T14:05:48Z | [
"python",
"uml"
] |
Automatically Generated Python Code from an UML diagram? | 1,190,854 | <p><em>The question is not the same as <a href="http://stackoverflow.com/questions/260165/whats-the-best-way-to-generate-a-uml-diagram-from-python-source-code">Whatâs the best way to generate a UML diagram from Python source code?</a>, but the other way around.</em></p>
<p><a href="http://www.topcoder.com/tc?module=... | 15 | 2009-07-27T21:53:05Z | 12,913,301 | <p>You can use DIA, and then install dia2code, it will generate from UML to code in python. I use it in PHP5 and Java.</p>
<pre><code>$ sudo apt-get install dia dia2code
</code></pre>
| 4 | 2012-10-16T11:04:46Z | [
"python",
"uml"
] |
How do you reload your Python source into the console window in Eclipse/Pydev? | 1,191,018 | <p>In other Python IDEs (PythonWin and Idle) it's possible to hit a key and have your current source file window reloaded into the console. I find this useful when experimenting with a piece of code; you can call functions from the console interactively and inspect data structures there.</p>
<p>Is there a way to do t... | 10 | 2009-07-27T22:28:35Z | 1,209,767 | <p>Use the revert option on the File menu.</p>
<p>You can bind a key to it in Windows > Preferences > General > Keys.</p>
<p>Edit:</p>
<p>The reload(module) function will update packages in the interactive console. It's built in for python 2.x and in the imp module for 3.x.
Python docs link: <a href="http://docs.py... | 1 | 2009-07-30T22:31:52Z | [
"python",
"pydev"
] |
How do you reload your Python source into the console window in Eclipse/Pydev? | 1,191,018 | <p>In other Python IDEs (PythonWin and Idle) it's possible to hit a key and have your current source file window reloaded into the console. I find this useful when experimenting with a piece of code; you can call functions from the console interactively and inspect data structures there.</p>
<p>Is there a way to do t... | 10 | 2009-07-27T22:28:35Z | 2,017,129 | <p>You can do it with <kbd>Ctrl</kbd>+<kbd>Alt</kbd>+<kbd>Enter</kbd> on the latest <a href="http://pydev.org/manual_adv_interactive_console.html" rel="nofollow">Pydev</a> for details on what <kbd>Ctrl</kbd>+<kbd>Alt</kbd>+<kbd>Enter</kbd> provides as it can do a number of things related to the interactive console.</p>... | 7 | 2010-01-06T23:27:46Z | [
"python",
"pydev"
] |
What's the best way to optimize this MySQL query? | 1,191,105 | <p><strong>This is a query that totals up every players game results from a game and displays the players who match the conditions.</strong> </p>
<pre><code>select *,
(kills / deaths) as killdeathratio,
(totgames - wins) as losses
from (select gp.name as name,
... | 1 | 2009-07-27T23:00:39Z | 1,191,257 | <p>First of all, the SQL is badly formatted. The most obvious error is the line splitting before each <code>AS</code> clause. Second obvious problem is using implicit joins instead of explicitly using <code>INNER JOIN ... ON ...</code>.</p>
<p>Now to answer the actual question. </p>
<p>Without knowing the data or the... | 2 | 2009-07-27T23:53:20Z | [
"python",
"mysql",
"django",
"performance"
] |
What's the best way to optimize this MySQL query? | 1,191,105 | <p><strong>This is a query that totals up every players game results from a game and displays the players who match the conditions.</strong> </p>
<pre><code>select *,
(kills / deaths) as killdeathratio,
(totgames - wins) as losses
from (select gp.name as name,
... | 1 | 2009-07-27T23:00:39Z | 1,191,304 | <p>No index will help you since you are scanning entire tables.
As your database grows the query will always get slower.</p>
<p>Consider accumulating the stats : after every game, insert the row for that game, and also increment counters in the player's row, Then you don't need to count() and sum() because the inform... | 0 | 2009-07-28T00:09:24Z | [
"python",
"mysql",
"django",
"performance"
] |
What's the best way to optimize this MySQL query? | 1,191,105 | <p><strong>This is a query that totals up every players game results from a game and displays the players who match the conditions.</strong> </p>
<pre><code>select *,
(kills / deaths) as killdeathratio,
(totgames - wins) as losses
from (select gp.name as name,
... | 1 | 2009-07-27T23:00:39Z | 1,191,357 | <ul>
<li>select * is bad most times - select only the columns you need</li>
<li>break the select into multiple simple selects, use temporary tables when needed</li>
<li>the sum(case part could be done with a subselect</li>
<li>mysql has a very bad performance with or-expressions. use two selects which you union togeth... | 0 | 2009-07-28T00:34:25Z | [
"python",
"mysql",
"django",
"performance"
] |
What's the best way to optimize this MySQL query? | 1,191,105 | <p><strong>This is a query that totals up every players game results from a game and displays the players who match the conditions.</strong> </p>
<pre><code>select *,
(kills / deaths) as killdeathratio,
(totgames - wins) as losses
from (select gp.name as name,
... | 1 | 2009-07-27T23:00:39Z | 25,435,283 | <p><strong>Small Improvement</strong></p>
<p><code>select *,
(kills / deaths) as killdeathratio,
(totgames - wins) as losses from (select gp.name as name,
gp.gameid as gameid,
gp.colour as colour,
... | 0 | 2014-08-21T20:22:11Z | [
"python",
"mysql",
"django",
"performance"
] |
Hosting Mercurial with IIS 6 | 1,191,136 | <p>I'm trying to set up Mercurial repositories to be hosted by IIS under Windows Server 2003. Following <a href="http://stackoverflow.com/questions/818571/how-to-setup-mercurial-and-hgwebdir-on-iis">this post</a> I installed Python 2.5.4.4 and Mercurial 1.3, set up virtual dir, extracted library.zip and created hgwebdi... | 15 | 2009-07-27T23:10:22Z | 1,226,954 | <p>Finally I got that "no headers" error returned on any python script error, so I checked script with console interpreter and fixed errors in my config file. And of course I should ask this question at ServerFault instead of StackOverflow - the lack of sleep did the job :) </p>
| 1 | 2009-08-04T11:31:36Z | [
"python",
"iis-6",
"mercurial"
] |
Hosting Mercurial with IIS 6 | 1,191,136 | <p>I'm trying to set up Mercurial repositories to be hosted by IIS under Windows Server 2003. Following <a href="http://stackoverflow.com/questions/818571/how-to-setup-mercurial-and-hgwebdir-on-iis">this post</a> I installed Python 2.5.4.4 and Mercurial 1.3, set up virtual dir, extracted library.zip and created hgwebdi... | 15 | 2009-07-27T23:10:22Z | 3,320,927 | <p>There's a pretty good post at <a href="http://vampirebasic.blogspot.com/2009/06/running-mercurial-on-windows.html" rel="nofollow">http://vampirebasic.blogspot.com/2009/06/running-mercurial-on-windows.html</a> that'll get you started, but if you need more detail or to go further than the writer did, I've got a 4 part... | 1 | 2010-07-23T17:47:29Z | [
"python",
"iis-6",
"mercurial"
] |
Hosting Mercurial with IIS 6 | 1,191,136 | <p>I'm trying to set up Mercurial repositories to be hosted by IIS under Windows Server 2003. Following <a href="http://stackoverflow.com/questions/818571/how-to-setup-mercurial-and-hgwebdir-on-iis">this post</a> I installed Python 2.5.4.4 and Mercurial 1.3, set up virtual dir, extracted library.zip and created hgwebdi... | 15 | 2009-07-27T23:10:22Z | 3,472,292 | <p>Some more things that I needed to fix:</p>
<ul>
<li>Where the various HOWTOs say to use <code>c:\whatever\Python26\python.exe -u "%s" "%s"</code> instead use <code>c:\whatever\Python26\python.exe -u -O -B "%s" "%s"</code> -O causes it to also look for .pyo files (not just .py or .pyc, which at least in my version ... | 5 | 2010-08-12T21:42:33Z | [
"python",
"iis-6",
"mercurial"
] |
Hosting Mercurial with IIS 6 | 1,191,136 | <p>I'm trying to set up Mercurial repositories to be hosted by IIS under Windows Server 2003. Following <a href="http://stackoverflow.com/questions/818571/how-to-setup-mercurial-and-hgwebdir-on-iis">this post</a> I installed Python 2.5.4.4 and Mercurial 1.3, set up virtual dir, extracted library.zip and created hgwebdi... | 15 | 2009-07-27T23:10:22Z | 4,803,131 | <p>In my situation, this error caused by line <code>application = hgwebdir('c:\somewhere\hgweb.config')</code> in hgweb.cgi, it should be <code>application = hgweb('c:\somewhere\hgweb.config')</code>. </p>
<p>Besides, uncomment line <code>import cgitb; cgitb.enable()</code> in hgweb.cgi will give you more info about ... | 1 | 2011-01-26T09:47:10Z | [
"python",
"iis-6",
"mercurial"
] |
Hosting Mercurial with IIS 6 | 1,191,136 | <p>I'm trying to set up Mercurial repositories to be hosted by IIS under Windows Server 2003. Following <a href="http://stackoverflow.com/questions/818571/how-to-setup-mercurial-and-hgwebdir-on-iis">this post</a> I installed Python 2.5.4.4 and Mercurial 1.3, set up virtual dir, extracted library.zip and created hgwebdi... | 15 | 2009-07-27T23:10:22Z | 5,032,628 | <p>In my case, the critical step that fixed it was using: c:\whatever\Python26\python.exe -u -O -B "%s" "%s</p>
<p>Before that it was not working with the error: </p>
<pre><code>A problem occurred in a Python script. Here is the sequence of function calls leading up to the error, in the order they occurred.
c:\hg\h... | 1 | 2011-02-17T17:52:12Z | [
"python",
"iis-6",
"mercurial"
] |
Bind event to wx.Menu() instead of to the menu item in wxPython | 1,191,221 | <p>My problem can be easily defined with the following code:</p>
<pre><code>self.Bind(wx.EVT_MENU_OPEN, self.OnAbout)
</code></pre>
<p>This will mean that when I click on any wx.Menu() in the MenuBar, the function 'onAbout()' is called. How do I bind this event to a specific wx.Menu() which is called wx.MenuAbout() ?... | 1 | 2009-07-27T23:39:46Z | 1,191,710 | <p>Why don't you just bind to the menu items using <code>EVT_MENU</code> instead?</p>
<p><code>EVT_MENU_OPEN</code> will fire as soon as any menu is opened. That being said, if that's what you really want, you can always do this:</p>
<p>Where you define your menu:</p>
<pre><code>self.about_menu = wx.Menu() # or wha... | 5 | 2009-07-28T02:55:50Z | [
"python",
"wxpython"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.