title stringlengths 10 172 | question_id int64 469 40.1M | question_body stringlengths 22 48.2k | question_score int64 -44 5.52k | question_date stringlengths 20 20 | answer_id int64 497 40.1M | answer_body stringlengths 18 33.9k | answer_score int64 -38 8.38k | answer_date stringlengths 20 20 | tags list |
|---|---|---|---|---|---|---|---|---|---|
Django or CodeIgniter for Turn-Key Web Application | 690,856 | <p>I'm going to build a turn-key solution for a vertical market, and would like to offer both options: software as a service, and give them the opportunity to host the application on their own. In other words, I'm aiming to have similar deployment options as Joel's FogBugz.</p>
<p>I'm a Python programmer, and I could ... | 8 | 2009-03-27T18:05:22Z | 691,231 | <p>Deployment is clearly a problem for all non-PHP based web apps, but I think things are getting better with the DreamHost/Engineyard type ISP's who provide Ruby/Python etc. out of the box. It also looks like there's going to be a lot of discussion at PyCon this week about ways to fix deployment problems. The growth... | 4 | 2009-03-27T19:46:19Z | [
"php",
"python",
"django",
"codeigniter"
] |
Django or CodeIgniter for Turn-Key Web Application | 690,856 | <p>I'm going to build a turn-key solution for a vertical market, and would like to offer both options: software as a service, and give them the opportunity to host the application on their own. In other words, I'm aiming to have similar deployment options as Joel's FogBugz.</p>
<p>I'm a Python programmer, and I could ... | 8 | 2009-03-27T18:05:22Z | 691,549 | <p>If you want your application to be mainstream then your almost forced to go with PHP. Going from Django to PHP is alot easier than going from PHP to Django. You know the standards, you just need to learn the PHP syntax and functions.</p>
<p>I would definitely use a PHP framework. Symfony and akelos are very similar... | 3 | 2009-03-27T21:34:50Z | [
"php",
"python",
"django",
"codeigniter"
] |
Django or CodeIgniter for Turn-Key Web Application | 690,856 | <p>I'm going to build a turn-key solution for a vertical market, and would like to offer both options: software as a service, and give them the opportunity to host the application on their own. In other words, I'm aiming to have similar deployment options as Joel's FogBugz.</p>
<p>I'm a Python programmer, and I could ... | 8 | 2009-03-27T18:05:22Z | 692,907 | <p>Based on your own conclusions, I would go with CodeIgniter. It seems like there would be a ton of work helping your customers install your web app, and I assume you don't want that.</p>
<p>Build a simple-to-install web app so that you can concentrate your efforts on making it better and selling it, instead of worki... | 2 | 2009-03-28T15:06:57Z | [
"php",
"python",
"django",
"codeigniter"
] |
How do you determine if an IP address is private, in Python? | 691,045 | <p>In Python, what is the best way to determine if an IP address (e.g., <code>'127.0.0.1'</code> or <code>'10.98.76.6'</code>) is on a <a href="http://en.wikipedia.org/wiki/Private%5Fnetwork">private network</a>? The code does not sound difficult to write. But there may be more edge cases than are immediately apparen... | 16 | 2009-03-27T18:51:53Z | 691,057 | <p>Check out the <a href="http://pypi.python.org/pypi/IPy/">IPy</a> module. If has a function <code>iptype()</code> that seems to do what you want:</p>
<pre><code>>>> from IPy import IP
>>> ip = IP('127.0.0.0/30')
>>> ip.iptype()
'PRIVATE'
</code></pre>
| 27 | 2009-03-27T18:55:23Z | [
"python",
"network-programming",
"ip-address"
] |
How do you determine if an IP address is private, in Python? | 691,045 | <p>In Python, what is the best way to determine if an IP address (e.g., <code>'127.0.0.1'</code> or <code>'10.98.76.6'</code>) is on a <a href="http://en.wikipedia.org/wiki/Private%5Fnetwork">private network</a>? The code does not sound difficult to write. But there may be more edge cases than are immediately apparen... | 16 | 2009-03-27T18:51:53Z | 692,457 | <p>If you want to avoid importing a module you can just apply a simple regex:</p>
<ul>
<li>^127.\d{123}.\d{123}.\d{123}$</li>
<li>^10.\d{123}.\d{123}.\d{123}$</li>
<li>^192.168.\d{123}$</li>
<li>^172.(1[6-9]|2[0-9]|3[0-1]).[0-9]{123}.[0-9]{123}$</li>
</ul>
| 2 | 2009-03-28T08:33:51Z | [
"python",
"network-programming",
"ip-address"
] |
How do you determine if an IP address is private, in Python? | 691,045 | <p>In Python, what is the best way to determine if an IP address (e.g., <code>'127.0.0.1'</code> or <code>'10.98.76.6'</code>) is on a <a href="http://en.wikipedia.org/wiki/Private%5Fnetwork">private network</a>? The code does not sound difficult to write. But there may be more edge cases than are immediately apparen... | 16 | 2009-03-27T18:51:53Z | 712,860 | <p>A few days after asking this question, I found out about this Google project, <a href="http://code.google.com/p/ipaddr-py/source/browse/trunk/ipaddr.py" rel="nofollow">ipaddr-py</a>, which appears to have some of the same functionality with respect to determining if an address is private (<code>is_rfc1918</code>). ... | 2 | 2009-04-03T07:23:27Z | [
"python",
"network-programming",
"ip-address"
] |
How do you determine if an IP address is private, in Python? | 691,045 | <p>In Python, what is the best way to determine if an IP address (e.g., <code>'127.0.0.1'</code> or <code>'10.98.76.6'</code>) is on a <a href="http://en.wikipedia.org/wiki/Private%5Fnetwork">private network</a>? The code does not sound difficult to write. But there may be more edge cases than are immediately apparen... | 16 | 2009-03-27T18:51:53Z | 8,339,939 | <p>You can check that yourself using
<a href="http://tools.ietf.org/html/rfc1918">http://tools.ietf.org/html/rfc1918</a> and <a href="http://tools.ietf.org/html/rfc3330">http://tools.ietf.org/html/rfc3330</a>. If you have 127.0.0.1 you just need to <code>&</code> it with the mask (lets say <code>255.0.0.0</code>) a... | 18 | 2011-12-01T10:36:41Z | [
"python",
"network-programming",
"ip-address"
] |
How do you determine if an IP address is private, in Python? | 691,045 | <p>In Python, what is the best way to determine if an IP address (e.g., <code>'127.0.0.1'</code> or <code>'10.98.76.6'</code>) is on a <a href="http://en.wikipedia.org/wiki/Private%5Fnetwork">private network</a>? The code does not sound difficult to write. But there may be more edge cases than are immediately apparen... | 16 | 2009-03-27T18:51:53Z | 28,532,296 | <p>This is the fixed version of the regex approach suggested by @Kurt including the fix recommended by @RobEvans</p>
<ul>
<li>^127.\d{1,3}.\d{1,3}.\d{1,3}$ </li>
<li>^10.\d{1,3}.\d{1,3}.\d{1,3}$</li>
<li>^192.168.\d{1,3}.\d{1,3}$</li>
<li><p>^172.(1[6-9]|2[0-9]|3[0-1]).[0-9]{1,3}.[0-9]{1,3}$</p>
<pre><code>def is_ip_... | 2 | 2015-02-15T23:03:15Z | [
"python",
"network-programming",
"ip-address"
] |
How do you determine if an IP address is private, in Python? | 691,045 | <p>In Python, what is the best way to determine if an IP address (e.g., <code>'127.0.0.1'</code> or <code>'10.98.76.6'</code>) is on a <a href="http://en.wikipedia.org/wiki/Private%5Fnetwork">private network</a>? The code does not sound difficult to write. But there may be more edge cases than are immediately apparen... | 16 | 2009-03-27T18:51:53Z | 31,036,423 | <p>Since Python 3.3 there is an <a href="https://docs.python.org/3/library/ipaddress.html">ipaddress module</a> in the stdlib that you can use.</p>
<pre><code>>>> import ipaddress
>>> ipaddress.ip_address('192.168.0.1').is_private
True
</code></pre>
<p>If using Python 2.6 or higher I would strongly ... | 11 | 2015-06-24T20:30:24Z | [
"python",
"network-programming",
"ip-address"
] |
How do you determine if an IP address is private, in Python? | 691,045 | <p>In Python, what is the best way to determine if an IP address (e.g., <code>'127.0.0.1'</code> or <code>'10.98.76.6'</code>) is on a <a href="http://en.wikipedia.org/wiki/Private%5Fnetwork">private network</a>? The code does not sound difficult to write. But there may be more edge cases than are immediately apparen... | 16 | 2009-03-27T18:51:53Z | 39,656,628 | <p>I find this in <a href="https://github.com/wmetcalf/cuckoo-master/blob/master/modules/processing/network.py" rel="nofollow">cuckoo</a>.There is no need to install new modules.Just import two built-in modules: socket and struct. And use function below.</p>
<pre><code>def _is_private_ip(self, ip):
"""Check if the... | 0 | 2016-09-23T08:53:01Z | [
"python",
"network-programming",
"ip-address"
] |
Pythonic way to implement a tokenizer | 691,148 | <p>I'm going to implement a tokenizer in Python and I was wondering if you could offer some style advice?</p>
<p>I've implemented a tokenizer before in C and in Java so I'm fine with the theory, I'd just like to ensure I'm following pythonic styles and best practices.</p>
<p>Listing Token Types:</p>
<p>In Java, for ... | 11 | 2009-03-27T19:20:43Z | 691,169 | <p>Python takes a "we're all consenting adults" approach to information hiding. It's OK to use variables as though they were constants, and trust that users of your code won't do something stupid. </p>
| 28 | 2009-03-27T19:24:07Z | [
"python",
"coding-style",
"tokenize"
] |
Pythonic way to implement a tokenizer | 691,148 | <p>I'm going to implement a tokenizer in Python and I was wondering if you could offer some style advice?</p>
<p>I've implemented a tokenizer before in C and in Java so I'm fine with the theory, I'd just like to ensure I'm following pythonic styles and best practices.</p>
<p>Listing Token Types:</p>
<p>In Java, for ... | 11 | 2009-03-27T19:20:43Z | 691,171 | <p>"Is there a better alternative to just simply returning a list of tuples?"</p>
<p>Nope. It works really well.</p>
| 4 | 2009-03-27T19:24:29Z | [
"python",
"coding-style",
"tokenize"
] |
Pythonic way to implement a tokenizer | 691,148 | <p>I'm going to implement a tokenizer in Python and I was wondering if you could offer some style advice?</p>
<p>I've implemented a tokenizer before in C and in Java so I'm fine with the theory, I'd just like to ensure I'm following pythonic styles and best practices.</p>
<p>Listing Token Types:</p>
<p>In Java, for ... | 11 | 2009-03-27T19:20:43Z | 691,187 | <p>"Is there a better alternative to just simply returning a list of tuples?"</p>
<p>That's the approach used by the "tokenize" module for parsing Python source code. Returning a simple list of tuples can work very well.</p>
| 2 | 2009-03-27T19:30:49Z | [
"python",
"coding-style",
"tokenize"
] |
Pythonic way to implement a tokenizer | 691,148 | <p>I'm going to implement a tokenizer in Python and I was wondering if you could offer some style advice?</p>
<p>I've implemented a tokenizer before in C and in Java so I'm fine with the theory, I'd just like to ensure I'm following pythonic styles and best practices.</p>
<p>Listing Token Types:</p>
<p>In Java, for ... | 11 | 2009-03-27T19:20:43Z | 691,230 | <p>In many situations, exp. when parsing long input streams, you may find it more useful to implement you tokenizer as a generator function. This way you can easily iterate over all the tokens without the need for lots of memory to build the list of tokens first.</p>
<p>For generator see the <a href="http://www.python... | 10 | 2009-03-27T19:45:28Z | [
"python",
"coding-style",
"tokenize"
] |
Pythonic way to implement a tokenizer | 691,148 | <p>I'm going to implement a tokenizer in Python and I was wondering if you could offer some style advice?</p>
<p>I've implemented a tokenizer before in C and in Java so I'm fine with the theory, I'd just like to ensure I'm following pythonic styles and best practices.</p>
<p>Listing Token Types:</p>
<p>In Java, for ... | 11 | 2009-03-27T19:20:43Z | 691,271 | <p>"Is there a better alternative to just simply returning a list of tuples"</p>
<p>I had to implement a tokenizer, but it required a more complex approach than a list of tuples, therefore I implemented a class for each token. You can then return a list of class instances, or if you want to save resources, you can ret... | 0 | 2009-03-27T19:56:48Z | [
"python",
"coding-style",
"tokenize"
] |
Pythonic way to implement a tokenizer | 691,148 | <p>I'm going to implement a tokenizer in Python and I was wondering if you could offer some style advice?</p>
<p>I've implemented a tokenizer before in C and in Java so I'm fine with the theory, I'd just like to ensure I'm following pythonic styles and best practices.</p>
<p>Listing Token Types:</p>
<p>In Java, for ... | 11 | 2009-03-27T19:20:43Z | 691,591 | <p>Thanks for your help, I've started to bring these ideas together, and I've come up with the following. Is there anything terribly wrong with this implementation (particularly I'm concerned about passing a file object to the tokenizer):</p>
<pre><code>class Tokenizer(object):
def __init__(self,file):
self.fi... | 7 | 2009-03-27T21:48:18Z | [
"python",
"coding-style",
"tokenize"
] |
Pythonic way to implement a tokenizer | 691,148 | <p>I'm going to implement a tokenizer in Python and I was wondering if you could offer some style advice?</p>
<p>I've implemented a tokenizer before in C and in Java so I'm fine with the theory, I'd just like to ensure I'm following pythonic styles and best practices.</p>
<p>Listing Token Types:</p>
<p>In Java, for ... | 11 | 2009-03-27T19:20:43Z | 691,963 | <p>I have recently built a tokenizer, too, and passed through some of your issues.</p>
<p>Token types are declared as "constants", i.e. variables with ALL_CAPS names, at the module level. For example,</p>
<pre><code>_INTEGER = 0x0007
_FLOAT = 0x0008
_VARIABLE = 0x0009
</code></pre>
<p>and so on. I have used an under... | 2 | 2009-03-28T01:20:48Z | [
"python",
"coding-style",
"tokenize"
] |
Pythonic way to implement a tokenizer | 691,148 | <p>I'm going to implement a tokenizer in Python and I was wondering if you could offer some style advice?</p>
<p>I've implemented a tokenizer before in C and in Java so I'm fine with the theory, I'd just like to ensure I'm following pythonic styles and best practices.</p>
<p>Listing Token Types:</p>
<p>In Java, for ... | 11 | 2009-03-27T19:20:43Z | 692,432 | <p>When I start something new in Python I usually look first at some modules or libraries to use. There's 90%+ chance that there already is somthing available.</p>
<p>For tokenizers and parsers this is certainly so. Have you looked at <a href="http://pyparsing.wikispaces.com/" rel="nofollow">PyParsing</a> ?</p>
| 1 | 2009-03-28T08:16:06Z | [
"python",
"coding-style",
"tokenize"
] |
Pythonic way to implement a tokenizer | 691,148 | <p>I'm going to implement a tokenizer in Python and I was wondering if you could offer some style advice?</p>
<p>I've implemented a tokenizer before in C and in Java so I'm fine with the theory, I'd just like to ensure I'm following pythonic styles and best practices.</p>
<p>Listing Token Types:</p>
<p>In Java, for ... | 11 | 2009-03-27T19:20:43Z | 693,818 | <p>There's an undocumented class in the <code>re</code> module called <code>re.Scanner</code>. It's very straightforward to use for a tokenizer:</p>
<pre><code>import re
scanner=re.Scanner([
(r"[0-9]+", lambda scanner,token:("INTEGER", token)),
(r"[a-z_]+", lambda scanner,token:("IDENTIFIER", token)),
(r"[,... | 46 | 2009-03-29T00:01:04Z | [
"python",
"coding-style",
"tokenize"
] |
Pythonic way to implement a tokenizer | 691,148 | <p>I'm going to implement a tokenizer in Python and I was wondering if you could offer some style advice?</p>
<p>I've implemented a tokenizer before in C and in Java so I'm fine with the theory, I'd just like to ensure I'm following pythonic styles and best practices.</p>
<p>Listing Token Types:</p>
<p>In Java, for ... | 11 | 2009-03-27T19:20:43Z | 1,176,838 | <p>I've implemented a tokenizer for a C-like programming language. What I did was to split up the creation of tokens into two layers:</p>
<ul>
<li>a <em>surface scanner</em>: This one actually reads the text and uses regular expression to split it up into only the most primitve tokens (operators, identifiers, numbers,... | 1 | 2009-07-24T10:28:01Z | [
"python",
"coding-style",
"tokenize"
] |
Pythonic way to implement a tokenizer | 691,148 | <p>I'm going to implement a tokenizer in Python and I was wondering if you could offer some style advice?</p>
<p>I've implemented a tokenizer before in C and in Java so I'm fine with the theory, I'd just like to ensure I'm following pythonic styles and best practices.</p>
<p>Listing Token Types:</p>
<p>In Java, for ... | 11 | 2009-03-27T19:20:43Z | 1,176,867 | <p>I'd turn to the excellent <em><a href="http://books.google.com/books?id=GxKWdn7u4w8C" rel="nofollow">Text Processing in Python</a></em> by David Mertz</p>
| 2 | 2009-07-24T10:36:27Z | [
"python",
"coding-style",
"tokenize"
] |
Pythonic way to implement a tokenizer | 691,148 | <p>I'm going to implement a tokenizer in Python and I was wondering if you could offer some style advice?</p>
<p>I've implemented a tokenizer before in C and in Java so I'm fine with the theory, I'd just like to ensure I'm following pythonic styles and best practices.</p>
<p>Listing Token Types:</p>
<p>In Java, for ... | 11 | 2009-03-27T19:20:43Z | 16,143,071 | <p>This being a late answer, there is now something in the official documentation: <a href="http://docs.python.org/3.2/library/re.html#writing-a-tokenizer" rel="nofollow">Writing a tokenizer</a> with the <code>re</code> standard library. This is content in the Python 3 documentation that isn't in the Py 2.7 docs. But i... | 1 | 2013-04-22T08:57:53Z | [
"python",
"coding-style",
"tokenize"
] |
How do I order referenced objects from a Google App Engine Datastore query? | 691,217 | <p>I have <code>Exhibit</code> objects which reference <code>Gallery</code> objects both of which are stored in the Google App Engine Datastore.</p>
<p>How do I order the <code>Exhibit</code> collection on each <code>Gallery</code> object when I get around to iterating over the values (ultimately in a Django template)... | 3 | 2009-03-27T19:40:03Z | 691,556 | <p>Instead of relying on the collection property App Engine creates, you need to construct your own query:</p>
<blockquote>
<p>exhibits = Exhibit.all().filter("gallery =", gallery).order("position")</p>
</blockquote>
<p>Or equivalently, in GQL:</p>
<blockquote>
<p>exhibits = db.GqlQuery("SELECT * FROM Exhibit WH... | 4 | 2009-03-27T21:36:18Z | [
"python",
"google-app-engine",
"gae-datastore"
] |
Passing functions which have multiple return values as arguments in Python | 691,267 | <p>So, Python functions can return multiple values. It struck me that it would be convenient (though a bit less readable) if the following were possible.</p>
<pre><code>a = [[1,2],[3,4]]
def cord():
return 1, 1
def printa(y,x):
print a[y][x]
printa(cord())
</code></pre>
<p>...but it's not. I'm aware that y... | 9 | 2009-03-27T19:55:29Z | 691,274 | <pre><code>printa(*cord())
</code></pre>
<p>The <code>*</code> here is an argument expansion operator... well I forget what it's technically called, but in this context it takes a list or tuple and expands it out so the function sees each list/tuple element as a separate argument.</p>
<p>It's basically the reverse of... | 17 | 2009-03-27T19:56:57Z | [
"python",
"return-value",
"function-calls"
] |
Passing functions which have multiple return values as arguments in Python | 691,267 | <p>So, Python functions can return multiple values. It struck me that it would be convenient (though a bit less readable) if the following were possible.</p>
<pre><code>a = [[1,2],[3,4]]
def cord():
return 1, 1
def printa(y,x):
print a[y][x]
printa(cord())
</code></pre>
<p>...but it's not. I'm aware that y... | 9 | 2009-03-27T19:55:29Z | 691,280 | <p>Try this:</p>
<pre><code>>>> def cord():
... return (1, 1)
...
>>> def printa(y, x):
... print a[y][x]
...
>>> a=[[1,2],[3,4]]
>>> printa(*cord())
4
</code></pre>
<p>The star basically says "use the elements of this collection as positional arguments." You can do the sa... | 6 | 2009-03-27T19:58:47Z | [
"python",
"return-value",
"function-calls"
] |
Passing functions which have multiple return values as arguments in Python | 691,267 | <p>So, Python functions can return multiple values. It struck me that it would be convenient (though a bit less readable) if the following were possible.</p>
<pre><code>a = [[1,2],[3,4]]
def cord():
return 1, 1
def printa(y,x):
print a[y][x]
printa(cord())
</code></pre>
<p>...but it's not. I'm aware that y... | 9 | 2009-03-27T19:55:29Z | 691,744 | <p>Actually, Python doesn't really return multiple values, it returns one value which can be multiple values packed into a tuple. Which means that you need to "unpack" the returned value in order to have multiples.
A statement like </p>
<pre><code>x,y = cord()
</code></pre>
<p>does that, but directly using the return... | 2 | 2009-03-27T22:56:10Z | [
"python",
"return-value",
"function-calls"
] |
Python: Retrieve Image from MSSQL | 691,288 | <p>Dear All,
I'm working on a Python project that retrieves an image from MSSQL. My code is able to retrieve the images successfully but with a fixed size of 63KB. if the image is greater than that size, it just brings the first 63KB from the image!</p>
<p>The following is my code:</p>
<pre><code>#!/usr/bin/python
im... | 2 | 2009-03-27T20:03:56Z | 692,031 | <p>It's kind of hard to tell what the problem is when you're using a database like this. Your query isn't explicitly selecting any columns, so we have no idea what your table structure is, or what types the columns are. I suspect the table format is not what you're expecting, or the columntype is incorrect for your dat... | 1 | 2009-03-28T02:15:14Z | [
"python",
"sql-server",
"file-io"
] |
Python: Retrieve Image from MSSQL | 691,288 | <p>Dear All,
I'm working on a Python project that retrieves an image from MSSQL. My code is able to retrieve the images successfully but with a fixed size of 63KB. if the image is greater than that size, it just brings the first 63KB from the image!</p>
<p>The following is my code:</p>
<pre><code>#!/usr/bin/python
im... | 2 | 2009-03-27T20:03:56Z | 2,490,838 | <p>If your using freetds (I think you are): Search in your freetds.conf for the 'text size' setting.. standard its at 63 kb</p>
| 0 | 2010-03-22T08:44:38Z | [
"python",
"sql-server",
"file-io"
] |
Handling output of python socket recv | 691,345 | <p>Apologies for the noob Python question but I've been stuck on this for far too long.</p>
<p>I'm using python sockets to receive some data from a server. I do this:</p>
<pre><code>
data = self.socket.recv(4)
print "data is ", data
print "repr(data) is ", repr(data)
</code></pre>
<p>The output on the console is thi... | 3 | 2009-03-27T20:26:51Z | 691,365 | <p>You probably want to use <a href="http://docs.python.org/library/struct.html#module-struct" rel="nofollow">struct</a>.</p>
<p>The code would look something like:</p>
<pre><code>import struct
data = self.socket.recv(4)
print "data is ", data
print "repr(data) is ", repr(data)
myint = struct.unpack("!i", data)[0]
<... | 8 | 2009-03-27T20:32:52Z | [
"python",
"sockets"
] |
Is there a method in python that's like os.path.split for other delimiters? | 691,740 | <p>I want to use something like this:</p>
<pre><code>os.path.split("C:\\a\\b\\c")
</code></pre>
<p>With this kind of output:</p>
<p>('C:\a\b', 'c')</p>
<p><hr /></p>
<p>However I want it to work on other delimiters like this:</p>
<pre><code>method ('a_b_c_d')
</code></pre>
<p>With this kind of output:</p>
<p>('... | 0 | 2009-03-27T22:55:11Z | 691,748 | <pre><code>>>> 'a_b_c_d'.rsplit('_', 1)
['a_b_c', 'd']
</code></pre>
<blockquote>
<p>Help on built-in function rsplit:</p>
<p>rsplit(...)
<code>S.rsplit([sep [,maxsplit]])</code> -> list of strings</p>
<p>Return a list of the words in the string S, using sep as the
delimiter string, starting a... | 15 | 2009-03-27T22:56:46Z | [
"python",
"string"
] |
Is there a method in python that's like os.path.split for other delimiters? | 691,740 | <p>I want to use something like this:</p>
<pre><code>os.path.split("C:\\a\\b\\c")
</code></pre>
<p>With this kind of output:</p>
<p>('C:\a\b', 'c')</p>
<p><hr /></p>
<p>However I want it to work on other delimiters like this:</p>
<pre><code>method ('a_b_c_d')
</code></pre>
<p>With this kind of output:</p>
<p>('... | 0 | 2009-03-27T22:55:11Z | 691,753 | <pre><code>string.split(separator)
</code></pre>
| 0 | 2009-03-27T22:58:18Z | [
"python",
"string"
] |
Is it bad form to call a classmethod as a method from an instance? | 692,040 | <p>Ex.</p>
<p>If I have something like this:</p>
<pre><code>class C(object):
@classmethod
def f(cls, x):
return x + x
</code></pre>
<p>This will work:</p>
<pre><code>c = C()
c.f(2)
4
</code></pre>
<p>But is that bad form?
Should I only call</p>
<pre><code>C.f()
</code></pre>
<p>or </p>
<pre><cod... | 20 | 2009-03-28T02:21:05Z | 692,054 | <p>It's mainly just confusing looking. If I were using your class and saw this, it would make me wonder what other surprises are in there, it just looks like bad design.</p>
<p>Is there a reason it's not just a staticmethod?</p>
| 3 | 2009-03-28T02:29:35Z | [
"python",
"class-method"
] |
Is it bad form to call a classmethod as a method from an instance? | 692,040 | <p>Ex.</p>
<p>If I have something like this:</p>
<pre><code>class C(object):
@classmethod
def f(cls, x):
return x + x
</code></pre>
<p>This will work:</p>
<pre><code>c = C()
c.f(2)
4
</code></pre>
<p>But is that bad form?
Should I only call</p>
<pre><code>C.f()
</code></pre>
<p>or </p>
<pre><cod... | 20 | 2009-03-28T02:21:05Z | 692,057 | <p><code>C.f()</code> is clearer than <code>c_instance.f()</code>, and <code>c_instance.__class__.f()</code> is just ugly. Since clarity and beauty are dearly loved characteristics in the python community, I'd tend to say that C.f() is the best route. </p>
<p>Is there any particular reason you even want to call it in ... | 1 | 2009-03-28T02:31:12Z | [
"python",
"class-method"
] |
Is it bad form to call a classmethod as a method from an instance? | 692,040 | <p>Ex.</p>
<p>If I have something like this:</p>
<pre><code>class C(object):
@classmethod
def f(cls, x):
return x + x
</code></pre>
<p>This will work:</p>
<pre><code>c = C()
c.f(2)
4
</code></pre>
<p>But is that bad form?
Should I only call</p>
<pre><code>C.f()
</code></pre>
<p>or </p>
<pre><cod... | 20 | 2009-03-28T02:21:05Z | 692,072 | <p>If you have an instance of C already, why do you need f() to be a class method? Not only is it bad form, its usually not necessary. Someone on the net says: "This is bad because it creates the impression that some instance variables in the object are used, but this isn't the case."</p>
<p>Although, page 484 of <a... | 2 | 2009-03-28T02:41:35Z | [
"python",
"class-method"
] |
Is it bad form to call a classmethod as a method from an instance? | 692,040 | <p>Ex.</p>
<p>If I have something like this:</p>
<pre><code>class C(object):
@classmethod
def f(cls, x):
return x + x
</code></pre>
<p>This will work:</p>
<pre><code>c = C()
c.f(2)
4
</code></pre>
<p>But is that bad form?
Should I only call</p>
<pre><code>C.f()
</code></pre>
<p>or </p>
<pre><cod... | 20 | 2009-03-28T02:21:05Z | 692,195 | <p>I don't recall using a classmethod like this from outside the class, but it is certainly ok for an instance method to call a classmethod on itself (e.g. <code>self.foo()</code> where <code>foo</code> is a classmethod). This makes sure that inheritance acts as expected, and will call <code>.foo()</code> in the right... | 5 | 2009-03-28T04:28:11Z | [
"python",
"class-method"
] |
Is it bad form to call a classmethod as a method from an instance? | 692,040 | <p>Ex.</p>
<p>If I have something like this:</p>
<pre><code>class C(object):
@classmethod
def f(cls, x):
return x + x
</code></pre>
<p>This will work:</p>
<pre><code>c = C()
c.f(2)
4
</code></pre>
<p>But is that bad form?
Should I only call</p>
<pre><code>C.f()
</code></pre>
<p>or </p>
<pre><cod... | 20 | 2009-03-28T02:21:05Z | 692,388 | <p>If you are tempted to call a class method from an instance you probably don't need a class method.</p>
<p>In the example you gave a static method would be more appropriate precisely because of your last remark (no self/cls interaction).</p>
<pre><code>class C(object):
@staticmethod
def f(x):
return ... | 20 | 2009-03-28T07:35:40Z | [
"python",
"class-method"
] |
How do I track an animated object in Python? | 692,259 | <p>I want to automate playing a video game with Python. I want to write a script that can grab the screen image, diff it with the next frame and track an object to click on. What libraries would be useful for this other than PIL?</p>
| 1 | 2009-03-28T05:14:57Z | 692,302 | <p>There are a few options here. The brute force diff'ing approach will lead to a lot of frustration unless what you're tracking is very consistent. For this you could use any number of genetic approaches to train your program what to follow. After enough generations it would do the right thing reliably. If the thing y... | 0 | 2009-03-28T05:43:24Z | [
"python",
"animation",
"image-manipulation"
] |
How do I track an animated object in Python? | 692,259 | <p>I want to automate playing a video game with Python. I want to write a script that can grab the screen image, diff it with the next frame and track an object to click on. What libraries would be useful for this other than PIL?</p>
| 1 | 2009-03-28T05:14:57Z | 692,396 | <p>Answer would depend on the platform and game too.
e.g. I did once similar things for helicopter flash game, as it was very simple 2d game with well defined colored maze
It was on widows with copy to clipboard and win32 key events using win32api bindings for python.</p>
| 0 | 2009-03-28T07:41:06Z | [
"python",
"animation",
"image-manipulation"
] |
Upgraded to ubuntu 9.04 django test are now slow | 692,294 | <p>Upgraded my laptop to Ubuntu 9.04 and runing latest trunk of django and my test suite has tripled in time to run.</p>
<pre><code>Python2.6
Mysql
Django 1.1 beta 1 SVN-10137
</code></pre>
| 0 | 2009-03-28T05:36:45Z | 695,544 | <p>Quote from the Official Jaunty IRC (#ubuntu+1 on Freenode)</p>
<blockquote>
<p>Jaunty is NOT RELEASED and NOT SUPPORTED. It will most certainly break your system.</p>
</blockquote>
| 3 | 2009-03-29T22:47:52Z | [
"python",
"django",
"ubuntu",
"testing",
"ubuntu-9.04"
] |
Upgraded to ubuntu 9.04 django test are now slow | 692,294 | <p>Upgraded my laptop to Ubuntu 9.04 and runing latest trunk of django and my test suite has tripled in time to run.</p>
<pre><code>Python2.6
Mysql
Django 1.1 beta 1 SVN-10137
</code></pre>
| 0 | 2009-03-28T05:36:45Z | 695,764 | <p>You should verify that your tests are running in a transaction. Is MySQL using the InnoDB or MyISAM backend? If you were using InnoDB before and now MyISAM there is no transaction support in MyISAM.</p>
| 0 | 2009-03-30T01:28:04Z | [
"python",
"django",
"ubuntu",
"testing",
"ubuntu-9.04"
] |
Resolving dependency in python between modules | 692,506 | <p>I am a newbie to python. I do have two modules. Model M1 and module m2.
From m2 , i need to refer m1 and m2 and m1 resides at two different locations in disk. </p>
<p>When I am trying to import m1 before executing m2 , of course it's saying can't find m1.
How I can point my interpreter to m1's location.</p>
<p>Tha... | -2 | 2009-03-28T09:33:53Z | 692,520 | <p>It's not <em>entirely</em> clear what your specific problem is (give more details!), but you may find these useful (further Googling will help you reach concrete answers for your specific needs):</p>
<ul>
<li>The PYTHONPATH environment variable</li>
<li>.pth files in directories that appear in PYTHONPATH</li>
<li>M... | 3 | 2009-03-28T09:46:32Z | [
"python",
"dependencies"
] |
Resolving dependency in python between modules | 692,506 | <p>I am a newbie to python. I do have two modules. Model M1 and module m2.
From m2 , i need to refer m1 and m2 and m1 resides at two different locations in disk. </p>
<p>When I am trying to import m1 before executing m2 , of course it's saying can't find m1.
How I can point my interpreter to m1's location.</p>
<p>Tha... | -2 | 2009-03-28T09:33:53Z | 692,521 | <p>If you can't modify the shell environment, you can append any directories you want the interpreter to search for modules to <code>sys.path</code> from within your script. In fact, the <code>PYTHONPATH</code> environment variable is read and used to initialize <code>sys.path</code>.</p>
| 2 | 2009-03-28T09:49:57Z | [
"python",
"dependencies"
] |
Resolving dependency in python between modules | 692,506 | <p>I am a newbie to python. I do have two modules. Model M1 and module m2.
From m2 , i need to refer m1 and m2 and m1 resides at two different locations in disk. </p>
<p>When I am trying to import m1 before executing m2 , of course it's saying can't find m1.
How I can point my interpreter to m1's location.</p>
<p>Tha... | -2 | 2009-03-28T09:33:53Z | 692,525 | <p>What's possible depends on the details of the modules, but usually you can just import the specifics objects needed from the modules, like this:</p>
<p>in B.py</p>
<pre><code>from A import classA1, funA1
</code></pre>
<p>in A.py</p>
<pre><code>from B import classB1, funB1
</code></pre>
<p>so that you only impor... | 0 | 2009-03-28T09:52:36Z | [
"python",
"dependencies"
] |
How can you find unused functions in Python code? | 693,070 | <p>So you've got some legacy code lying around in a fairly hefty project. How can you find and delete dead functions?</p>
<p>I've seen these two references: <a href="http://stackoverflow.com/questions/245963">Find unused code</a> and <a href="http://stackoverflow.com/questions/11532">Tool to find unused functions in p... | 37 | 2009-03-28T16:42:42Z | 693,120 | <p>Because of the fairly strict way python code is presented, would it be that hard to build a list of functions based on a regex looking for <code>def function_name(..)</code> ?</p>
<p>And then search for each name and tot up how many times it features in the code. It wouldn't naturally take comments into account but... | 1 | 2009-03-28T17:11:40Z | [
"python",
"refactoring",
"dead-code"
] |
How can you find unused functions in Python code? | 693,070 | <p>So you've got some legacy code lying around in a fairly hefty project. How can you find and delete dead functions?</p>
<p>I've seen these two references: <a href="http://stackoverflow.com/questions/245963">Find unused code</a> and <a href="http://stackoverflow.com/questions/11532">Tool to find unused functions in p... | 37 | 2009-03-28T16:42:42Z | 693,183 | <p><a href="http://www.logilab.org/857" rel="nofollow">pylint</a> can do what you want.</p>
| 19 | 2009-03-28T17:39:45Z | [
"python",
"refactoring",
"dead-code"
] |
How can you find unused functions in Python code? | 693,070 | <p>So you've got some legacy code lying around in a fairly hefty project. How can you find and delete dead functions?</p>
<p>I've seen these two references: <a href="http://stackoverflow.com/questions/245963">Find unused code</a> and <a href="http://stackoverflow.com/questions/11532">Tool to find unused functions in p... | 37 | 2009-03-28T16:42:42Z | 693,356 | <p>I'm not sure if this is helpful, but you might try using the <a href="http://nedbatchelder.com/code/modules/coverage.html" rel="nofollow">coverage</a>, <a href="http://darcs.idyll.org/~t/projects/figleaf/doc/" rel="nofollow">figleaf</a> or other similar modules, which record which parts of your source code is used a... | 4 | 2009-03-28T19:21:31Z | [
"python",
"refactoring",
"dead-code"
] |
How can you find unused functions in Python code? | 693,070 | <p>So you've got some legacy code lying around in a fairly hefty project. How can you find and delete dead functions?</p>
<p>I've seen these two references: <a href="http://stackoverflow.com/questions/245963">Find unused code</a> and <a href="http://stackoverflow.com/questions/11532">Tool to find unused functions in p... | 37 | 2009-03-28T16:42:42Z | 693,404 | <p>unless you know that your code uses reflection, as you said, I would go for a trivial grep. Do not underestimate the power of the asterisk in vim as well (performs a search of the word you have under your cursor in the file), albeit this is limited only to the file you are currently editing.</p>
<p>Another solution... | 1 | 2009-03-28T19:44:15Z | [
"python",
"refactoring",
"dead-code"
] |
How can you find unused functions in Python code? | 693,070 | <p>So you've got some legacy code lying around in a fairly hefty project. How can you find and delete dead functions?</p>
<p>I've seen these two references: <a href="http://stackoverflow.com/questions/245963">Find unused code</a> and <a href="http://stackoverflow.com/questions/11532">Tool to find unused functions in p... | 37 | 2009-03-28T16:42:42Z | 9,824,998 | <p>In python you can find unused code by using dynamic or static code analyzers. Two examples for dynamic analyzers are <strong>coverage</strong> and <strong>figleaf</strong>. They have the drawback that you have to run all possible branches of your code in order to find unused parts, but they also have the advantage t... | 29 | 2012-03-22T15:06:44Z | [
"python",
"refactoring",
"dead-code"
] |
Has anyone successfully configured NetBeans for Python (specifically Python 3.0) development? | 693,459 | <p>I was able to configure NetBeans for 2.6.1 by going to to the Python Platform Manager, creating a new platform, and pointing NetBeans at python.exe where I installed 2.6.1. However, when I follow the exact same steps for 3.0, I get an error in the NetBeans console that says "SyntaxError: invalid syntax".</p>
<p>If ... | 8 | 2009-03-28T20:23:37Z | 718,086 | <p>Yep- it's actually very easy. The scripts in the plugin use 'print' as a keyword which has been changed in Python 3; you just have to convert all 'print' statements in the console.py and platform_ info.py files under the 'python1' folder in your NetBeans installation directory to use parenthesis. For instance, in pl... | 5 | 2009-04-05T00:05:55Z | [
"python",
"ide",
"netbeans"
] |
Has anyone successfully configured NetBeans for Python (specifically Python 3.0) development? | 693,459 | <p>I was able to configure NetBeans for 2.6.1 by going to to the Python Platform Manager, creating a new platform, and pointing NetBeans at python.exe where I installed 2.6.1. However, when I follow the exact same steps for 3.0, I get an error in the NetBeans console that says "SyntaxError: invalid syntax".</p>
<p>If ... | 8 | 2009-03-28T20:23:37Z | 719,479 | <p>It doesn't let me comment back here so I'll answer your comment in an post.</p>
<p>Yes, it will let you use Python 2.x as well; the 'print' method was both a keyword and function prior to Python 3, so the parenthesis were optional. As on 3 they are required, so this change is backwards compatible.</p>
| 2 | 2009-04-05T18:58:09Z | [
"python",
"ide",
"netbeans"
] |
Has anyone successfully configured NetBeans for Python (specifically Python 3.0) development? | 693,459 | <p>I was able to configure NetBeans for 2.6.1 by going to to the Python Platform Manager, creating a new platform, and pointing NetBeans at python.exe where I installed 2.6.1. However, when I follow the exact same steps for 3.0, I get an error in the NetBeans console that says "SyntaxError: invalid syntax".</p>
<p>If ... | 8 | 2009-03-28T20:23:37Z | 719,512 | <p>There are some issues with debugging, btw- I'll let you all know when I successfully figure out what has to be updated here.</p>
| 0 | 2009-04-05T19:19:31Z | [
"python",
"ide",
"netbeans"
] |
Has anyone successfully configured NetBeans for Python (specifically Python 3.0) development? | 693,459 | <p>I was able to configure NetBeans for 2.6.1 by going to to the Python Platform Manager, creating a new platform, and pointing NetBeans at python.exe where I installed 2.6.1. However, when I follow the exact same steps for 3.0, I get an error in the NetBeans console that says "SyntaxError: invalid syntax".</p>
<p>If ... | 8 | 2009-03-28T20:23:37Z | 1,284,595 | <p>Thank you Ben Flynn for the solution to integrate python30 with netbeans 6.71</p>
<p>However, this piece of code :</p>
<pre><code>def fib(n): # write Fibonacci series up to n
"""Print a Fibonacci series up to n."""
a, b = 0, 1
while b < n:
print (b, end=' ')
a, b = b, a+b
fi... | 0 | 2009-08-16T15:49:05Z | [
"python",
"ide",
"netbeans"
] |
Has anyone successfully configured NetBeans for Python (specifically Python 3.0) development? | 693,459 | <p>I was able to configure NetBeans for 2.6.1 by going to to the Python Platform Manager, creating a new platform, and pointing NetBeans at python.exe where I installed 2.6.1. However, when I follow the exact same steps for 3.0, I get an error in the NetBeans console that says "SyntaxError: invalid syntax".</p>
<p>If ... | 8 | 2009-03-28T20:23:37Z | 1,325,561 | <p>Starting at version 3.0, the print statement has to be written as a function...</p>
<p>your </p>
<p>print (b, end=' ')</p>
<p>becomes </p>
<p>print("end= ", b)</p>
| 0 | 2009-08-25T01:07:27Z | [
"python",
"ide",
"netbeans"
] |
Alter all values in a Python list of lists? | 693,630 | <p>Let's say I have a list like:</p>
<pre><code>my_list = [[1,2,3],[4,5,6],[7,8,9]]
</code></pre>
<p>How do I alter every value in the list without doing?:</p>
<pre><code>for x in range(0, 3):
for y in range(0, 3):
my_list[x][y] = -my_list[x][y]
</code></pre>
<p>I have tried to simplify this by doing</p... | 4 | 2009-03-28T22:15:04Z | 693,636 | <p>By "alter" I assume you mean "negate" (but you should have said that).</p>
<p>I notice that you're iterating over each element of a two-dimensional array (a list of lists) and treating each element as a list of three elements... but in fact each element is just a number, in your question as stated. So I would do so... | 3 | 2009-03-28T22:18:45Z | [
"python"
] |
Alter all values in a Python list of lists? | 693,630 | <p>Let's say I have a list like:</p>
<pre><code>my_list = [[1,2,3],[4,5,6],[7,8,9]]
</code></pre>
<p>How do I alter every value in the list without doing?:</p>
<pre><code>for x in range(0, 3):
for y in range(0, 3):
my_list[x][y] = -my_list[x][y]
</code></pre>
<p>I have tried to simplify this by doing</p... | 4 | 2009-03-28T22:15:04Z | 693,641 | <p>Try this:</p>
<pre><code>my_list = [[-a, -b, -c] for [a, b, c] in my_list]
</code></pre>
<p>Note that this creates a new list, rather than altering the list.</p>
| 3 | 2009-03-28T22:20:16Z | [
"python"
] |
Alter all values in a Python list of lists? | 693,630 | <p>Let's say I have a list like:</p>
<pre><code>my_list = [[1,2,3],[4,5,6],[7,8,9]]
</code></pre>
<p>How do I alter every value in the list without doing?:</p>
<pre><code>for x in range(0, 3):
for y in range(0, 3):
my_list[x][y] = -my_list[x][y]
</code></pre>
<p>I have tried to simplify this by doing</p... | 4 | 2009-03-28T22:15:04Z | 693,674 | <p>As others have noted, there are two "levels" of lists and one "level" of ints, so two loops gives you an int, not another list.</p>
<p>For comparison, the loop version should be:</p>
<pre><code>for x in range(0, 3):
for y in range(0, 3):
my_list[x][y] = -my_list[x][y]
</code></pre>
<p>That also fixes ... | 1 | 2009-03-28T22:36:22Z | [
"python"
] |
Alter all values in a Python list of lists? | 693,630 | <p>Let's say I have a list like:</p>
<pre><code>my_list = [[1,2,3],[4,5,6],[7,8,9]]
</code></pre>
<p>How do I alter every value in the list without doing?:</p>
<pre><code>for x in range(0, 3):
for y in range(0, 3):
my_list[x][y] = -my_list[x][y]
</code></pre>
<p>I have tried to simplify this by doing</p... | 4 | 2009-03-28T22:15:04Z | 693,682 | <p>Although Constantin's answer is correct, I would make two improvements:</p>
<ol>
<li>Generality is not always the best way. What if the altering function should work on lists?</li>
<li>Using <code>enumerate</code> and indexing is not as fast as creating a list copy and assigning it in-place using <code>[:]</code> s... | 1 | 2009-03-28T22:43:35Z | [
"python"
] |
Alter all values in a Python list of lists? | 693,630 | <p>Let's say I have a list like:</p>
<pre><code>my_list = [[1,2,3],[4,5,6],[7,8,9]]
</code></pre>
<p>How do I alter every value in the list without doing?:</p>
<pre><code>for x in range(0, 3):
for y in range(0, 3):
my_list[x][y] = -my_list[x][y]
</code></pre>
<p>I have tried to simplify this by doing</p... | 4 | 2009-03-28T22:15:04Z | 693,723 | <p>It's possible to code a more general solution to this problem. The following works in Python 3.0, <em>regardless of the level of nesting</em>.</p>
<p>Let's define <code>recursive_map</code>:</p>
<pre><code>import collections
def recursive_map(f, iterable):
for e in iterable:
if isinstance(e, collectio... | 6 | 2009-03-28T23:05:53Z | [
"python"
] |
Alter all values in a Python list of lists? | 693,630 | <p>Let's say I have a list like:</p>
<pre><code>my_list = [[1,2,3],[4,5,6],[7,8,9]]
</code></pre>
<p>How do I alter every value in the list without doing?:</p>
<pre><code>for x in range(0, 3):
for y in range(0, 3):
my_list[x][y] = -my_list[x][y]
</code></pre>
<p>I have tried to simplify this by doing</p... | 4 | 2009-03-28T22:15:04Z | 693,811 | <p>It is ugly but you can modify the list in-place with a list comprehension if you really want to.</p>
<pre><code>>>> my_list = [[1,2,3],[4,5,6],[7,8,9]]
>>> [[slist.__setitem__(i, -n) for i, n in enumerate(slist)] for slist in my_list]
[[None, None, None], [None, None, None], [None, None, None]]
&g... | 1 | 2009-03-28T23:57:13Z | [
"python"
] |
Alter all values in a Python list of lists? | 693,630 | <p>Let's say I have a list like:</p>
<pre><code>my_list = [[1,2,3],[4,5,6],[7,8,9]]
</code></pre>
<p>How do I alter every value in the list without doing?:</p>
<pre><code>for x in range(0, 3):
for y in range(0, 3):
my_list[x][y] = -my_list[x][y]
</code></pre>
<p>I have tried to simplify this by doing</p... | 4 | 2009-03-28T22:15:04Z | 693,834 | <p>Another option is to use the built-in <code>map</code> function:</p>
<pre><code>>>> my_list = [[1,2,3],[4,5,6],[7,8,9]]
>>> neg = lambda x: -x
>>> f = lambda x: map(neg, x)
>>> map(f, my_list)
[[-1, -2, -3], [-4, -5, -6], [-7, -8, -9]]
</code></pre>
| 11 | 2009-03-29T00:09:02Z | [
"python"
] |
Alter all values in a Python list of lists? | 693,630 | <p>Let's say I have a list like:</p>
<pre><code>my_list = [[1,2,3],[4,5,6],[7,8,9]]
</code></pre>
<p>How do I alter every value in the list without doing?:</p>
<pre><code>for x in range(0, 3):
for y in range(0, 3):
my_list[x][y] = -my_list[x][y]
</code></pre>
<p>I have tried to simplify this by doing</p... | 4 | 2009-03-28T22:15:04Z | 693,876 | <p>Many answers are about creating altered <em>copy</em> of list, but literal meaning of question is about in-place modification of list.</p>
<p>Here is my version of best-of-breed in-place list altering solution:</p>
<pre><code>def alter_elements(lst, func):
for i, item in enumerate(lst):
if isinstance(item, l... | 7 | 2009-03-29T00:37:37Z | [
"python"
] |
Alter all values in a Python list of lists? | 693,630 | <p>Let's say I have a list like:</p>
<pre><code>my_list = [[1,2,3],[4,5,6],[7,8,9]]
</code></pre>
<p>How do I alter every value in the list without doing?:</p>
<pre><code>for x in range(0, 3):
for y in range(0, 3):
my_list[x][y] = -my_list[x][y]
</code></pre>
<p>I have tried to simplify this by doing</p... | 4 | 2009-03-28T22:15:04Z | 694,290 | <p>If you have a 3x3 array of numbers, and you want to perform a transformation on every element of it, I suspect you may be better served in the long run by using a numerical library like NumPy/SciPy, and using the matrix routines it provides. If you are in any way interested in high performance, then this would be a ... | 0 | 2009-03-29T07:57:39Z | [
"python"
] |
Python module for VBox? | 693,752 | <p>I want to make some python scripts to create an "Appliance" with VirtualBox. However, I can't find any documentation anywhere on making calls to VBoxService.exe. Well, I've found stuff that works from OUTSIDE the Machine, but nothing from working from inside the machine.</p>
<p>Does anyone know anything about this?... | 2 | 2009-03-28T23:20:16Z | 694,365 | <p>Consider using <A HREF="http://www.libvirt.org" rel="nofollow">libvirt</A>. The VirtualBox support is bleeding-edge (not in any release, may not even be in source control yet, but is available as a set of patches on the mailing list) -- but this single API, available for C, Python and several other languages, lets y... | 2 | 2009-03-29T09:13:21Z | [
"python",
"virtualbox"
] |
Best practice for two way hashing in python? | 693,826 | <p>I want to allow users to validate their email address by clicking on a link. The link would look something like</p>
<p><a href="http://www.example.com/verifyemail?id=some-random-string" rel="nofollow">http://www.example.com/verifyemail?id=some-random-string</a></p>
<p>When I am sending this email, I want to be abl... | 1 | 2009-03-29T00:06:00Z | 693,838 | <p>Use encryption, that's exactly what it's designed for. Blowfish, AES, even DES3 if you don't need particularly high security.</p>
<p>Alternatively, you could compute an SHA-256 or SHA-512 (or whatever) hash of the email address and store it in a database along with the email address itself. That way you can just lo... | 3 | 2009-03-29T00:10:10Z | [
"python"
] |
Best practice for two way hashing in python? | 693,826 | <p>I want to allow users to validate their email address by clicking on a link. The link would look something like</p>
<p><a href="http://www.example.com/verifyemail?id=some-random-string" rel="nofollow">http://www.example.com/verifyemail?id=some-random-string</a></p>
<p>When I am sending this email, I want to be abl... | 1 | 2009-03-29T00:06:00Z | 694,304 | <p>Your best choice is to generate a hash (one-way function) of some of the user's data. For example, to generate a hash of user's row id, you could use something like:</p>
<pre><code>>>> import hashlib
>>> hashlib.sha1('3').hexdigest()
'77de68daecd823babbb58edb1c8e14d7106e83bb'
</code></pre>
<p>How... | 5 | 2009-03-29T08:18:36Z | [
"python"
] |
why doesn't subprocess.Popen(...) always return? | 694,000 | <p>I hope this is a simple python question.</p>
<p>When I try the following in the python interpreter:</p>
<pre><code>>>> import process
>>> def test(cmd):
... p = subprocess.Popen(cmd)
...
>>> test(['ls', '-l'])
</code></pre>
<p>It will run the <code>ls -l</code>, but I need to hit "ret... | 5 | 2009-03-29T02:18:09Z | 694,021 | <p>I may have answered my own question. I believe that in the final case, I need to explicitly read from p.stdout in order for my process to continue.</p>
<p>ie:</p>
<pre><code>p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
output = p.stdout.readlines()
....
</code></pre>
<p>Thanks all</p>
| 6 | 2009-03-29T02:35:19Z | [
"python",
"subprocess"
] |
why doesn't subprocess.Popen(...) always return? | 694,000 | <p>I hope this is a simple python question.</p>
<p>When I try the following in the python interpreter:</p>
<pre><code>>>> import process
>>> def test(cmd):
... p = subprocess.Popen(cmd)
...
>>> test(['ls', '-l'])
</code></pre>
<p>It will run the <code>ls -l</code>, but I need to hit "ret... | 5 | 2009-03-29T02:18:09Z | 694,074 | <p>In the first variation, <code>test()</code> returns immediately after starting the process, but before its output is sent to the console.</p>
<p>If you look at the output you <em>do</em> get the prompt, immediately before the output of <code>ls</code>. </p>
<pre><code>>>> test(['ls', '-l'])
>>> t... | 8 | 2009-03-29T03:47:51Z | [
"python",
"subprocess"
] |
why doesn't subprocess.Popen(...) always return? | 694,000 | <p>I hope this is a simple python question.</p>
<p>When I try the following in the python interpreter:</p>
<pre><code>>>> import process
>>> def test(cmd):
... p = subprocess.Popen(cmd)
...
>>> test(['ls', '-l'])
</code></pre>
<p>It will run the <code>ls -l</code>, but I need to hit "ret... | 5 | 2009-03-29T02:18:09Z | 21,903,956 | <p>Just use communicate() method.No need to return.</p>
<pre><code>>>> test(['ls', '-l'])
>>>
>>> def test(cmd):
... p = subprocess.Popen(cmd).communicate()
...
>>> test(['ls', '-l'])
</code></pre>
| 0 | 2014-02-20T09:46:46Z | [
"python",
"subprocess"
] |
why doesn't subprocess.Popen(...) always return? | 694,000 | <p>I hope this is a simple python question.</p>
<p>When I try the following in the python interpreter:</p>
<pre><code>>>> import process
>>> def test(cmd):
... p = subprocess.Popen(cmd)
...
>>> test(['ls', '-l'])
</code></pre>
<p>It will run the <code>ls -l</code>, but I need to hit "ret... | 5 | 2009-03-29T02:18:09Z | 25,453,263 | <p>Here is a command that pings Google forever, so it needs to be manually terminated to retrieve the output.</p>
<p>See the <a href="https://docs.python.org/2/library/subprocess.html#replacing-os-popen-os-popen2-os-popen3" rel="nofollow">subprocess documentation</a> for instructions on converting os.popen() method ca... | 0 | 2014-08-22T18:17:12Z | [
"python",
"subprocess"
] |
Understanding Python Class instances | 694,002 | <p>I'm working on a problem which uses a python class and has a constructor function to give the number of sides to one die and a function to roll the die with a random number returned based on the number of sides. I realize the code is very basic, but I'm having troubles understanding how to sum up the total of three ... | 2 | 2009-03-29T02:19:23Z | 694,006 | <p>Since <code>roll_die</code> returns a value, you can add those values.</p>
<p>Try this.</p>
<pre><code>roll1.roll_die() + roll2.roll_die()
</code></pre>
<p>What happens?</p>
| 1 | 2009-03-29T02:22:54Z | [
"python",
"class",
"sum"
] |
Understanding Python Class instances | 694,002 | <p>I'm working on a problem which uses a python class and has a constructor function to give the number of sides to one die and a function to roll the die with a random number returned based on the number of sides. I realize the code is very basic, but I'm having troubles understanding how to sum up the total of three ... | 2 | 2009-03-29T02:19:23Z | 694,016 | <p>You can just sum the numbers. In case you want to sum the outcome of <em>n</em> rolls, consider adding this function to the class:</p>
<pre><code>def sum_of_n_rolls(self, n)
return sum(self.roll_die() for _ in range(n))
</code></pre>
<p>Also, consider renaming *roll_die* to just <em>roll</em>. It's obvious tha... | 0 | 2009-03-29T02:30:02Z | [
"python",
"class",
"sum"
] |
Understanding Python Class instances | 694,002 | <p>I'm working on a problem which uses a python class and has a constructor function to give the number of sides to one die and a function to roll the die with a random number returned based on the number of sides. I realize the code is very basic, but I'm having troubles understanding how to sum up the total of three ... | 2 | 2009-03-29T02:19:23Z | 694,020 | <p>You can store the results in a list:</p>
<pre><code>rolls = [Die(n).roll_die() for n in (6, 4, 12)]
</code></pre>
<p>then you can show the individual results</p>
<pre><code>>>> print rolls
[5, 2, 6]
</code></pre>
<p>or sum them</p>
<pre><code>>>> print sum(rolls)
13
</code></pre>
<p>Or, inste... | 10 | 2009-03-29T02:32:52Z | [
"python",
"class",
"sum"
] |
Understanding Python Class instances | 694,002 | <p>I'm working on a problem which uses a python class and has a constructor function to give the number of sides to one die and a function to roll the die with a random number returned based on the number of sides. I realize the code is very basic, but I'm having troubles understanding how to sum up the total of three ... | 2 | 2009-03-29T02:19:23Z | 694,022 | <p>I'm not sure exactly where you're confused. The simplest thing you need to do is separate the concept of a specific die you're going to roll (the object) with the action (rolling it). I would start here:</p>
<pre><code>d6 = Die() #create die 1 with the default side of 6
d4 = Die(4) #create die 2 with 4 sides
d12 = ... | 3 | 2009-03-29T02:37:16Z | [
"python",
"class",
"sum"
] |
Understanding Python Class instances | 694,002 | <p>I'm working on a problem which uses a python class and has a constructor function to give the number of sides to one die and a function to roll the die with a random number returned based on the number of sides. I realize the code is very basic, but I'm having troubles understanding how to sum up the total of three ... | 2 | 2009-03-29T02:19:23Z | 694,034 | <p>Guess I'd do something like this:</p>
<pre><code># Create dice
sides = [6,4,12]
dice = [Die(s) for s in sides]
# Roll dice
rolls = [die.roll_die() for die in dice]
# Print rolls
for roll in rolls:
print roll
</code></pre>
<p>You can also combine a few of these steps if you like:</p>
<pre><code>for num_sides... | 0 | 2009-03-29T02:56:51Z | [
"python",
"class",
"sum"
] |
Understanding Python Class instances | 694,002 | <p>I'm working on a problem which uses a python class and has a constructor function to give the number of sides to one die and a function to roll the die with a random number returned based on the number of sides. I realize the code is very basic, but I'm having troubles understanding how to sum up the total of three ... | 2 | 2009-03-29T02:19:23Z | 694,039 | <p>It may also be useful to just store the last roll so you can get it whenever you want.</p>
<pre><code>def __init__(self, s = 6):
self.sides = s
self.last_roll = None
def roll_die(self):
self.last_roll = random.randint(1,self.sides)
return self.last_roll
</code></pre>
| 3 | 2009-03-29T03:01:03Z | [
"python",
"class",
"sum"
] |
Understanding Python Class instances | 694,002 | <p>I'm working on a problem which uses a python class and has a constructor function to give the number of sides to one die and a function to roll the die with a random number returned based on the number of sides. I realize the code is very basic, but I'm having troubles understanding how to sum up the total of three ... | 2 | 2009-03-29T02:19:23Z | 694,217 | <p>If I understood you correctly you want a class attribute.</p>
<p><strong>UPDATE:</strong> Added a way for automatically reseting the total</p>
<pre><code>import random
class Die():
_total = 0
@classmethod
def total(cls):
t = cls._total
cls._total = 0
return t
def __init__... | 0 | 2009-03-29T06:36:33Z | [
"python",
"class",
"sum"
] |
Understanding Python Class instances | 694,002 | <p>I'm working on a problem which uses a python class and has a constructor function to give the number of sides to one die and a function to roll the die with a random number returned based on the number of sides. I realize the code is very basic, but I'm having troubles understanding how to sum up the total of three ... | 2 | 2009-03-29T02:19:23Z | 695,507 | <p>Let's get crazy :) (combined with my last answer as well)</p>
<pre><code>class Die():
def __init__(self, s = 6):
self.sides = s
self.last_roll = None
def roll_die(self):
self.last_roll = random.randint(1,self.sides)
return self.last_roll
dice = map(Die, (6, 4, 12))
rolls = ... | 0 | 2009-03-29T22:26:23Z | [
"python",
"class",
"sum"
] |
Bad Pickle get error | 694,192 | <p>I have been using a flash card program called Mnemosyne which uses python script. A short time ago my database of flash cards became inaccessible after my computer froze and I had to shut it down manually. Whenever I try to load the data base containing my cards I get this error. </p>
<pre>
Invalid file format
Tra... | 0 | 2009-03-29T06:08:20Z | 695,936 | <p>(Whilst CLayton's copy may be a binary distribution, the source to mnemosyne is freely available.)</p>
<p>It's not much help though: line 1012 is just:</p>
<pre><code>db = cPickle.load(infile)
</code></pre>
<p>Where âinfileâ is the stored database file. So there's something corrupt in your database file. (Bad... | 1 | 2009-03-30T03:40:52Z | [
"python",
"pickle"
] |
Detect in python which keys are pressed | 694,296 | <p>I need to know which key is being pressed right now. I'm not looking to capture some specific keys to trigger an event or anything like that, </p>
<p>I want to know which keys are pressed now and display a list of them.</p>
<p>I also need to capture special keys like F1 ... F12, shift, alt, home, windows, etc. Bas... | 18 | 2009-03-29T08:11:26Z | 694,311 | <p><a href="https://sourceforge.net/p/pykeylogger/wiki/Main_Page/" rel="nofollow">PyKeylogger</a> mentioned in <a href="http://stackoverflow.com/questions/365110/cross-platform-keylogger/365225#365225">the related question</a> might do the job.</p>
| 4 | 2009-03-29T08:25:45Z | [
"python",
"events",
"keyboard"
] |
Detect in python which keys are pressed | 694,296 | <p>I need to know which key is being pressed right now. I'm not looking to capture some specific keys to trigger an event or anything like that, </p>
<p>I want to know which keys are pressed now and display a list of them.</p>
<p>I also need to capture special keys like F1 ... F12, shift, alt, home, windows, etc. Bas... | 18 | 2009-03-29T08:11:26Z | 694,342 | <p>I found the answer using a link in a <a href="http://stackoverflow.com/questions/365110/cross-platform-keylogger">related question</a> to <a href="http://pyhook.wiki.sourceforge.net/" rel="nofollow">pyHook</a>:</p>
<p><a href="http://pyhook.wiki.sourceforge.net/pyHook%5FTutorial#tocpyHook%5FTutorial4" rel="nofollow... | 2 | 2009-03-29T08:58:30Z | [
"python",
"events",
"keyboard"
] |
Detect in python which keys are pressed | 694,296 | <p>I need to know which key is being pressed right now. I'm not looking to capture some specific keys to trigger an event or anything like that, </p>
<p>I want to know which keys are pressed now and display a list of them.</p>
<p>I also need to capture special keys like F1 ... F12, shift, alt, home, windows, etc. Bas... | 18 | 2009-03-29T08:11:26Z | 695,439 | <p>The easiest way to do something like this, if you're not too fussy, is to bring in a GUI toolkit such as pygame or wxPython. For example, run the wxPython Demo, then go to the demo for KeyEvents.</p>
| 3 | 2009-03-29T21:43:02Z | [
"python",
"events",
"keyboard"
] |
How can I make this recursive crawl function iterative? | 694,366 | <p>For academic and performance sake, given this crawl recursive web-crawling function (which crawls only within the given domain) what would be the best approach to make it run iteratively? Currently when it runs, by the time it finishes python has climbed to using over 1GB of memory which isn't acceptable for running... | 4 | 2009-03-29T09:13:29Z | 694,369 | <p>Use a BFS instead of crawling recursively (DFS): <a href="http://en.wikipedia.org/wiki/Breadth_first_search" rel="nofollow">http://en.wikipedia.org/wiki/Breadth_first_search</a></p>
<p>You can use an external storage solution (such as a database) for BFS queue to free up RAM.</p>
<p>The algorithm is:</p>
<pre><co... | 11 | 2009-03-29T09:16:53Z | [
"python",
"recursion",
"web-crawler"
] |
How can I make this recursive crawl function iterative? | 694,366 | <p>For academic and performance sake, given this crawl recursive web-crawling function (which crawls only within the given domain) what would be the best approach to make it run iteratively? Currently when it runs, by the time it finishes python has climbed to using over 1GB of memory which isn't acceptable for running... | 4 | 2009-03-29T09:13:29Z | 694,398 | <p>Instead of recursing, you could put the new URLs to crawl into a queue. Then run until the queue is empty without recursing. If you put the queue into a file this uses almost no memory at all.</p>
| 5 | 2009-03-29T09:54:17Z | [
"python",
"recursion",
"web-crawler"
] |
How can I make this recursive crawl function iterative? | 694,366 | <p>For academic and performance sake, given this crawl recursive web-crawling function (which crawls only within the given domain) what would be the best approach to make it run iteratively? Currently when it runs, by the time it finishes python has climbed to using over 1GB of memory which isn't acceptable for running... | 4 | 2009-03-29T09:13:29Z | 695,187 | <p>You can do it pretty easily just by using <code>links</code> as a queue:</p>
<pre><code>def get_links(url):
"Extract all matching links from a url"
try:
links = BeautifulSoup(urllib2.urlopen(url)).findAll(Crawler._match_tag)
except urllib2.HTTPError:
return []
def crawl(self, url):
... | 0 | 2009-03-29T19:26:10Z | [
"python",
"recursion",
"web-crawler"
] |
How can I make this recursive crawl function iterative? | 694,366 | <p>For academic and performance sake, given this crawl recursive web-crawling function (which crawls only within the given domain) what would be the best approach to make it run iteratively? Currently when it runs, by the time it finishes python has climbed to using over 1GB of memory which isn't acceptable for running... | 4 | 2009-03-29T09:13:29Z | 697,001 | <p>@Mehrdad - Thank you for your reply, the example you provided was concise and easy to understand.</p>
<p>The solution:</p>
<pre><code> def crawl(self, url):
urls = Queue(-1)
_crawled = []
urls.put(url)
while not urls.empty():
url = urls.get()
try:
links = BeautifulSoup(urllib... | 2 | 2009-03-30T12:33:44Z | [
"python",
"recursion",
"web-crawler"
] |
how to hook to events / messages in windows using python | 694,475 | <h2>in short:</h2>
<p>i want to intercept <strong>suspend/standby messages</strong> on my laptop, but my program doesn't receives all relevant messages.</p>
<h2>background:</h2>
<p>there's a bug in ms-excel on windows xp/2k, which prevents system suspend if a file is opened on a network/usb drive.</p>
<p>i'm trying... | 9 | 2009-03-29T11:15:10Z | 702,555 | <p>Is this a learning experience or something that you actually want ? </p>
<p>Could your program instead just quit excel when it detects a shut down therefore avoiding the issue of excel reporting back a false?</p>
| 0 | 2009-03-31T18:58:02Z | [
"python",
"windows",
"wmi",
"power-management"
] |
how to hook to events / messages in windows using python | 694,475 | <h2>in short:</h2>
<p>i want to intercept <strong>suspend/standby messages</strong> on my laptop, but my program doesn't receives all relevant messages.</p>
<h2>background:</h2>
<p>there's a bug in ms-excel on windows xp/2k, which prevents system suspend if a file is opened on a network/usb drive.</p>
<p>i'm trying... | 9 | 2009-03-29T11:15:10Z | 707,898 | <p>I've found an ugly workaround:
I wrote an <a href="http://www.autoitscript.com/autoit3/" rel="nofollow">AutoIt</a> script which detects the Excel's error MessageBox, closes it, and runs a sysinternals' utility which forces the computer to standby.</p>
<pre>
Opt("WinWaitDelay",400)
; -- exact text match, to save LOT... | 2 | 2009-04-02T00:47:07Z | [
"python",
"windows",
"wmi",
"power-management"
] |
What is the best way to internationalize a Python app with multiple i18n domains? | 694,768 | <p>I'm internationalizing a Python application, with two goals in mind:</p>
<ol>
<li><p>The application loads classes from multiple packages, each with its own i18n domain. So modules in package A are using domain A, modules in package B are using domain B, etc.</p></li>
<li><p>The locale can be changed while the app... | 2 | 2009-03-29T15:08:06Z | 694,953 | <p>how about you bind _ to a function roughly like this (for each module):</p>
<pre><code>def _(message):
return my_gettext(__name__, message)
</code></pre>
<p>This allows you to use gettext while at the same time perform any lookup on a per-module-per-call-base that allows you to switch locale as well.</p>
| 2 | 2009-03-29T16:55:49Z | [
"python",
"localization",
"internationalization"
] |
Shortening a oft-used code segment for testing a return value in Python | 694,775 | <p>Consider this Python segment:</p>
<pre><code>def someTestFunction():
if someTest:
return value1
elif someOtherTest:
return value2
elif yetSomeOtherTest:
return value3
return None
def SomeCallingFunction():
a = someTestFunction()
if a != None:
return a
..... | 1 | 2009-03-29T15:10:51Z | 694,786 | <p>I often use a hash table in place of a series of elifs:</p>
<pre><code>def someTestFunction(decorated_test):
options = {
'val1': return_val_1,
'val2': return_val_2
}
return options[decorated_test]
</code></pre>
<p>You can set up options as a defaultdict(None) to default to None if a key... | 4 | 2009-03-29T15:17:44Z | [
"python",
"optimization"
] |
Shortening a oft-used code segment for testing a return value in Python | 694,775 | <p>Consider this Python segment:</p>
<pre><code>def someTestFunction():
if someTest:
return value1
elif someOtherTest:
return value2
elif yetSomeOtherTest:
return value3
return None
def SomeCallingFunction():
a = someTestFunction()
if a != None:
return a
..... | 1 | 2009-03-29T15:10:51Z | 694,803 | <p>If you want to use a decorator, it would look like this:</p>
<pre><code>def testDecorator(f):
def _testDecorator():
a = someTestFunction()
if a is None:
return f()
else: return a
return _testDecorator
@testDecorator
def SomeCallingFunction():
... normal execution
</c... | 9 | 2009-03-29T15:27:43Z | [
"python",
"optimization"
] |
Shortening a oft-used code segment for testing a return value in Python | 694,775 | <p>Consider this Python segment:</p>
<pre><code>def someTestFunction():
if someTest:
return value1
elif someOtherTest:
return value2
elif yetSomeOtherTest:
return value3
return None
def SomeCallingFunction():
a = someTestFunction()
if a != None:
return a
..... | 1 | 2009-03-29T15:10:51Z | 694,811 | <p>I think this would do it:</p>
<p><strong>UPDATE</strong> Fixed!<br />
Sorry for yesterday, I rushed and didn't test the code!</p>
<pre><code>def test_decorator( test_func ):
def tester( normal_function ):
def tester_inner():
a = test_func()
if a is not None:
ret... | 2 | 2009-03-29T15:34:09Z | [
"python",
"optimization"
] |
Help with Python loop weirdness? | 695,040 | <p>I'm learning Python as my second programming language (my first real one if you don't count HTML/CSS/Javascript). I'm trying to build something useful as my first real application - an IRC bot that alerts people via SMS when certain things happen in the channel. Per a request by someone, I'm (trying) to build in s... | 1 | 2009-03-29T17:54:24Z | 695,077 | <p>I would check the logic in your conditionals. You looping construct should work. </p>
| 0 | 2009-03-29T18:19:52Z | [
"python",
"csv",
"loops"
] |
Help with Python loop weirdness? | 695,040 | <p>I'm learning Python as my second programming language (my first real one if you don't count HTML/CSS/Javascript). I'm trying to build something useful as my first real application - an IRC bot that alerts people via SMS when certain things happen in the channel. Per a request by someone, I'm (trying) to build in s... | 1 | 2009-03-29T17:54:24Z | 695,113 | <p>Be explicit with what's in a row. Using 0, 1, 2...n is actually your bug, and it makes code very hard to read in the future for yourself or others. So let's use the handy tuple to show what we're expecting from a row. This sort of works like code as documentation</p>
<pre><code>db = open("db.csv")
for line in db.re... | 0 | 2009-03-29T18:37:01Z | [
"python",
"csv",
"loops"
] |
Help with Python loop weirdness? | 695,040 | <p>I'm learning Python as my second programming language (my first real one if you don't count HTML/CSS/Javascript). I'm trying to build something useful as my first real application - an IRC bot that alerts people via SMS when certain things happen in the channel. Per a request by someone, I'm (trying) to build in s... | 1 | 2009-03-29T17:54:24Z | 695,125 | <p>Have you tried something more simple? Just to see how your file is actually read by Python:</p>
<pre><code>db = open("db.csv")
for line in db:
print line
</code></pre>
<p>There can be problem with format of your csv-file. That happens, for instance, when you open Unix file in Windows environment. In that c... | 5 | 2009-03-29T18:44:43Z | [
"python",
"csv",
"loops"
] |
Help with Python loop weirdness? | 695,040 | <p>I'm learning Python as my second programming language (my first real one if you don't count HTML/CSS/Javascript). I'm trying to build something useful as my first real application - an IRC bot that alerts people via SMS when certain things happen in the channel. Per a request by someone, I'm (trying) to build in s... | 1 | 2009-03-29T17:54:24Z | 695,148 | <p>If this is a regular CSV file you should not try to parse it yourself. Use the standard library <a href="http://docs.python.org/library/csv.html" rel="nofollow">csv module</a>.</p>
<p>Here is a short example from the docs:</p>
<pre><code>import csv
reader = csv.reader(open("some.csv", "rb"))
for row in reader:
... | 9 | 2009-03-29T19:00:33Z | [
"python",
"csv",
"loops"
] |
Help with Python loop weirdness? | 695,040 | <p>I'm learning Python as my second programming language (my first real one if you don't count HTML/CSS/Javascript). I'm trying to build something useful as my first real application - an IRC bot that alerts people via SMS when certain things happen in the channel. Per a request by someone, I'm (trying) to build in s... | 1 | 2009-03-29T17:54:24Z | 695,152 | <p>There are at least two bugs in your program:</p>
<pre><code>curtime = time.strftime("%H")
...
for hour in range(int(s), int(f)):
nrt.append(hour)
# this is an inefficient synonym for
# nrt = range(int(s), int(f))
if curtime in nrt:
...
</code></pre>
<p>First, curtime is a string, whereas nrt is a list of ... | 7 | 2009-03-29T19:02:11Z | [
"python",
"csv",
"loops"
] |
Help with Python loop weirdness? | 695,040 | <p>I'm learning Python as my second programming language (my first real one if you don't count HTML/CSS/Javascript). I'm trying to build something useful as my first real application - an IRC bot that alerts people via SMS when certain things happen in the channel. Per a request by someone, I'm (trying) to build in s... | 1 | 2009-03-29T17:54:24Z | 695,531 | <p>You could go thro an existing well written IRC bot in Python <a href="http://susam.in/downloads/pibby/pibby-0.0.3-alpha.tar.gz" rel="nofollow">Download</a></p>
| 0 | 2009-03-29T22:40:40Z | [
"python",
"csv",
"loops"
] |
What is LLVM and How is replacing Python VM with LLVM increasing speeds 5x? | 695,370 | <p>Google is sponsoring an Open Source project to increase the speed of Python by 5x.</p>
<p><a href="http://code.google.com/p/unladen-swallow/">Unladen-Swallow</a> seems to have a <a href="http://code.google.com/p/unladen-swallow/wiki/ProjectPlan">good project plan</a></p>
<p>Why is concurrency such a hard problem? ... | 26 | 2009-03-29T21:01:56Z | 695,428 | <p><a href="http://llvm.org/">LLVM</a> is several things together - kind of a virtual machine/optimizing compiler, combined with different frontends that take the input in a particular language and output the result in an intermediate language. This intermediate output can be run with the virtual machine, or can be use... | 32 | 2009-03-29T21:37:41Z | [
"python",
"multicore",
"llvm",
"unladen-swallow"
] |
What is LLVM and How is replacing Python VM with LLVM increasing speeds 5x? | 695,370 | <p>Google is sponsoring an Open Source project to increase the speed of Python by 5x.</p>
<p><a href="http://code.google.com/p/unladen-swallow/">Unladen-Swallow</a> seems to have a <a href="http://code.google.com/p/unladen-swallow/wiki/ProjectPlan">good project plan</a></p>
<p>Why is concurrency such a hard problem? ... | 26 | 2009-03-29T21:01:56Z | 695,433 | <p>The switch to LLVM itself isn't solving the concurrency problem. That's being solved separately, by getting rid of the <a href="http://docs.python.org/c-api/init.html#thread-state-and-the-global-interpreter-lock">Global Interpreter Lock</a>.</p>
<p>I'm not sure how I feel about that; I use threads mainly to deal w... | 17 | 2009-03-29T21:39:59Z | [
"python",
"multicore",
"llvm",
"unladen-swallow"
] |
What is LLVM and How is replacing Python VM with LLVM increasing speeds 5x? | 695,370 | <p>Google is sponsoring an Open Source project to increase the speed of Python by 5x.</p>
<p><a href="http://code.google.com/p/unladen-swallow/">Unladen-Swallow</a> seems to have a <a href="http://code.google.com/p/unladen-swallow/wiki/ProjectPlan">good project plan</a></p>
<p>Why is concurrency such a hard problem? ... | 26 | 2009-03-29T21:01:56Z | 695,479 | <p>LLVM takes care of the nitty-gritty of code generation, so it lets them rewrite Psyco in a way that's more general, portable, maintainable. That in turn allows them to rewrite the CPython core, which lets them experiment with alternate GCs and other things needed to improve python's support for concurrency.</p>
<p... | 15 | 2009-03-29T22:07:58Z | [
"python",
"multicore",
"llvm",
"unladen-swallow"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.