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 |
|---|---|---|---|---|---|---|---|---|---|
New to Mac Platform, Trying to get back to default python install | 2,196,823 | <p>I've been trying to follow <a href="http://www.dx13.co.uk/articles/2009/10/23/MacPython-24-to-Default-Python-on-Snow-Leopard.html" rel="nofollow">this blog post</a> to get my python version back to the snow leopard default. I have followed the first two steps without a problem but am lost when it comes to 3 and 4. ... | 0 | 2010-02-04T01:42:38Z | 2,196,882 | <p>Step 3:</p>
<p><code>sudo rm /usr/local/bin/python</code></p>
<p>Step 4:</p>
<p><code>ls ~/.bash_profile.pysave</code></p>
<p>If the file exists:</p>
<p><code>rm ~/.bash_profile && mv ~/.bash_profile.pysave ~/.bash_profile</code></p>
<p>You will probably want to close your shell / Terminal and open a n... | 2 | 2010-02-04T01:58:17Z | [
"python",
"osx",
"osx-snow-leopard"
] |
New to Mac Platform, Trying to get back to default python install | 2,196,823 | <p>I've been trying to follow <a href="http://www.dx13.co.uk/articles/2009/10/23/MacPython-24-to-Default-Python-on-Snow-Leopard.html" rel="nofollow">this blog post</a> to get my python version back to the snow leopard default. I have followed the first two steps without a problem but am lost when it comes to 3 and 4. ... | 0 | 2010-02-04T01:42:38Z | 2,197,372 | <p>Please be aware that Snow Leopard ships with a buggy IDLE. You will not be able to create a new document with it. If you will use another editor, it may not bother you. I a working with the following version:</p>
<p>Python 2.6.4 (r264:75821M, Oct 27 2009, 19:48:32) </p>
| 0 | 2010-02-04T04:49:13Z | [
"python",
"osx",
"osx-snow-leopard"
] |
Add an object to a python list | 2,196,956 | <p>I am trying to add an object to a list but since I'm adding the actual object when I try to reset the list thereafter, all the values in the list are reset.
Is there an actual way how I can add a monitor object to the list and change the values and not affect the ones I've already saved in the list?</p>
<p>Thanks</... | 17 | 2010-02-04T02:21:52Z | 2,196,970 | <p>while you should show how your code looks like that gives the problem, i think this scenario is very common. See <a href="http://docs.python.org/library/copy.html" rel="nofollow">copy/deepcopy</a> </p>
| 2 | 2010-02-04T02:28:00Z | [
"python",
"object"
] |
Add an object to a python list | 2,196,956 | <p>I am trying to add an object to a list but since I'm adding the actual object when I try to reset the list thereafter, all the values in the list are reset.
Is there an actual way how I can add a monitor object to the list and change the values and not affect the ones I've already saved in the list?</p>
<p>Thanks</... | 17 | 2010-02-04T02:21:52Z | 2,196,972 | <p>Is your problem similar to this:</p>
<pre><code>l = [[0]] * 4
l[0][0] += 1
print l # prints "[[1], [1], [1], [1]]"
</code></pre>
<p>If so, you simply need to copy the objects when you store them:</p>
<pre><code>import copy
l = [copy.copy(x) for x in [[0]] * 4]
l[0][0] += 1
print l # prints "[[1], [0], [0], [0]]"
... | 15 | 2010-02-04T02:29:05Z | [
"python",
"object"
] |
Add an object to a python list | 2,196,956 | <p>I am trying to add an object to a list but since I'm adding the actual object when I try to reset the list thereafter, all the values in the list are reset.
Is there an actual way how I can add a monitor object to the list and change the values and not affect the ones I've already saved in the list?</p>
<p>Thanks</... | 17 | 2010-02-04T02:21:52Z | 2,197,022 | <p>You need to create a copy of the list before you modify its contents. A quick shortcut to duplicate a list is this:</p>
<pre><code>mylist[:]
</code></pre>
<p>Example:</p>
<pre><code>>>> first = [1,2,3]
>>> second = first[:]
>>> second.append(4)
>>> first
[1, 2, 3]
>>>... | 2 | 2010-02-04T02:46:06Z | [
"python",
"object"
] |
Add an object to a python list | 2,196,956 | <p>I am trying to add an object to a list but since I'm adding the actual object when I try to reset the list thereafter, all the values in the list are reset.
Is there an actual way how I can add a monitor object to the list and change the values and not affect the ones I've already saved in the list?</p>
<p>Thanks</... | 17 | 2010-02-04T02:21:52Z | 17,115,750 | <p>If i am correct in believing that you are adding a variable to the array but when you change that variable outside of the array, it also changes inside the array but you don't want it to then it is a really simple solution.</p>
<p>When you are saving the variable to the array you should turn it into a string by sim... | 0 | 2013-06-14T19:16:08Z | [
"python",
"object"
] |
Python shelve OutOfMemory error | 2,196,969 | <p>I have some data stored in a DB that I want to process. DB access is painfully slow, so I decided to load all data in a dictionary before any processing. However, due to the huge size of the data stored, I get an out of memory error (I see more than 2 gigs being used). So I decided to use a disk data structure, and ... | 1 | 2010-02-04T02:27:54Z | 2,197,129 | <p>Using the <code>sqlite3</code> module is probably your best choice here. You might be able to use sqlite entirely in memory anyway since its memory footprint might be a bit smaller than using python objects anyway. It's generally a better choice than using <code>shelve</code> anyway; <code>shelve</code> uses <code>p... | 0 | 2010-02-04T03:24:50Z | [
"python",
"dictionary",
"persistence",
"shelve",
"out-of-memory"
] |
Python shelve OutOfMemory error | 2,196,969 | <p>I have some data stored in a DB that I want to process. DB access is painfully slow, so I decided to load all data in a dictionary before any processing. However, due to the huge size of the data stored, I get an out of memory error (I see more than 2 gigs being used). So I decided to use a disk data structure, and ... | 1 | 2010-02-04T02:27:54Z | 2,197,247 | <p><code>writeback=True</code> forces the shelf to keep in-memory any item ever fetched, and write them back when the shelf is closed. So, it consumes much more memory, and slows down closing.</p>
<p>The advantage of the parameter is that, with it, you <strong>don't</strong> need the contorted code you show in your co... | 6 | 2010-02-04T04:03:09Z | [
"python",
"dictionary",
"persistence",
"shelve",
"out-of-memory"
] |
How to add a timeout to a function in Python | 2,196,999 | <p>Many attempts have been made in the past to add timeout functionality in Python such that when a specified time limit expired, waiting code could move on. Unfortunately, previous recipes either allowed the running function to continue running and consuming resources or else killed the function using a platform-speci... | 23 | 2010-02-04T02:38:38Z | 2,197,101 | <p>The principal problem with your code is the overuse of the double underscore namespace conflict prevention in a class that isn't intended to be subclassed at all.</p>
<p>In general, <code>self.__foo</code> is a code smell that should be accompanied by a comment along the lines of <code># This is a mixin and we don'... | 13 | 2010-02-04T03:16:19Z | [
"python",
"process",
"asynchronous",
"cross-platform",
"timeout"
] |
How to add a timeout to a function in Python | 2,196,999 | <p>Many attempts have been made in the past to add timeout functionality in Python such that when a specified time limit expired, waiting code could move on. Unfortunately, previous recipes either allowed the running function to continue running and consuming resources or else killed the function using a platform-speci... | 23 | 2010-02-04T02:38:38Z | 2,197,148 | <p>This is how to get the decorator syntax Jerub mentioned</p>
<pre><code>def timeout(limit=None):
if limit is None:
limit = DEFAULT_TIMEOUT
if limit <= 0:
raise TimeoutError() # why not ValueError here?
def wrap(function):
return _Timeout(function,limit)
return wrap
@timeou... | 6 | 2010-02-04T03:32:02Z | [
"python",
"process",
"asynchronous",
"cross-platform",
"timeout"
] |
How to add a timeout to a function in Python | 2,196,999 | <p>Many attempts have been made in the past to add timeout functionality in Python such that when a specified time limit expired, waiting code could move on. Unfortunately, previous recipes either allowed the running function to continue running and consuming resources or else killed the function using a platform-speci... | 23 | 2010-02-04T02:38:38Z | 40,140,563 | <p>The <a href="https://pypi.python.org/pypi/Pebble" rel="nofollow">Pebble</a> library was designed to offer cross-platform implementation capable of dealing with problematic logic which could <a href="http://pythonhosted.org/Pebble/#concurrent-functions" rel="nofollow">crash, segfault or run indefinitely</a>. </p>
<... | 0 | 2016-10-19T20:05:28Z | [
"python",
"process",
"asynchronous",
"cross-platform",
"timeout"
] |
Does PySVN need Subversion installed? | 2,197,156 | <p>I have python script that uses pysvn and checks out or updates a local copy obtained also from a local repo.</p>
<pre><code>client.checkout(url,
path,
revision=pysvn.Revision(pysvn.opt_revision_kind.number, RevNumber),
ignore_externals=False)
</code></pre>
<p>I am running this on a windows machine in which I have... | 1 | 2010-02-04T03:34:47Z | 2,197,183 | <p>This is because your Ubuntu is accessing the repo with too old a version of the SVN API.</p>
<p>The windows one is fine because it is obviously using a newer version.</p>
<p>According the <a href="http://pysvn.tigris.org/project_downloads.html" rel="nofollow">PySVN download page</a>:</p>
<blockquote>
<p>Windows... | 1 | 2010-02-04T03:44:55Z | [
"python",
"windows",
"svn",
"ubuntu-9.04",
"pysvn"
] |
Trouble with rdfstore with mysql - how to debug? | 2,197,157 | <p>I have a mysql server running and can connect to it from my Django ORM. Can't connect using the rdflib functionality. How can I debug this problem? Thanks.</p>
<p>rdflib 2.4.2, python 2.6, MySQL Community 5.1.42 </p>
<p>Trace: </p>
<pre><code>configString = "host=localhost,user=root,password=...,db=..."
print ... | 0 | 2010-02-04T03:34:53Z | 2,203,503 | <p>I commented code in the rdflib/store directory in MySQL.py and now it all works:</p>
<pre><code># test_db = MySQLdb.connect(user=configDict['user'],
# passwd=configDict['password'],
# db='test',
# port=configDict['port'],
# ... | 1 | 2010-02-04T21:51:45Z | [
"python",
"mysql",
"rdflib",
"rdfstore",
"mysql-error-1049"
] |
Why are empty strings returned in split() results? | 2,197,451 | <p>What is the point of <code>'/segment/segment/'.split('/')</code> returning <code>['', 'segment', 'segment', '']</code>?</p>
<p>Notice the empty elements. If you're splitting on a delimiter that happens to be at position one and at the very end of a string, what extra value does it give you to have the empty string ... | 58 | 2010-02-04T05:14:52Z | 2,197,481 | <p>I'm not sure what kind of answer you're looking for? You get three matches because you have three delimiters. If you don't want that empty one, just use:</p>
<pre><code>'/segment/segment/'.strip('/').split('/')
</code></pre>
| 5 | 2010-02-04T05:21:39Z | [
"python",
"string",
"split"
] |
Why are empty strings returned in split() results? | 2,197,451 | <p>What is the point of <code>'/segment/segment/'.split('/')</code> returning <code>['', 'segment', 'segment', '']</code>?</p>
<p>Notice the empty elements. If you're splitting on a delimiter that happens to be at position one and at the very end of a string, what extra value does it give you to have the empty string ... | 58 | 2010-02-04T05:14:52Z | 2,197,493 | <p><code>str.split</code> complements <code>str.join</code>, so</p>
<pre><code>"/".join(['', 'segment', 'segment', ''])
</code></pre>
<p>gets you back the original string.</p>
<p>If the empty strings were not there, the first and last <code>'/'</code> would be missing after the <code>join()</code></p>
| 85 | 2010-02-04T05:24:44Z | [
"python",
"string",
"split"
] |
Why are empty strings returned in split() results? | 2,197,451 | <p>What is the point of <code>'/segment/segment/'.split('/')</code> returning <code>['', 'segment', 'segment', '']</code>?</p>
<p>Notice the empty elements. If you're splitting on a delimiter that happens to be at position one and at the very end of a string, what extra value does it give you to have the empty string ... | 58 | 2010-02-04T05:14:52Z | 2,197,494 | <p>Well, it lets you know there was a delimiter there. So, seeing 4 results lets you know you had 3 delimiters. This gives you the power to do whatever you want with this information, rather than having Python drop the empty elements, and then making you manually check for starting or ending delimiters if you need to k... | 5 | 2010-02-04T05:24:49Z | [
"python",
"string",
"split"
] |
Why are empty strings returned in split() results? | 2,197,451 | <p>What is the point of <code>'/segment/segment/'.split('/')</code> returning <code>['', 'segment', 'segment', '']</code>?</p>
<p>Notice the empty elements. If you're splitting on a delimiter that happens to be at position one and at the very end of a string, what extra value does it give you to have the empty string ... | 58 | 2010-02-04T05:14:52Z | 2,197,575 | <p>There are two main points to consider here:</p>
<ul>
<li>Expecting the result of <code>'/segment/segment/'.split('/')</code> to be equal to <code>['segment', 'segment']</code> is reasonable, but then this loses information. If <code>split()</code> worked the way you wanted, if I tell you that <code>a.split('/') ==... | 21 | 2010-02-04T05:44:24Z | [
"python",
"string",
"split"
] |
Why are empty strings returned in split() results? | 2,197,451 | <p>What is the point of <code>'/segment/segment/'.split('/')</code> returning <code>['', 'segment', 'segment', '']</code>?</p>
<p>Notice the empty elements. If you're splitting on a delimiter that happens to be at position one and at the very end of a string, what extra value does it give you to have the empty string ... | 58 | 2010-02-04T05:14:52Z | 2,197,605 | <p>Having <code>x.split(y)</code> always return a list of <code>1 + x.count(y)</code> items is a precious regularity -- as @gnibbler's already pointed out it makes <code>split</code> and <code>join</code> exact inverses of each other (as they obviously should be), it also precisely maps the semantics of all kinds of de... | 7 | 2010-02-04T05:50:30Z | [
"python",
"string",
"split"
] |
Why are empty strings returned in split() results? | 2,197,451 | <p>What is the point of <code>'/segment/segment/'.split('/')</code> returning <code>['', 'segment', 'segment', '']</code>?</p>
<p>Notice the empty elements. If you're splitting on a delimiter that happens to be at position one and at the very end of a string, what extra value does it give you to have the empty string ... | 58 | 2010-02-04T05:14:52Z | 34,844,548 | <p>More generally, to remove empty strings returned in <code>split()</code> results, you may want to look at the <a href="https://docs.python.org/2/library/functions.html#filter" rel="nofollow"><code>filter</code></a> function. </p>
<p>Example:</p>
<pre><code>filter(None, '/segment/segment/'.split('/'))
</code></pre>... | 0 | 2016-01-17T22:30:49Z | [
"python",
"string",
"split"
] |
Why doesn't super(Thread, self).__init__() work for a threading.Thread subclass? | 2,197,563 | <p>Every object I know of in Python can take care of its base class initialization by calling:</p>
<pre><code>super(BaseClass, self).__init__()
</code></pre>
<p>This doesn't seem to be the case with a subclass of <code>threading.Thread</code>, since if I try this in <code>SubClass.__init__()</code>, I get:</p>
<pre>... | 13 | 2010-02-04T05:42:22Z | 2,197,625 | <p>This works fine:</p>
<pre><code>>>> class MyThread(threading.Thread):
... def __init__(self):
... super(MyThread, self).__init__()
</code></pre>
<p>I think your code's bug is that you're passing the <strong>base</strong> class, rather than the <strong>current</strong> class, to <code>super</code> --... | 37 | 2010-02-04T05:56:02Z | [
"python",
"multithreading"
] |
Complex SQL optimization vs. general-purpose language | 2,197,579 | <p>How might I optimize this query? The schema:</p>
<pre><code>mysql> show columns from transactionlog;
+---------------+-------------------------------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------... | 3 | 2010-02-04T05:45:34Z | 2,197,712 | <p>Use:</p>
<pre><code> SELECT CONCAT(x.weight, ' ', GROUP_CONCAT(t.id SEPARATOR ' '), '\n')
FROM TRANSACTIONLOG t
JOIN (SELECT tl.tableid,
tl.tupleid,
COUNT(DISTINCT tl.transactionid) AS weight
FROM TRANSACTIONLOG tl
WHERE tl.querytype = 'update'
... | 0 | 2010-02-04T06:15:07Z | [
"python",
"sql",
"mysql",
"optimization"
] |
How to Handle EOFError for raw_input() in python in Mac OS X | 2,197,891 | <p>My python program has two calls to <code>raw_input()</code> </p>
<p>The first <code>raw_input()</code> is to take multiline input from the user. The user can issue Ctrl+D (Ctrl+Z in windows) for the end of input.</p>
<p>Second <code>raw_input()</code> should take another input from user with (y/n) type prompt.</p>... | 4 | 2010-02-04T06:53:13Z | 2,197,908 | <p>It's quite normal that when standard input is terminated (by hitting control-D, in Unix-derived systems -- I think it's control-Z in Windows), it <em>stays</em> terminated thereafter (unless you close and re-open it in the meantime, of course).</p>
| 6 | 2010-02-04T06:57:26Z | [
"python",
"osx",
"eof",
"eoferror"
] |
How do I update my version of Django? | 2,197,919 | <p>I currently have it installed and it's running a website.</p>
<p><a href="http://www.djangoproject.com/download/">http://www.djangoproject.com/download/</a>
This is the new version. How do I upgrade it? (How do I install the new version over my current one?)</p>
| 6 | 2010-02-04T07:00:58Z | 2,197,936 | <p>read about this in :</p>
<p><a href="http://docs.djangoproject.com/en/dev/topics/install/" rel="nofollow">http://docs.djangoproject.com/en/dev/topics/install/</a></p>
<h3>For installing Django to be able to update to the latest code in trunk:</h3>
<blockquote>
<p>If you'd like to be able to update
your Django... | 5 | 2010-02-04T07:04:45Z | [
"python",
"django"
] |
How do I update my version of Django? | 2,197,919 | <p>I currently have it installed and it's running a website.</p>
<p><a href="http://www.djangoproject.com/download/">http://www.djangoproject.com/download/</a>
This is the new version. How do I upgrade it? (How do I install the new version over my current one?)</p>
| 6 | 2010-02-04T07:00:58Z | 2,198,201 | <p>First of all, don't. Install/upgrade it on your staging server first and test your app to make sure that it still works. Only after complete testing should you cut over to the new version on your production website.</p>
| 4 | 2010-02-04T08:19:38Z | [
"python",
"django"
] |
python file reading | 2,197,958 | <p>I have file /tmp/gs.pid with content</p>
<pre><code>client01: 25778
</code></pre>
<p>I would like retrieve the second word from it.
ie. <code>25778</code>.</p>
<p>I have tried below code but it didn't work.</p>
<pre><code>>>> f=open ("/tmp/gs.pid","r")
>>> for line in f:
... word=line.str... | 1 | 2010-02-04T07:12:30Z | 2,197,963 | <p>Try this:</p>
<pre><code>>>> f = open("/tmp/gs.pid", "r")
>>> for line in f:
... word = line.strip().split()[1].lower()
... print " -->", word
>>> f.close()
</code></pre>
<p>It will print the second word of every line in lowercase. <code>split()</code> will take your line ... | 7 | 2010-02-04T07:14:26Z | [
"python",
"file",
"string"
] |
python file reading | 2,197,958 | <p>I have file /tmp/gs.pid with content</p>
<pre><code>client01: 25778
</code></pre>
<p>I would like retrieve the second word from it.
ie. <code>25778</code>.</p>
<p>I have tried below code but it didn't work.</p>
<pre><code>>>> f=open ("/tmp/gs.pid","r")
>>> for line in f:
... word=line.str... | 1 | 2010-02-04T07:12:30Z | 2,197,970 | <pre><code>word="client01: 25778"
pid=word.split(": ")[1] #or word.split()[1] to split from the separator
</code></pre>
| 1 | 2010-02-04T07:16:14Z | [
"python",
"file",
"string"
] |
python file reading | 2,197,958 | <p>I have file /tmp/gs.pid with content</p>
<pre><code>client01: 25778
</code></pre>
<p>I would like retrieve the second word from it.
ie. <code>25778</code>.</p>
<p>I have tried below code but it didn't work.</p>
<pre><code>>>> f=open ("/tmp/gs.pid","r")
>>> for line in f:
... word=line.str... | 1 | 2010-02-04T07:12:30Z | 2,197,971 | <p>If all lines are of the form <code>abc: def</code>, you can extract the 2nd part with</p>
<pre><code>second_part = line[line.find(": ")+2:]
</code></pre>
<p>If not you need to verify <code>line.find(": ")</code> really returns a nonnegative number first.</p>
<pre><code>with open("/tmp/gs.pid") as f:
for line i... | 1 | 2010-02-04T07:16:13Z | [
"python",
"file",
"string"
] |
python file reading | 2,197,958 | <p>I have file /tmp/gs.pid with content</p>
<pre><code>client01: 25778
</code></pre>
<p>I would like retrieve the second word from it.
ie. <code>25778</code>.</p>
<p>I have tried below code but it didn't work.</p>
<pre><code>>>> f=open ("/tmp/gs.pid","r")
>>> for line in f:
... word=line.str... | 1 | 2010-02-04T07:12:30Z | 2,198,074 | <pre><code>>>> open("/tmp/gs.pid").read().split()[1]
'25778'
</code></pre>
| 0 | 2010-02-04T07:48:49Z | [
"python",
"file",
"string"
] |
Convert "little endian" hex string to IP address in Python | 2,197,974 | <p>What's the best way to turn a string in this form into an IP address: <code>"0200A8C0"</code>. The "octets" present in the string are in reverse order, i.e. the given example string should generate <code>192.168.0.2</code>.</p>
| 4 | 2010-02-04T07:16:48Z | 2,198,008 | <p>You could do something like this:</p>
<pre><code>>>> s = '0200A8C0'
>>> octets = [s[i:i+2] for i in range(0, len(s), 2)]
>>> ip = [int(i, 16) for i in reversed(octets)]
>>> ip_formatted = '.'.join(str(i) for i in ip)
>>> print ip_formatted
192.168.0.2
</code></pre>
<p>T... | 2 | 2010-02-04T07:25:27Z | [
"python",
"sockets",
"ip-address",
"endianness"
] |
Convert "little endian" hex string to IP address in Python | 2,197,974 | <p>What's the best way to turn a string in this form into an IP address: <code>"0200A8C0"</code>. The "octets" present in the string are in reverse order, i.e. the given example string should generate <code>192.168.0.2</code>.</p>
| 4 | 2010-02-04T07:16:48Z | 2,198,027 | <pre><code>>>> s = "0200A8C0"
>>> bytes = ["".join(x) for x in zip(*[iter(s)]*2)]
>>> bytes
['02', '00', 'A8', 'C0']
>>> bytes = [int(x, 16) for x in bytes]
>>> bytes
[2, 0, 168, 192]
>>> print ".".join(str(x) for x in reversed(bytes))
192.168.0.2
</code></pre>
<p>... | 4 | 2010-02-04T07:32:27Z | [
"python",
"sockets",
"ip-address",
"endianness"
] |
Convert "little endian" hex string to IP address in Python | 2,197,974 | <p>What's the best way to turn a string in this form into an IP address: <code>"0200A8C0"</code>. The "octets" present in the string are in reverse order, i.e. the given example string should generate <code>192.168.0.2</code>.</p>
| 4 | 2010-02-04T07:16:48Z | 2,198,052 | <p>Network address manipulation is provided by the socket module.</p>
<blockquote>
<p><a href="http://docs.python.org/library/socket.html#socket.inet_ntoa"><code>socket.inet_ntoa(packed_ip)</code></a></p>
<p>Convert a 32-bit packed IPv4 address (a string four characters in length) to its standard dotted-quad st... | 21 | 2010-02-04T07:39:24Z | [
"python",
"sockets",
"ip-address",
"endianness"
] |
Convert "little endian" hex string to IP address in Python | 2,197,974 | <p>What's the best way to turn a string in this form into an IP address: <code>"0200A8C0"</code>. The "octets" present in the string are in reverse order, i.e. the given example string should generate <code>192.168.0.2</code>.</p>
| 4 | 2010-02-04T07:16:48Z | 2,198,054 | <p>My try:</p>
<pre><code>a = '0200A8C0'
indices = range(0, 8, 2)
data = [str(int(a[x:x+2], 16)) for x in indices]
'.'.join(reversed(data))
</code></pre>
| 0 | 2010-02-04T07:40:11Z | [
"python",
"sockets",
"ip-address",
"endianness"
] |
how to use array in django | 2,197,975 | <p>I have a db table which has an integer array. But how can I add this field in my model? I tried writing it using <code>IntegerField</code> but on save it is giving error</p>
<pre><code>int() argument must be a string or a number, not 'list
</code></pre>
<p>How can I add this field to my model? I am using this fiel... | 2 | 2010-02-04T07:17:41Z | 2,198,033 | <p>I would look into <a href="http://en.wikipedia.org/wiki/Database_normalization" rel="nofollow">database normalization</a>. In particular, your database is not even in 1st normal form, the first and probably most significant of the normal forms which states that normalized data should not contain any repeating groups... | 1 | 2010-02-04T07:33:10Z | [
"python",
"django",
"django-models"
] |
how to use array in django | 2,197,975 | <p>I have a db table which has an integer array. But how can I add this field in my model? I tried writing it using <code>IntegerField</code> but on save it is giving error</p>
<pre><code>int() argument must be a string or a number, not 'list
</code></pre>
<p>How can I add this field to my model? I am using this fiel... | 2 | 2010-02-04T07:17:41Z | 2,198,128 | <p>Clueless' answer is probably the best you can get, but in case you still want to store array of numbers in single field, you can do this - either by manually e.g. pickling it and then storing to TextField, or by writing custom model field that do something like this for you automatically. </p>
<p>Here's the doc: <a... | 1 | 2010-02-04T08:04:01Z | [
"python",
"django",
"django-models"
] |
how to use array in django | 2,197,975 | <p>I have a db table which has an integer array. But how can I add this field in my model? I tried writing it using <code>IntegerField</code> but on save it is giving error</p>
<pre><code>int() argument must be a string or a number, not 'list
</code></pre>
<p>How can I add this field to my model? I am using this fiel... | 2 | 2010-02-04T07:17:41Z | 2,198,402 | <p>You may be interested in using a <a href="http://docs.djangoproject.com/en/dev/ref/models/fields/#commaseparatedintegerfield"><code>CommaSeparatedIntegerField</code></a>.</p>
<p>If you've got a list of integers like this:</p>
<pre><code>my_ints = [1,2,3,4,5]
</code></pre>
<p>and a model like this:</p>
<pre><code... | 7 | 2010-02-04T09:04:17Z | [
"python",
"django",
"django-models"
] |
how to use array in django | 2,197,975 | <p>I have a db table which has an integer array. But how can I add this field in my model? I tried writing it using <code>IntegerField</code> but on save it is giving error</p>
<pre><code>int() argument must be a string or a number, not 'list
</code></pre>
<p>How can I add this field to my model? I am using this fiel... | 2 | 2010-02-04T07:17:41Z | 2,303,052 | <p>I got it working by saying textfield in my model.Since i am only using that field for reading it doesnot effect me</p>
| 1 | 2010-02-20T17:52:25Z | [
"python",
"django",
"django-models"
] |
Importing globally and locally | 2,198,082 | <p>I created a module which is going to be used in several python scripts. The structure is as follows:</p>
<p>Main file:</p>
<pre><code>import numpy as np
from mymodule import newfunction
f = np.arange(100,200,1)
a = np.zeros(np.shape(f))
c = newfunction(f)
</code></pre>
<p>mymodule.py:</p>
<pre><code>def newfunct... | 3 | 2010-02-04T07:50:24Z | 2,198,099 | <p>mymodule.py doesn't see:</p>
<pre><code> import numpy as np
</code></pre>
<p>statement(s). "import" statement in Python doesn't work like #include in C++, it merely creates new dictionary of objects contained in imported module. If you want to use 'np' identifier within that dictionary, you have to explicitly imp... | 3 | 2010-02-04T07:53:40Z | [
"python",
"import",
"module"
] |
Getting python MySQLdb to run on Ubuntu | 2,198,260 | <p>I created a virtualbox with a fresh install of ubuntu 9.10.</p>
<p>I am trying to get MySQLdb to run on python but I'm failing at the <code>import MySQLdb</code></p>
<p>I first tried <code>sudo easy_install MySQL_python-1.2.3c1-py2.6-linux-i686.egg</code> and then <code>sudo apt-get install python-mysqldb</code>.... | 9 | 2010-02-04T08:32:56Z | 2,198,288 | <p>Your MySQLdb egg installation looks like it is not working properly. You should go into /usr/local/lib/python2.6/dist-packages and remove it.</p>
<p>The Ubuntu python-mysqldb package should work fine. Unless you have a good reason, you should stick to your distribution's package manager when installing new software... | 7 | 2010-02-04T08:38:55Z | [
"python",
"ubuntu-9.10",
"mysql"
] |
How to turn a SVG image to a SDL surface or an array of RGBA pixels with python? | 2,198,499 | <p>I'm guessing it has to be done with the aid of some sort of framework. Google gives libCairo as the most common result, but that is way too many dependencies.</p>
<p>I mean something that would work on Win/Lin/OSX, be non-GPL, python-compatible, freely re-distributable. And preferably a few hundred KB in size.</p>
... | 2 | 2010-02-04T09:23:55Z | 2,223,710 | <p>Try python-rsvg from <a href="http://www.cairographics.org/pyrsvg/" rel="nofollow">http://www.cairographics.org/pyrsvg/</a></p>
<p>Too many dependencies? Really? <a href="http://www.cairographics.org/download/" rel="nofollow">http://www.cairographics.org/download/</a> has Windows binaries. It depends on <code>libpn... | 1 | 2010-02-08T17:58:06Z | [
"python",
"svg",
"sdl",
"rgb"
] |
no procedural code and non mvc in ruby and python? | 2,198,562 | <p>i know that these 2 languages require oop.</p>
<p>but inside the classes, could you have procedural code?</p>
<p>and for the mvc part, that pattern comes with their frameworks right?</p>
<p>nothing to do with the actual language itself?</p>
| 0 | 2010-02-04T09:35:40Z | 2,198,616 | <p>Neither of these languages require OOP, especially Python. In Python you can write as many ordinary functions as you want, and there are plenty of modules which don't define any classes. In Ruby you can do the same thing, except instead of functions you have methods on a module.</p>
<p>You are correct that MVC is... | 4 | 2010-02-04T09:44:59Z | [
"python",
"ruby",
"model-view-controller",
"oop"
] |
no procedural code and non mvc in ruby and python? | 2,198,562 | <p>i know that these 2 languages require oop.</p>
<p>but inside the classes, could you have procedural code?</p>
<p>and for the mvc part, that pattern comes with their frameworks right?</p>
<p>nothing to do with the actual language itself?</p>
| 0 | 2010-02-04T09:35:40Z | 2,198,673 | <p>They don't require OOP, but they do require procedural code, as they are imperative languages, and not functional ones. You can use some functional techniques.</p>
<p>There are plenty of frameworks that use MVC for both languages, yes.</p>
| 3 | 2010-02-04T09:51:32Z | [
"python",
"ruby",
"model-view-controller",
"oop"
] |
What does pk__in mean in Django? | 2,198,635 | <pre><code>Model.objects.filter(pk__in=[list of ids])
</code></pre>
<p>and </p>
<pre><code>Model.objects.filter(pk__in=[1,2,3])
</code></pre>
<p>How do I show this data in a template?</p>
<pre><code>def xx(request):
return HttpResponse(Model.objects.filter(pk__in=[1,2,3]))
</code></pre>
| 3 | 2010-02-04T09:48:05Z | 2,198,657 | <p>It means, give me all objects of model <code>Model</code> that either have <code>1</code>,<code>2</code> or <code>3</code> as their primary key.</p>
<p>See <a href="http://docs.djangoproject.com/en/1.1/ref/models/querysets/#in" rel="nofollow">Field lookups - in</a>.</p>
<p>You get a list of objects back you can sh... | 12 | 2010-02-04T09:50:25Z | [
"python",
"django"
] |
How to automate updating a trac wiki page? | 2,198,701 | <p>I have a trac wiki page I'd like to update automatically on a regular basis (say, once an hour) with data fetched by a script.</p>
<p>I can get the script to generate the wiki markup.</p>
<p>How would you then upload that to the trac page? I want to replace the whole body of the page.</p>
<p>I would prefer a solu... | 1 | 2010-02-04T09:54:51Z | 2,198,885 | <p>You can install the Trac XMLRPC plugin:</p>
<p><a href="http://trac-hacks.org/wiki/XmlRpcPlugin" rel="nofollow">http://trac-hacks.org/wiki/XmlRpcPlugin</a></p>
<p>and then use the xmlrpc client library from the standard library. Then you'll be able to manipulate most aspects of Trac (tickets, wiki pages, etc) from... | 3 | 2010-02-04T10:27:46Z | [
"python",
"automation",
"wiki",
"trac"
] |
How to automate updating a trac wiki page? | 2,198,701 | <p>I have a trac wiki page I'd like to update automatically on a regular basis (say, once an hour) with data fetched by a script.</p>
<p>I can get the script to generate the wiki markup.</p>
<p>How would you then upload that to the trac page? I want to replace the whole body of the page.</p>
<p>I would prefer a solu... | 1 | 2010-02-04T09:54:51Z | 4,769,423 | <p>I had a hard time getting the XmlRpcPlugin to work, details in the trac ticket: <a href="http://trac-hacks.org/ticket/6035#comment:7" rel="nofollow">http://trac-hacks.org/ticket/6035#comment:7</a></p>
| 0 | 2011-01-22T17:39:27Z | [
"python",
"automation",
"wiki",
"trac"
] |
How to automate updating a trac wiki page? | 2,198,701 | <p>I have a trac wiki page I'd like to update automatically on a regular basis (say, once an hour) with data fetched by a script.</p>
<p>I can get the script to generate the wiki markup.</p>
<p>How would you then upload that to the trac page? I want to replace the whole body of the page.</p>
<p>I would prefer a solu... | 1 | 2010-02-04T09:54:51Z | 11,199,321 | <p>u can try and use
<a href="http://perlmediawikiapi.wikia.com/wiki/Perl_MediaWiki_API_Wiki" rel="nofollow">http://perlmediawikiapi.wikia.com/wiki/Perl_MediaWiki_API_Wiki</a></p>
| -1 | 2012-06-26T00:37:39Z | [
"python",
"automation",
"wiki",
"trac"
] |
Problem writing a database query | 2,198,820 | <p>I have two models, <code>Location</code> and <code>Event</code>, that are linked by ForeignKey on the <code>Event</code> model. The models break down as follows:</p>
<pre><code>class Location(models.Model):
city = models.CharField('city', max_length=25)
slug = models.SlugField('slug')
class Event(models.Mo... | 2 | 2010-02-04T10:15:23Z | 2,198,854 | <p>I think you should look at django aggregation<a href="http://docs.djangoproject.com/en/dev/topics/db/aggregation/" rel="nofollow">link text</a>, so your result will be agragated by location with a condition to filter future/expired events and min(start_time) returns next event time</p>
| 0 | 2010-02-04T10:22:02Z | [
"python",
"sql",
"django"
] |
Problem writing a database query | 2,198,820 | <p>I have two models, <code>Location</code> and <code>Event</code>, that are linked by ForeignKey on the <code>Event</code> model. The models break down as follows:</p>
<pre><code>class Location(models.Model):
city = models.CharField('city', max_length=25)
slug = models.SlugField('slug')
class Event(models.Mo... | 2 | 2010-02-04T10:15:23Z | 2,198,866 | <pre><code>select id, (
select * from event
where location=location.id
and start_date>NOW()
order by start_date asc
limit 1
)
from location
</code></pre>
| 1 | 2010-02-04T10:23:46Z | [
"python",
"sql",
"django"
] |
Problem writing a database query | 2,198,820 | <p>I have two models, <code>Location</code> and <code>Event</code>, that are linked by ForeignKey on the <code>Event</code> model. The models break down as follows:</p>
<pre><code>class Location(models.Model):
city = models.CharField('city', max_length=25)
slug = models.SlugField('slug')
class Event(models.Mo... | 2 | 2010-02-04T10:15:23Z | 2,199,325 | <p>"Ideally I would like to make this in a single query (I don't want to run a query for every location, as this would cause a lot of unnecessary hits to the database)."</p>
<p>This is a false assumption.</p>
<p>1) Django's ORM uses a cache. It may not query the database as often as you think. Databases have a cach... | 1 | 2010-02-04T11:46:26Z | [
"python",
"sql",
"django"
] |
Problem writing a database query | 2,198,820 | <p>I have two models, <code>Location</code> and <code>Event</code>, that are linked by ForeignKey on the <code>Event</code> model. The models break down as follows:</p>
<pre><code>class Location(models.Model):
city = models.CharField('city', max_length=25)
slug = models.SlugField('slug')
class Event(models.Mo... | 2 | 2010-02-04T10:15:23Z | 2,199,603 | <p>Something like the following may be useful:</p>
<pre><code>SELECT * FROM EVENTS V
WHERE (V.LOCATION, V.START_DATE) IN
(SELECT E.LOCATION, MIN(E.START_DATE)
FROM EVENTS E
WHERE E.START_DATE >= NOW
GROUP BY E.LOCATION)
</code></pre>
<p>Share and enjoy.</p>
| 0 | 2010-02-04T12:30:24Z | [
"python",
"sql",
"django"
] |
django error:connection to localhost;3312 failed ,i used django-sphinx | 2,198,899 | <pre><code>Traceback (most recent call last):
File "D:\Python25\Lib\site-packages\django\core\servers\basehttp.py", line 280, in run
self.finish_response()
File "D:\Python25\Lib\site-packages\django\core\servers\basehttp.py", line 319, in finish_response
for data in self.result:
File "D:\Python25\Lib\s... | 0 | 2010-02-04T10:29:48Z | 2,200,071 | <p>You don't use a semicolon to separate host and port, you use a colon: i.e. <code>localhost:3312</code> instead of <code>localhost;3312</code>.</p>
| 1 | 2010-02-04T13:47:36Z | [
"python",
"django",
"django-sphinx"
] |
django error:connection to localhost;3312 failed ,i used django-sphinx | 2,198,899 | <pre><code>Traceback (most recent call last):
File "D:\Python25\Lib\site-packages\django\core\servers\basehttp.py", line 280, in run
self.finish_response()
File "D:\Python25\Lib\site-packages\django\core\servers\basehttp.py", line 319, in finish_response
for data in self.result:
File "D:\Python25\Lib\s... | 0 | 2010-02-04T10:29:48Z | 4,054,814 | <p>What version of sphinx? django-sphinx? There has been a change in the <code>port</code> that is used by sphinx as setup in <code>sphinx.conf</code>. </p>
<p>The <code>searchd</code> now runs on <code>127.0.0.1:9312</code>. You can of course change this port in <code>sphinx.con</code>. Restart your <code>searchd</co... | 1 | 2010-10-29T18:36:46Z | [
"python",
"django",
"django-sphinx"
] |
django error:connection to localhost;3312 failed ,i used django-sphinx | 2,198,899 | <pre><code>Traceback (most recent call last):
File "D:\Python25\Lib\site-packages\django\core\servers\basehttp.py", line 280, in run
self.finish_response()
File "D:\Python25\Lib\site-packages\django\core\servers\basehttp.py", line 319, in finish_response
for data in self.result:
File "D:\Python25\Lib\s... | 0 | 2010-02-04T10:29:48Z | 13,884,306 | <p>I think it's worth noting that if you have forgotten to turn sphinx on you will get this error message.</p>
| 0 | 2012-12-14T18:26:59Z | [
"python",
"django",
"django-sphinx"
] |
wx.TextCtrl and wx.Validator | 2,198,903 | <p>I need to validate the textboxes with wx.Textvalidator.
Any please help me to do this?</p>
<p>How can i use wx.FILTER_ALPHA with validators and if the user is giving a wrong input how can i give them a message?</p>
<p>i need to validate all the inputs when clicking on the save button?</p>
<p>can any one provide m... | 5 | 2010-02-04T10:30:26Z | 2,203,002 | <p>This is a feature of wxWidgets, and is not implemented in wxPython.</p>
<p><a href="http://www.wxpython.org/docs/api/wx.TextValidator-class.html">http://www.wxpython.org/docs/api/wx.TextValidator-class.html</a> - not found</p>
<p>while:</p>
<p><a href="http://docs.wxwidgets.org/trunk/classwx_text_validator.html">... | 5 | 2010-02-04T20:36:15Z | [
"python",
"wxpython"
] |
wx.TextCtrl and wx.Validator | 2,198,903 | <p>I need to validate the textboxes with wx.Textvalidator.
Any please help me to do this?</p>
<p>How can i use wx.FILTER_ALPHA with validators and if the user is giving a wrong input how can i give them a message?</p>
<p>i need to validate all the inputs when clicking on the save button?</p>
<p>can any one provide m... | 5 | 2010-02-04T10:30:26Z | 2,329,625 | <p>I was unable to make the sample code work properly within my code (not using a dialog at all but a txtctrl within a panel), even though it works correctly in the demo (go figure).</p>
<p>I ended up using a snippet from another site and feel obligated to document it here:</p>
<pre><code>self.tc.GetValidator().Valid... | 1 | 2010-02-24T21:19:39Z | [
"python",
"wxpython"
] |
wx.TextCtrl and wx.Validator | 2,198,903 | <p>I need to validate the textboxes with wx.Textvalidator.
Any please help me to do this?</p>
<p>How can i use wx.FILTER_ALPHA with validators and if the user is giving a wrong input how can i give them a message?</p>
<p>i need to validate all the inputs when clicking on the save button?</p>
<p>can any one provide m... | 5 | 2010-02-04T10:30:26Z | 3,403,937 | <p>The problem is probably thast you have the ctrl in a panel within the dialog. Set the recursive flag on the dialog to enable validation code to look for controls with validators recursively:</p>
<pre><code>self.SetExtraStyle(wx.WS_EX_VALIDATE_RECURSIVELY)
</code></pre>
| 2 | 2010-08-04T08:47:50Z | [
"python",
"wxpython"
] |
wx.TextCtrl and wx.Validator | 2,198,903 | <p>I need to validate the textboxes with wx.Textvalidator.
Any please help me to do this?</p>
<p>How can i use wx.FILTER_ALPHA with validators and if the user is giving a wrong input how can i give them a message?</p>
<p>i need to validate all the inputs when clicking on the save button?</p>
<p>can any one provide m... | 5 | 2010-02-04T10:30:26Z | 3,405,979 | <p>There are lots of ways to do this. The wxPython demo actually shows how to allow only digits or only alpha. Here's an example based on that:</p>
<pre><code>import wx
import string
########################################################################
class CharValidator(wx.PyValidator):
''' Validates data as... | 4 | 2010-08-04T13:30:19Z | [
"python",
"wxpython"
] |
Is there an API for Wireshark, to develop programs/plugins that interact with it/enhance it? | 2,198,972 | <p>Googling didn't give me great results. Is there any sort of API for Wireshark that abstracts away from the main source code so we can develop programs that interact with it and deal with the data it provides?</p>
<p><strong>edit:</strong> I appreciate the suggestions for different ways to receive packets, but I w... | 15 | 2010-02-04T10:43:04Z | 2,199,007 | <p>I wasn't able to find any information indicating that to be possible in the <a href="http://www.wireshark.org/docs/wsdg_html_chunked/" rel="nofollow">developer's guide</a>. So that seems indicate "no".</p>
| 0 | 2010-02-04T10:48:54Z | [
"c++",
"python",
"api",
"wireshark",
"packet-sniffers"
] |
Is there an API for Wireshark, to develop programs/plugins that interact with it/enhance it? | 2,198,972 | <p>Googling didn't give me great results. Is there any sort of API for Wireshark that abstracts away from the main source code so we can develop programs that interact with it and deal with the data it provides?</p>
<p><strong>edit:</strong> I appreciate the suggestions for different ways to receive packets, but I w... | 15 | 2010-02-04T10:43:04Z | 2,199,432 | <p>Since there's at least <a href="http://www.cacetech.com/" rel="nofollow">one</a> that makes commercial products that integrate somewhat with wireshark , it has to be possible. It seems the immediate integration point is with the data it produces according to wikipedia, <a href="http://en.wikipedia.org/wiki/Wireshark... | 0 | 2010-02-04T12:03:57Z | [
"c++",
"python",
"api",
"wireshark",
"packet-sniffers"
] |
Is there an API for Wireshark, to develop programs/plugins that interact with it/enhance it? | 2,198,972 | <p>Googling didn't give me great results. Is there any sort of API for Wireshark that abstracts away from the main source code so we can develop programs that interact with it and deal with the data it provides?</p>
<p><strong>edit:</strong> I appreciate the suggestions for different ways to receive packets, but I w... | 15 | 2010-02-04T10:43:04Z | 2,199,520 | <p><a href="http://www.wireshark.org/docs/man-pages/tshark.html" rel="nofollow">tshark</a> provides a CLI to much of Wireshark's functionality, if you are looking to harness Wireshark's protocol analyzers and data manipulation capabilities.</p>
<p>If you wanted to do some digging into Wireshark's <a href="http://anons... | 2 | 2010-02-04T12:16:53Z | [
"c++",
"python",
"api",
"wireshark",
"packet-sniffers"
] |
Is there an API for Wireshark, to develop programs/plugins that interact with it/enhance it? | 2,198,972 | <p>Googling didn't give me great results. Is there any sort of API for Wireshark that abstracts away from the main source code so we can develop programs that interact with it and deal with the data it provides?</p>
<p><strong>edit:</strong> I appreciate the suggestions for different ways to receive packets, but I w... | 15 | 2010-02-04T10:43:04Z | 2,199,694 | <p>I use <a href="http://code.google.com/p/pypcap/"><code>pypcap</code></a> to read packets and <a href="http://code.google.com/p/dpkt/"><code>dpkt</code></a> to parse.</p>
<p>For example, to use dpkt to read packets from a saved pcap:</p>
<pre><code>import socket
import dpkt
import sys
pcapReader = dpkt.pcap.Reader(... | 5 | 2010-02-04T12:42:39Z | [
"c++",
"python",
"api",
"wireshark",
"packet-sniffers"
] |
Is there an API for Wireshark, to develop programs/plugins that interact with it/enhance it? | 2,198,972 | <p>Googling didn't give me great results. Is there any sort of API for Wireshark that abstracts away from the main source code so we can develop programs that interact with it and deal with the data it provides?</p>
<p><strong>edit:</strong> I appreciate the suggestions for different ways to receive packets, but I w... | 15 | 2010-02-04T10:43:04Z | 2,209,096 | <p>wireshark uses libpcap, this library abstracts away platform differences in packet sniffing <em>and</em> provides a <a href="http://wiki.wireshark.org/Development/LibpcapFileFormat" rel="nofollow">format for data files</a>. that's how I'd inject packets into wireshark.</p>
| 0 | 2010-02-05T17:33:41Z | [
"c++",
"python",
"api",
"wireshark",
"packet-sniffers"
] |
Is there an API for Wireshark, to develop programs/plugins that interact with it/enhance it? | 2,198,972 | <p>Googling didn't give me great results. Is there any sort of API for Wireshark that abstracts away from the main source code so we can develop programs that interact with it and deal with the data it provides?</p>
<p><strong>edit:</strong> I appreciate the suggestions for different ways to receive packets, but I w... | 15 | 2010-02-04T10:43:04Z | 3,322,740 | <p>Try the lua scripting that they've got in the newer versions of wireshark.. you can write custom dissectors (for your own protocols and so on).</p>
<p><a href="http://wiki.wireshark.org/Lua" rel="nofollow">http://wiki.wireshark.org/Lua</a></p>
| 2 | 2010-07-23T22:05:54Z | [
"c++",
"python",
"api",
"wireshark",
"packet-sniffers"
] |
Is there an API for Wireshark, to develop programs/plugins that interact with it/enhance it? | 2,198,972 | <p>Googling didn't give me great results. Is there any sort of API for Wireshark that abstracts away from the main source code so we can develop programs that interact with it and deal with the data it provides?</p>
<p><strong>edit:</strong> I appreciate the suggestions for different ways to receive packets, but I w... | 15 | 2010-02-04T10:43:04Z | 7,784,297 | <p>c++ well could not find one.. but here is the wireshark documentation of Python support..!
<a href="http://wiki.wireshark.org/Python" rel="nofollow">http://wiki.wireshark.org/Python</a></p>
| 1 | 2011-10-16T12:39:03Z | [
"c++",
"python",
"api",
"wireshark",
"packet-sniffers"
] |
In Django, my request.session is not carrying over...does anyone know why? | 2,199,150 | <p>In one view, I set:</p>
<pre><code>request.session.set_expiry(999)
request.session['test'] = '123'
</code></pre>
<p>In another view, I do:</p>
<pre><code>print request.session['test']
</code></pre>
<p>and it cannot be found. (error)
It's very simple, I just have 2 views.</p>
<p>It seems that once I leave a view... | 2 | 2010-02-04T11:14:42Z | 2,199,513 | <p>Are you, by any chance, setting the session itself to an empty dictionary, somewhere?</p>
| 1 | 2010-02-04T12:15:49Z | [
"python",
"django",
"session"
] |
In Django, my request.session is not carrying over...does anyone know why? | 2,199,150 | <p>In one view, I set:</p>
<pre><code>request.session.set_expiry(999)
request.session['test'] = '123'
</code></pre>
<p>In another view, I do:</p>
<pre><code>print request.session['test']
</code></pre>
<p>and it cannot be found. (error)
It's very simple, I just have 2 views.</p>
<p>It seems that once I leave a view... | 2 | 2010-02-04T11:14:42Z | 2,200,624 | <p>Could it be related to this?, just found it at <a href="http://code.djangoproject.com/wiki/NewbieMistakes">http://code.djangoproject.com/wiki/NewbieMistakes</a></p>
<p>Appending to a list in session doesn't work
Problem </p>
<p>If you have a list in your session, append operations don't get saved to the object.
S... | 8 | 2010-02-04T15:01:37Z | [
"python",
"django",
"session"
] |
encoding mp3 from a audio stream of PyTTS | 2,199,151 | <p>I work on text-to-speech trasforming text, in audio mp3 files, using python 2.5.</p>
<p>I use pyTSS as a python Text-To-Speech module, to transform text in audio .wav files (in pyTTS is not possible to encode in mp3 format directly). So after that, I code these wav files, in mp3 format, using lame command line enco... | 1 | 2010-02-04T11:14:39Z | 2,199,314 | <p>I don't think PyTTS produces default PCM data (i.e. 44100 Hz, stereo, 16-bit). You should check the format like this:</p>
<pre><code>memStream = tts.SpeakToMemory("some text")
format = memStream.Format.GetWaveFormatEx()
</code></pre>
<p>...and hand it over correctly to <code>acodec</code>. Therefore you can use th... | 2 | 2010-02-04T11:43:43Z | [
"python",
"mp3",
"text-to-speech",
"encoder"
] |
encoding mp3 from a audio stream of PyTTS | 2,199,151 | <p>I work on text-to-speech trasforming text, in audio mp3 files, using python 2.5.</p>
<p>I use pyTSS as a python Text-To-Speech module, to transform text in audio .wav files (in pyTTS is not possible to encode in mp3 format directly). So after that, I code these wav files, in mp3 format, using lame command line enco... | 1 | 2010-02-04T11:14:39Z | 2,199,351 | <p>can't provide a definitive answer here, sorry. But there is some trial and error: I'd look at the docuemtation of the pymedia module to check if tehre are any quality configurations that you can set. </p>
<p>And the other thign is that unlike wave or raw audio, you won't be able to simply concatenate mp3 encoded au... | 0 | 2010-02-04T11:50:31Z | [
"python",
"mp3",
"text-to-speech",
"encoder"
] |
How do I turn a dictionary into a string? | 2,199,303 | <pre><code>params = {'fruit':'orange', 'color':'red', 'size':'5'}
</code></pre>
<p>How can I turn that into a string:</p>
<pre><code>fruit=orange&color=red&size=5
</code></pre>
| 1 | 2010-02-04T11:41:54Z | 2,199,320 | <p>You can do it like this:</p>
<pre><code>'&'.join('%s=%s' % (k,v) for k,v in params.items())
</code></pre>
<p>If you are building strings for a URL it would be better to use urllib as this will escape correctly for you too:</p>
<pre><code>>>> params = { 'foo' : 'bar+baz', 'qux' : 'quux' }
>>>... | 11 | 2010-02-04T11:45:06Z | [
"python",
"string",
"dictionary"
] |
How do I turn a dictionary into a string? | 2,199,303 | <pre><code>params = {'fruit':'orange', 'color':'red', 'size':'5'}
</code></pre>
<p>How can I turn that into a string:</p>
<pre><code>fruit=orange&color=red&size=5
</code></pre>
| 1 | 2010-02-04T11:41:54Z | 2,199,342 | <p>If you are encoding url parameters, you can use <a href="http://docs.python.org/library/urllib.html#urllib.urlencode" rel="nofollow"><code>urllib.urlencode</code></a> to accomplish this. For example:</p>
<pre><code>import urllib
params = {'fruit':'orange', 'color':'red', 'size':'5'}
encoding = urllib.urlencode(para... | 3 | 2010-02-04T11:48:49Z | [
"python",
"string",
"dictionary"
] |
How do I turn a dictionary into a string? | 2,199,303 | <pre><code>params = {'fruit':'orange', 'color':'red', 'size':'5'}
</code></pre>
<p>How can I turn that into a string:</p>
<pre><code>fruit=orange&color=red&size=5
</code></pre>
| 1 | 2010-02-04T11:41:54Z | 2,199,345 | <p>Are you asking about this?</p>
<pre><code>>>> params = {'fruit':'orange', 'color':'red', 'size':'5'}
>>> import urllib
>>> urllib.urlencode( params )
'color=red&fruit=orange&size=5'
</code></pre>
| 3 | 2010-02-04T11:49:02Z | [
"python",
"string",
"dictionary"
] |
How do I turn a dictionary into a string? | 2,199,303 | <pre><code>params = {'fruit':'orange', 'color':'red', 'size':'5'}
</code></pre>
<p>How can I turn that into a string:</p>
<pre><code>fruit=orange&color=red&size=5
</code></pre>
| 1 | 2010-02-04T11:41:54Z | 2,199,355 | <p>If you want to create a querystring, Python comes with batteries included:</p>
<pre><code> import urllib
print(urllib.urlencode({'fruit':'orange', 'color':'red', 'size':'5'}))
</code></pre>
| 2 | 2010-02-04T11:51:06Z | [
"python",
"string",
"dictionary"
] |
How to send a HTTP Header request rather than HTTP URL in Python | 2,199,413 | <p>I'm doing Oauth, and Linkedin needs me to send a "header" request instead of URL request (I have no idea what that means).</p>
<p>This is what someone says on Google:</p>
<blockquote>
<p>If the library you are using isn't
using HTTP headers for the
authorization, you're not going to be
able to access prote... | 0 | 2010-02-04T12:00:16Z | 2,199,497 | <p>I don't know about this particular oauth library you are using, so I can't comment on that.</p>
<p>But,</p>
<ul>
<li><p>It can be clearly identified from the traceback, that <code>oauth_request.to_header()</code> returns a dictionary and not a string, that httplib.py expects.</p></li>
<li><p>The way to set authent... | 2 | 2010-02-04T12:13:12Z | [
"python",
"django",
"http",
"oauth",
"header"
] |
How to send a HTTP Header request rather than HTTP URL in Python | 2,199,413 | <p>I'm doing Oauth, and Linkedin needs me to send a "header" request instead of URL request (I have no idea what that means).</p>
<p>This is what someone says on Google:</p>
<blockquote>
<p>If the library you are using isn't
using HTTP headers for the
authorization, you're not going to be
able to access prote... | 0 | 2010-02-04T12:00:16Z | 9,422,830 | <p>Your connection.request method can take in HTTP headers:</p>
<p>connection.request(method, url, body = body, headers={'Authorization':header})</p>
<p>For OAuth, there are a bunch of fields that 'header' has: <br></p>
<blockquote>
<p>OAuth realm="http://api.linkedin.com", oauth_consumer_key="##########", oauth_n... | 0 | 2012-02-23T23:02:26Z | [
"python",
"django",
"http",
"oauth",
"header"
] |
matching multiple line in python regular expression | 2,199,552 | <p>I want to extract the data between <code><tr></code> tags from an html page. I used the following code.But i didn't get any result. The html between the <code><tr></code> tags is in multiple lines</p>
<pre><code>category =re.findall('<tr>(.*?)</tr>',data);
</code></pre>
<p>Please suggest a ... | 11 | 2010-02-04T12:22:43Z | 2,199,563 | <p>Do not use regular expressions to parse HTML. Use an HTML parser such as <a href="http://codespeak.net/lxml/" rel="nofollow">lxml</a> or <a href="http://www.crummy.com/software/BeautifulSoup/" rel="nofollow">BeautifulSoup</a>.</p>
| 2 | 2010-02-04T12:24:20Z | [
"python"
] |
matching multiple line in python regular expression | 2,199,552 | <p>I want to extract the data between <code><tr></code> tags from an html page. I used the following code.But i didn't get any result. The html between the <code><tr></code> tags is in multiple lines</p>
<pre><code>category =re.findall('<tr>(.*?)</tr>',data);
</code></pre>
<p>Please suggest a ... | 11 | 2010-02-04T12:22:43Z | 2,199,629 | <pre><code>pat=re.compile('<tr>(.*?)</tr>',re.DOTALL|re.M)
print pat.findall(data)
</code></pre>
<p>Or non regex way,</p>
<pre><code>for item in data.split("</tr>"):
if "<tr>" in item:
print item[item.find("<tr>")+len("<tr>"):]
</code></pre>
| 2 | 2010-02-04T12:33:48Z | [
"python"
] |
matching multiple line in python regular expression | 2,199,552 | <p>I want to extract the data between <code><tr></code> tags from an html page. I used the following code.But i didn't get any result. The html between the <code><tr></code> tags is in multiple lines</p>
<pre><code>category =re.findall('<tr>(.*?)</tr>',data);
</code></pre>
<p>Please suggest a ... | 11 | 2010-02-04T12:22:43Z | 2,199,661 | <p>Don't use regex, use a HTML parser such as <a href="http://www.crummy.com/software/BeautifulSoup/" rel="nofollow">BeautifulSoup</a>:</p>
<pre><code>html = '<html><body>foo<tr>bar</tr>baz<tr>qux</tr></body></html>'
import BeautifulSoup
soup = BeautifulSoup.BeautifulSo... | 5 | 2010-02-04T12:36:33Z | [
"python"
] |
matching multiple line in python regular expression | 2,199,552 | <p>I want to extract the data between <code><tr></code> tags from an html page. I used the following code.But i didn't get any result. The html between the <code><tr></code> tags is in multiple lines</p>
<pre><code>category =re.findall('<tr>(.*?)</tr>',data);
</code></pre>
<p>Please suggest a ... | 11 | 2010-02-04T12:22:43Z | 2,199,710 | <p>As other have suggested the specific problem you are having can be resolved by <strong>allowing multi-line matching using <a href="http://docs.python.org/library/re.html#re.MULTILINE" rel="nofollow"><code>re.MULTILINE</code></a></strong></p>
<p>However <strong>you are going down a treacherous patch parsing <a href=... | 0 | 2010-02-04T12:45:54Z | [
"python"
] |
matching multiple line in python regular expression | 2,199,552 | <p>I want to extract the data between <code><tr></code> tags from an html page. I used the following code.But i didn't get any result. The html between the <code><tr></code> tags is in multiple lines</p>
<pre><code>category =re.findall('<tr>(.*?)</tr>',data);
</code></pre>
<p>Please suggest a ... | 11 | 2010-02-04T12:22:43Z | 2,199,744 | <p>just to clear up the issue. Despite all those links to <code>re.M</code> it wouldn't work here as simple skimming of the its explanation would reveal. You'd need <code>re.S</code>, if you wouldn't try to parse html, of course:</p>
<pre><code>>>> doc = """<table border="1">
<tr>
<... | 13 | 2010-02-04T12:52:05Z | [
"python"
] |
PyQt debugging in main loop | 2,199,703 | <p>Can I debug PyQt application when is main loop running ?
Pdb, NetBeans, PyDev, all "freeze" when sys.exit(app.exec_()) is executed.
I probably missing something obvious. Or what can be problem, please ?
I apologize for my "creepy" english. Thanks.</p>
| 1 | 2010-02-04T12:45:04Z | 2,199,901 | <p>I'm assuming your <code>main()</code> function looks something like this:</p>
<pre><code>def __name__ == '__main__':
app = QtGui.QApplication(sys.argv)
myapp = MyApplication()
myapp.show()
sys.exit(app.exec_())
</code></pre>
<p>If not, post some example code to help determine what coudl be wrong.</... | 1 | 2010-02-04T13:19:47Z | [
"python",
"debugging",
"pyqt"
] |
pydoc fails under Windows and Python 2.6.4 | 2,199,739 | <p>When trying to use pydoc under Windows and python.org 2.6.4 I get the following error:</p>
<pre><code>C:\>pydoc sys
'import site' failed; use -v for traceback
Traceback (most recent call last):
File "C:\programs\Python26\Lib\pydoc.py", line 55, in ?
import sys, imp, os, re, types, inspect, __builtin__, pkg... | 1 | 2010-02-04T12:51:01Z | 2,199,785 | <p>how about setting your PATH</p>
<pre><code>c:\> set PATH=C:\Python26\Lib;%PATH%
c:\> pydoc.py sys
</code></pre>
| 0 | 2010-02-04T12:59:27Z | [
"python",
"pydoc"
] |
pydoc fails under Windows and Python 2.6.4 | 2,199,739 | <p>When trying to use pydoc under Windows and python.org 2.6.4 I get the following error:</p>
<pre><code>C:\>pydoc sys
'import site' failed; use -v for traceback
Traceback (most recent call last):
File "C:\programs\Python26\Lib\pydoc.py", line 55, in ?
import sys, imp, os, re, types, inspect, __builtin__, pkg... | 1 | 2010-02-04T12:51:01Z | 2,199,944 | <p>Typical windows problem: I had a program installed lately which brought its own Python 2.4. This installation overwrote the Windows file handlers for python scripts, but did not appear on the PATH. So scripts started from the console ran in the old-version python, but calling "python" ran the 2.6 version.</p>
<p>Th... | 2 | 2010-02-04T13:26:48Z | [
"python",
"pydoc"
] |
Calculating conditional probabilities from joint pmfs in numpy, too slow. Ideas? (python-numpy) | 2,199,940 | <p>I have a conjunctive probability mass function array, with shape, for example (1,2,3,4,5,6) and I want to calculate the probability table, conditional to a value for some of the dimensions (export the cpts), for decision-making purposes.</p>
<p>The code I came up with at the moment is the following (the input is th... | 1 | 2010-02-04T13:26:21Z | 2,218,191 | <p>Ok, found the answer myself after playing a little with numpy's in-place array manipulations.</p>
<p>Changed the last 3 lines in the loop to:</p>
<pre><code> d = conditionalize(d, dim, val)
</code></pre>
<p>where conditionalize is defined as:</p>
<pre><code> def conditionalize(arr, dim, val):
arr =... | 1 | 2010-02-07T20:23:28Z | [
"python",
"numpy",
"probability",
"arrays",
"recarray"
] |
What is the most lightweight way to transmit data over the internet using Python? | 2,199,963 | <p>I have two computers in geographically dispersed locations, both connected to the internet. On each computer I am running a Python program, and I would like to send and receive data from one to the other. I'd like to use the most simple approach possible, while remaining somewhat secure.</p>
<p>I have considered th... | 6 | 2010-02-04T13:31:20Z | 2,200,022 | <p>The cheapest and simplest way to transmit would probably be XML-RPC. It runs over HTTP (so you can secure it that way), it's in the standard library, and unlike protobuf, you don't have to worry about creating and compiling your data type files (since both ends are running Python, the dynamic typing shouldn't be a p... | 3 | 2010-02-04T13:40:42Z | [
"python",
"network-protocols"
] |
What is the most lightweight way to transmit data over the internet using Python? | 2,199,963 | <p>I have two computers in geographically dispersed locations, both connected to the internet. On each computer I am running a Python program, and I would like to send and receive data from one to the other. I'd like to use the most simple approach possible, while remaining somewhat secure.</p>
<p>I have considered th... | 6 | 2010-02-04T13:31:20Z | 2,200,040 | <p>Or you could go right down to the Sockets library and simply transmit the data in your own format.</p>
<p><a href="http://www.amk.ca/python/howto/sockets/" rel="nofollow">http://www.amk.ca/python/howto/sockets/</a></p>
| 1 | 2010-02-04T13:41:58Z | [
"python",
"network-protocols"
] |
What is the most lightweight way to transmit data over the internet using Python? | 2,199,963 | <p>I have two computers in geographically dispersed locations, both connected to the internet. On each computer I am running a Python program, and I would like to send and receive data from one to the other. I'd like to use the most simple approach possible, while remaining somewhat secure.</p>
<p>I have considered th... | 6 | 2010-02-04T13:31:20Z | 2,200,082 | <p>You could consider <a href="http://pyro.sourceforge.net/manual/PyroManual.html" rel="nofollow">Pyro</a>, be sure to read the <a href="http://pyro.sourceforge.net/manual/9-security.html" rel="nofollow">Security chapter</a>.</p>
<p><strong>Update:</strong> It seems simpler to set up than Protocol Buffers and may requ... | 0 | 2010-02-04T13:49:43Z | [
"python",
"network-protocols"
] |
What is the most lightweight way to transmit data over the internet using Python? | 2,199,963 | <p>I have two computers in geographically dispersed locations, both connected to the internet. On each computer I am running a Python program, and I would like to send and receive data from one to the other. I'd like to use the most simple approach possible, while remaining somewhat secure.</p>
<p>I have considered th... | 6 | 2010-02-04T13:31:20Z | 2,200,965 | <p>Protocol buffers are "lightweight" in the sense that they produce very compact wire representation, thus saving bandwidth, memory, storage, etc -- while staying very general-purpose and cross-language. We use them a <strong>lot</strong> at Google, of course, but it's not clear whether you care about these performan... | 9 | 2010-02-04T15:43:05Z | [
"python",
"network-protocols"
] |
What is the most lightweight way to transmit data over the internet using Python? | 2,199,963 | <p>I have two computers in geographically dispersed locations, both connected to the internet. On each computer I am running a Python program, and I would like to send and receive data from one to the other. I'd like to use the most simple approach possible, while remaining somewhat secure.</p>
<p>I have considered th... | 6 | 2010-02-04T13:31:20Z | 2,208,108 | <p>Alex is right, of course. But, I'll chime in that I have been very happy in the past with pickling data and pushing it over SSH to another process for unpickling. It's just so easy.</p>
<p>But, it's not suitable for many things. You really need to trust the incoming data, which in the case of my blog server rece... | 0 | 2010-02-05T15:08:55Z | [
"python",
"network-protocols"
] |
Python: defining new functions on the fly using "with" | 2,200,026 | <p>I want to convert the following code:</p>
<pre><code>...
urls = [many urls]
links = []
funcs = []
for url in urls:
func = getFunc(url, links)
funcs.append(func)
...
def getFunc(url, links):
def func():
page = open(url)
link = searchForLink(page)
links.append(link)
return func
</code><... | 4 | 2010-02-04T13:41:00Z | 2,200,062 | <p>Lose the line <code><STATEMENT>(funcs):</code></p>
<p>Edit:</p>
<p>I mean: why would you do this? Why define a new function for each page? Why not just do this?</p>
<pre><code>urls = [many urls]
links = []
for url in urls:
page = open(url)
link = searchForLink(page)
links.append(link)
</code... | 2 | 2010-02-04T13:45:58Z | [
"python",
"with-statement"
] |
Python: defining new functions on the fly using "with" | 2,200,026 | <p>I want to convert the following code:</p>
<pre><code>...
urls = [many urls]
links = []
funcs = []
for url in urls:
func = getFunc(url, links)
funcs.append(func)
...
def getFunc(url, links):
def func():
page = open(url)
link = searchForLink(page)
links.append(link)
return func
</code><... | 4 | 2010-02-04T13:41:00Z | 2,200,118 | <p>It makes no sense to use <code>with</code> here. Instead use a list comprehension:</p>
<pre><code>funcs = [getFunc(url, links) for url in urls]
</code></pre>
| 6 | 2010-02-04T13:55:27Z | [
"python",
"with-statement"
] |
Python: defining new functions on the fly using "with" | 2,200,026 | <p>I want to convert the following code:</p>
<pre><code>...
urls = [many urls]
links = []
funcs = []
for url in urls:
func = getFunc(url, links)
funcs.append(func)
...
def getFunc(url, links):
def func():
page = open(url)
link = searchForLink(page)
links.append(link)
return func
</code><... | 4 | 2010-02-04T13:41:00Z | 2,200,127 | <p>There are only two ways to create functions: <code>def</code> and <code>lambda</code>. Lambdas are meant for tiny functions, so they may not be very appropriate for your case. However, if you really want to, you can enclose two lambdas within each other:</p>
<pre><code>urls = [many urls]
links = []
funcs = [(lambda... | 2 | 2010-02-04T13:56:25Z | [
"python",
"with-statement"
] |
Python: defining new functions on the fly using "with" | 2,200,026 | <p>I want to convert the following code:</p>
<pre><code>...
urls = [many urls]
links = []
funcs = []
for url in urls:
func = getFunc(url, links)
funcs.append(func)
...
def getFunc(url, links):
def func():
page = open(url)
link = searchForLink(page)
links.append(link)
return func
</code><... | 4 | 2010-02-04T13:41:00Z | 2,200,619 | <p>You should not use "with" to do this (even though, given that it's Python, you almost certainly could, using some bizarre side-effect and Python's dynamicism). </p>
<p>The purpose of "with" in Python is, <a href="http://docs.python.org/reference/compound_stmts.html#the-with-statement" rel="nofollow">as described i... | 1 | 2010-02-04T15:01:11Z | [
"python",
"with-statement"
] |
Python: defining new functions on the fly using "with" | 2,200,026 | <p>I want to convert the following code:</p>
<pre><code>...
urls = [many urls]
links = []
funcs = []
for url in urls:
func = getFunc(url, links)
funcs.append(func)
...
def getFunc(url, links):
def func():
page = open(url)
link = searchForLink(page)
links.append(link)
return func
</code><... | 4 | 2010-02-04T13:41:00Z | 2,200,707 | <p>Good old <a href="http://docs.python.org/library/itertools.html" rel="nofollow">itertools</a>.</p>
<pre><code>from itertools import imap
links.extend(imap(searchForLink, imap(open, urls)))
</code></pre>
<p>Although, maybe you'd prefer <a href="http://oakwinter.com/code/functional/" rel="nofollow">functional</a>.</... | 1 | 2010-02-04T15:11:22Z | [
"python",
"with-statement"
] |
Python: defining new functions on the fly using "with" | 2,200,026 | <p>I want to convert the following code:</p>
<pre><code>...
urls = [many urls]
links = []
funcs = []
for url in urls:
func = getFunc(url, links)
funcs.append(func)
...
def getFunc(url, links):
def func():
page = open(url)
link = searchForLink(page)
links.append(link)
return func
</code><... | 4 | 2010-02-04T13:41:00Z | 2,202,055 | <p>A bit unconventional, but you can have a decorator register the func and bind any loop variables as default arguments:</p>
<pre><code>urls = [many urls]
links = []
funcs = []
for url in urls:
@funcs.append
def func(url=url):
page = open(url)
link = searchForLink(page)
links.append(l... | 4 | 2010-02-04T18:12:09Z | [
"python",
"with-statement"
] |
Python: defining new functions on the fly using "with" | 2,200,026 | <p>I want to convert the following code:</p>
<pre><code>...
urls = [many urls]
links = []
funcs = []
for url in urls:
func = getFunc(url, links)
funcs.append(func)
...
def getFunc(url, links):
def func():
page = open(url)
link = searchForLink(page)
links.append(link)
return func
</code><... | 4 | 2010-02-04T13:41:00Z | 2,204,287 | <p>You may be better using generators to achieve the delayed computation you're after.</p>
<pre><code>def MakeLinks(urls):
for url in urls:
page = open(url)
link = searchForLink(page)
yield link
links = MakeLinks(urls)
</code></pre>
<p>When you want the links:</p>
<pre><code>for link in ... | 1 | 2010-02-05T00:34:09Z | [
"python",
"with-statement"
] |
which is more efficient for buffer manipulations: python strings or array() | 2,200,027 | <p>I am building a routine that processes disk buffers for forensic purposes. Am I better off using python strings or the array() type? My first thought was to use strings, but I'm trying to void unicode problems, so perhaps array('c') is better?</p>
| 3 | 2010-02-04T13:41:07Z | 2,200,091 | <p>Write the code using what is most natural (strings), find out if it's too slow and then improve it. </p>
<p>Arrays can be used as drop-in replacements for <code>str</code> in most cases, as long as you restrict yourself to index and slice access. Both are fixed-length. Both should have about the same memory require... | 9 | 2010-02-04T13:50:56Z | [
"python",
"arrays",
"performance"
] |
which is more efficient for buffer manipulations: python strings or array() | 2,200,027 | <p>I am building a routine that processes disk buffers for forensic purposes. Am I better off using python strings or the array() type? My first thought was to use strings, but I'm trying to void unicode problems, so perhaps array('c') is better?</p>
| 3 | 2010-02-04T13:41:07Z | 2,200,806 | <p>If you need to <em>alter</em> the buffer in-place (it's not clear if you do, since you use the ambiguous term "to process"), <code>array</code>s will likely be better, since <code>str</code>ings are immutable. In Python 2.6 or better, however, <code>bytearray</code>s can be the best of both worlds -- mutable <em>an... | 6 | 2010-02-04T15:22:46Z | [
"python",
"arrays",
"performance"
] |
Netbeans not allowing Python 2.6 as default platform (forcing Jython2.5) | 2,200,685 | <p>I am trying to get Netbeans python to run with the default python platform set to Python 2.6.1 (my system python), so in Netbeans I do the following:</p>
<p>Tools -> Python Platform<br>
Set Python 2.6.1 to 'default'</p>
<p>However, it seems impossible to make this stick. Whenever I restart Netbeans it's back to Jy... | 3 | 2010-02-04T15:09:03Z | 2,232,995 | <p>Might be worth logging a bug with Netbeans about the first bit of behaviour you described - I can confirm similar (although strangely not identical) symptoms on my system.</p>
<p>I tried this with Python 2.6.2 / Netbeans 6.5.1</p>
<pre><code>NetBeans IDE 6.5.1 (Build 200903060201)
Java: 1.6.0_01; Java HotSpot(TM) ... | 0 | 2010-02-09T22:31:05Z | [
"python",
"netbeans",
"jython"
] |
Netbeans not allowing Python 2.6 as default platform (forcing Jython2.5) | 2,200,685 | <p>I am trying to get Netbeans python to run with the default python platform set to Python 2.6.1 (my system python), so in Netbeans I do the following:</p>
<p>Tools -> Python Platform<br>
Set Python 2.6.1 to 'default'</p>
<p>However, it seems impossible to make this stick. Whenever I restart Netbeans it's back to Jy... | 3 | 2010-02-04T15:09:03Z | 2,401,063 | <p>Looks like <a href="http://netbeans.org/bugzilla/show_bug.cgi?id=180693" rel="nofollow">http://netbeans.org/bugzilla/show_bug.cgi?id=180693</a> which provides a clumsy and non persistent workaround. </p>
<p>This needs heavy complaining on the netbean bug tracker imo. </p>
| 1 | 2010-03-08T11:57:09Z | [
"python",
"netbeans",
"jython"
] |
Python: default/common way to read png images | 2,200,742 | <p>I haven't found a standard way in Python to read images. Is there really none (because there are so many functions for so many custom stuff that I really wonder that there are no functions to read images)? Or what is it? (It should be available in the MacOSX standard installation and in most recent versions on Linux... | 16 | 2010-02-04T15:15:26Z | 2,200,768 | <p>No, there are no modules in the standard library for reading/writing/processing images directly. But the most common library might be <a href="http://www.pythonware.com/products/pil/">PIL (Python Imaging Library)</a>. Many projects are not included in the standard library because they are 1) totally optional and 2) ... | 23 | 2010-02-04T15:18:42Z | [
"python",
"image",
"png"
] |
Python: default/common way to read png images | 2,200,742 | <p>I haven't found a standard way in Python to read images. Is there really none (because there are so many functions for so many custom stuff that I really wonder that there are no functions to read images)? Or what is it? (It should be available in the MacOSX standard installation and in most recent versions on Linux... | 16 | 2010-02-04T15:15:26Z | 2,202,189 | <p>THe suggested PIL does not support interlaced PNGs. It can be quite anoying when dealing with lots of PNGs from different origins.
It is possible to open them, but can only read headerinformation from them, all other operations fail.</p>
| 0 | 2010-02-04T18:34:39Z | [
"python",
"image",
"png"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.