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 |
|---|---|---|---|---|---|---|---|---|---|
Installing TortoiseHG on Gnome in Ubuntu 9.10? | 1,830,705 | <p>I followed the following steps to install TortoiseHG on Ubuntu 9.10 using the following document: </p>
<p><a href="http://bitbucket.org/tortoisehg/stable/wiki/nautilus" rel="nofollow">http://bitbucket.org/tortoisehg/stable/wiki/nautilus</a></p>
<p>I get the following error in my ~/.xsession-errors</p>
<pre><code>... | 3 | 2009-12-02T04:46:57Z | 1,834,174 | <p>It appears you are using Mercurial 1.2.1, which does not have the refactoring done in <a href="http://www.selenic.com/hg/rev/6b5522cb2ad2" rel="nofollow">revision 6b5522cb2ad2</a>. That means that you cannot use the latest version of TortoiseHg with such an old version of Mercurial.</p>
<p>I suggest updating Mercur... | 2 | 2009-12-02T16:38:23Z | [
"python",
"ubuntu",
"mercurial",
"gnome",
"tortoisehg"
] |
How to load compiled python modules from memory? | 1,830,727 | <p>I need to read all modules (pre-compiled) from a zipfile (built by py2exe compressed) into memory and then load them all.
I know this can be done by loading direct from the zipfile but I need to load them from memory.
Any ideas? (I'm using python 2.5.2 on windows)
TIA Steve</p>
| 6 | 2009-12-02T04:53:21Z | 1,830,807 | <p>It depends on what exactly you have as "the module (pre-compiled)". Let's assume it's exactly the contents of a <code>.pyc</code> file, e.g., <code>ciao.pyc</code> as built by:</p>
<pre><code>$ cat>'ciao.py'
def ciao(): return 'Ciao!'
$ python -c'import ciao; print ciao.ciao()'
Ciao!
</code></pre>
<p>IOW, hav... | 30 | 2009-12-02T05:22:35Z | [
"python",
"module"
] |
How to load compiled python modules from memory? | 1,830,727 | <p>I need to read all modules (pre-compiled) from a zipfile (built by py2exe compressed) into memory and then load them all.
I know this can be done by loading direct from the zipfile but I need to load them from memory.
Any ideas? (I'm using python 2.5.2 on windows)
TIA Steve</p>
| 6 | 2009-12-02T04:53:21Z | 1,830,820 | <p>Compiled Python file consist of</p>
<ol>
<li>magic number (4 bytes) to determine type and version of Python,</li>
<li>timestamp (4 bytes) to check whether we have newer source,</li>
<li>marshaled code object.</li>
</ol>
<p>To load module you have to create module object with <code>imp.new_module()</code>, execute ... | 8 | 2009-12-02T05:25:30Z | [
"python",
"module"
] |
Does an entertaining guide exist? | 1,830,852 | <p>I know of the few normally mentioned Python tutorial/guides/introductions, but I was wondering if there were any that were...more entertaining to go through, I guess.</p>
<p>For example, Ruby has <a href="http://mislav.uniqpath.com/poignant-guide/">Why's (Poignant) Guide to Ruby</a>, Haskell has <a href="http://lea... | 9 | 2009-12-02T05:38:19Z | 1,830,881 | <p><a href="http://www.swaroopch.com/notes/Python" rel="nofollow" title="A Byte of Python">A Byte of Python</a></p>
<p>For real entertainment, take <a href="http://www.pythonchallenge.com/" rel="nofollow">The Python Challenge</a>.</p>
| 7 | 2009-12-02T05:44:10Z | [
"python"
] |
Does an entertaining guide exist? | 1,830,852 | <p>I know of the few normally mentioned Python tutorial/guides/introductions, but I was wondering if there were any that were...more entertaining to go through, I guess.</p>
<p>For example, Ruby has <a href="http://mislav.uniqpath.com/poignant-guide/">Why's (Poignant) Guide to Ruby</a>, Haskell has <a href="http://lea... | 9 | 2009-12-02T05:38:19Z | 1,831,106 | <p>I'm partial to <a href="http://www.diveintopython.net/" rel="nofollow">Dive Into Python</a>, myself. Now <a href="http://diveintopython3.net/" rel="nofollow">updated for Python 3</a>, too.</p>
<p>Not as silly as <em>why's (Poignant) Guide to Ruby</em>, but that's a plus, in my opinion. <em>Dive into Python</em> s... | 0 | 2009-12-02T06:58:46Z | [
"python"
] |
Does an entertaining guide exist? | 1,830,852 | <p>I know of the few normally mentioned Python tutorial/guides/introductions, but I was wondering if there were any that were...more entertaining to go through, I guess.</p>
<p>For example, Ruby has <a href="http://mislav.uniqpath.com/poignant-guide/">Why's (Poignant) Guide to Ruby</a>, Haskell has <a href="http://lea... | 9 | 2009-12-02T05:38:19Z | 31,727,622 | <p>Not a guide exactly but this is a game for python coders. check it out it
<a href="http://www.checkio.org/" rel="nofollow">http://www.checkio.org/</a></p>
| 1 | 2015-07-30T15:14:07Z | [
"python"
] |
Boost.Python: __init__ accepting None argument | 1,830,902 | <p>I have a C++ value type wrapped with Boost.Python which has a concept of a NULL value. The relevant parts of the wrapper code appear as follows:</p>
<pre><code>class_<TCurrency> currency( "TCurrency" )
.def( init<long>() )
.def( init<const std::string&>() )
<...>;
</code></p... | 1 | 2009-12-02T05:50:48Z | 1,830,989 | <p>Adding an <code>init<void*></code> overload will pass NULL if None is used, but I'm not sure how this could affect other ctors in corner cases. I also don't get the same None to string const& conversion that you mention, if I leave <code>init<void*></code> out. Using Boost.Python 1.37 and Python 2.... | 2 | 2009-12-02T06:21:09Z | [
"python",
"crash",
"boost-python"
] |
Pythonic List Comprehension | 1,831,129 | <p>This seems like a common task, alter some elements of an array, but my solution didn't feel very pythonic. Is there a better way to build <code>urls</code> with list comprehension?</p>
<pre><code>links = re.findall(r"(?:https?://|www\.|https?://www\.)[\S]+", text)
if len(links) == 0:
return text
urls = []
for l... | 2 | 2009-12-02T07:04:47Z | 1,831,146 | <pre><code>["http://"+link if link[0:4]=='www.' else link for link in links]
</code></pre>
<p>or </p>
<pre><code>[link[0:4]=='www.' and "http://"+link or link for link in links]
</code></pre>
<p><hr></p>
<p>Notes:
<code>("http://"+link if link[0:4]=='www.' else link)</code> - this is ternary operator like ?: in C<... | 1 | 2009-12-02T07:09:58Z | [
"python",
"list-comprehension"
] |
Pythonic List Comprehension | 1,831,129 | <p>This seems like a common task, alter some elements of an array, but my solution didn't feel very pythonic. Is there a better way to build <code>urls</code> with list comprehension?</p>
<pre><code>links = re.findall(r"(?:https?://|www\.|https?://www\.)[\S]+", text)
if len(links) == 0:
return text
urls = []
for l... | 2 | 2009-12-02T07:04:47Z | 1,831,151 | <p>If you want to go with list comprehensions, use:</p>
<pre><code>urls = ['http://' + link if link.startswith('www.') else link for link in links]
</code></pre>
<p>But I actually think that the more verbose way of looping through the links that you used is easier to read. "Shorter" does not always equal "better" or... | 4 | 2009-12-02T07:12:21Z | [
"python",
"list-comprehension"
] |
Pythonic List Comprehension | 1,831,129 | <p>This seems like a common task, alter some elements of an array, but my solution didn't feel very pythonic. Is there a better way to build <code>urls</code> with list comprehension?</p>
<pre><code>links = re.findall(r"(?:https?://|www\.|https?://www\.)[\S]+", text)
if len(links) == 0:
return text
urls = []
for l... | 2 | 2009-12-02T07:04:47Z | 1,831,185 | <p>You'll probably be better off using built-in Python functionality for dealing with urls. Assuming you stay with your current regex, I think you could rewrite this as:</p>
<pre><code>from urlparse import urlsplit, urlunsplit
links = re.findall("(?:https?://|www\.|https?://www\.)[\S]+", text)
urls = [urlunsplit(urls... | 1 | 2009-12-02T07:21:24Z | [
"python",
"list-comprehension"
] |
Pythonic List Comprehension | 1,831,129 | <p>This seems like a common task, alter some elements of an array, but my solution didn't feel very pythonic. Is there a better way to build <code>urls</code> with list comprehension?</p>
<pre><code>links = re.findall(r"(?:https?://|www\.|https?://www\.)[\S]+", text)
if len(links) == 0:
return text
urls = []
for l... | 2 | 2009-12-02T07:04:47Z | 1,831,197 | <p>Alternatively:</p>
<pre><code>def addHttp(url):
if url[0:4] == "www.":
url = "http://" + url
return url
urls = map(addHttp, links)
</code></pre>
<p>this is longer than using list comprehensions and the ternary operator, but IMHO it is more readable since the function name describes what it is doi... | 0 | 2009-12-02T07:25:12Z | [
"python",
"list-comprehension"
] |
Bignum implementation that has efficient addition of small integers | 1,831,212 | <p>I have been using python's native bignums for an algorithm and decided to try and speed it up by converting it to C++. When I used long longs, the C++ was about 100x faster than the python, but when I used GMP bindings in C++, it was only 10x faster than the python (for the same cases that fit in long longs).</p>
<... | 5 | 2009-12-02T07:33:27Z | 1,831,265 | <p>The GMP library itself has a <a href="http://gmplib.org/manual/Integer-Arithmetic.html#Integer-Arithmetic" rel="nofollow">fast short integer add to MPZ routine</a></p>
<pre><code>void mpz_add_ui (mpz_t rop, mpz_t op1, unsigned long int op2)
</code></pre>
<p>I don't know whether gmpy uses that, but if it does try a... | 2 | 2009-12-02T07:48:04Z | [
"c++",
"python",
"bignum",
"gmp",
"arbitrary-precision"
] |
Bignum implementation that has efficient addition of small integers | 1,831,212 | <p>I have been using python's native bignums for an algorithm and decided to try and speed it up by converting it to C++. When I used long longs, the C++ was about 100x faster than the python, but when I used GMP bindings in C++, it was only 10x faster than the python (for the same cases that fit in long longs).</p>
<... | 5 | 2009-12-02T07:33:27Z | 1,831,277 | <p>Did you do profiling ? Of Python and C++ <strong>whole</strong> applications. So that you know that you really need that additional speed.</p>
<p>Try Python 3k it now have any-length integers implemented!</p>
| 0 | 2009-12-02T07:51:30Z | [
"c++",
"python",
"bignum",
"gmp",
"arbitrary-precision"
] |
Bignum implementation that has efficient addition of small integers | 1,831,212 | <p>I have been using python's native bignums for an algorithm and decided to try and speed it up by converting it to C++. When I used long longs, the C++ was about 100x faster than the python, but when I used GMP bindings in C++, it was only 10x faster than the python (for the same cases that fit in long longs).</p>
<... | 5 | 2009-12-02T07:33:27Z | 1,845,577 | <p>(Note: I help maintain GMPY and I've implemented quite a few optimizations in the most recent release.)</p>
<p>GMPY v1.11 does use <code>mpz_add_ui</code> when adding a small number to an mpz. The newest version of GMPY is also about 25% faster than prior versions when working with small numbers.</p>
<pre><code>Wi... | 0 | 2009-12-04T08:16:28Z | [
"c++",
"python",
"bignum",
"gmp",
"arbitrary-precision"
] |
Is there a tuple data structure in Python | 1,831,218 | <p>I want to have an 3 item combination like tag, name, and list of values (array) what is the best possible data structure to store such things.</p>
<p>Current I am using dictionary, but it only allows 2 items, but easy traversal using</p>
<pre><code>for k, v in dict.iteritems():
</code></pre>
<p>can we have someth... | 4 | 2009-12-02T07:36:01Z | 1,831,228 | <p>why not just use a list of tuples (yes, this is a data type in python, like lists, but immutable):</p>
<pre><code>mylistoftuples = [(1, 2, 3), (2, "three", 4), (3, 4, [1, 2, 3, 4, 5])]
for k, v, x in mylistoftuples:
print k, v, x
</code></pre>
| 4 | 2009-12-02T07:37:43Z | [
"python",
"tuples"
] |
Is there a tuple data structure in Python | 1,831,218 | <p>I want to have an 3 item combination like tag, name, and list of values (array) what is the best possible data structure to store such things.</p>
<p>Current I am using dictionary, but it only allows 2 items, but easy traversal using</p>
<pre><code>for k, v in dict.iteritems():
</code></pre>
<p>can we have someth... | 4 | 2009-12-02T07:36:01Z | 1,831,230 | <p>You can have an array of 3-item tuples.</p>
<pre><code>arr = [ (1,2,3), (4,5,6), (7,8,9)]
for (k, v, x) in arr:
# do stuff
</code></pre>
| 0 | 2009-12-02T07:37:51Z | [
"python",
"tuples"
] |
Is there a tuple data structure in Python | 1,831,218 | <p>I want to have an 3 item combination like tag, name, and list of values (array) what is the best possible data structure to store such things.</p>
<p>Current I am using dictionary, but it only allows 2 items, but easy traversal using</p>
<pre><code>for k, v in dict.iteritems():
</code></pre>
<p>can we have someth... | 4 | 2009-12-02T07:36:01Z | 1,831,234 | <p><a href="http://docs.python.org/tutorial/datastructures.html" rel="nofollow">Python tutorial on data structutres</a> see section 5.3 "Tuples and sequences"</p>
<p>however, if you want to use "name" to index the data, you probably want to use a dictionary that has the string name as key and values are tuple of (tag,... | 8 | 2009-12-02T07:38:45Z | [
"python",
"tuples"
] |
Is there a tuple data structure in Python | 1,831,218 | <p>I want to have an 3 item combination like tag, name, and list of values (array) what is the best possible data structure to store such things.</p>
<p>Current I am using dictionary, but it only allows 2 items, but easy traversal using</p>
<pre><code>for k, v in dict.iteritems():
</code></pre>
<p>can we have someth... | 4 | 2009-12-02T07:36:01Z | 1,831,236 | <p>Maybe you should take a look here: <a href="http://docs.python.org/tutorial/datastructures.html" rel="nofollow">Python data structures</a></p>
| 3 | 2009-12-02T07:39:21Z | [
"python",
"tuples"
] |
Is there a tuple data structure in Python | 1,831,218 | <p>I want to have an 3 item combination like tag, name, and list of values (array) what is the best possible data structure to store such things.</p>
<p>Current I am using dictionary, but it only allows 2 items, but easy traversal using</p>
<pre><code>for k, v in dict.iteritems():
</code></pre>
<p>can we have someth... | 4 | 2009-12-02T07:36:01Z | 1,831,334 | <p>You can consider the <a href="http://docs.python.org/library/collections.html#collections.namedtuple" rel="nofollow"><code>collections.namedtuple</code></a> type to create tuple-like objects that have fields accessible by attribute lookup.</p>
<blockquote>
<p><code>collections.namedtuple(typename, field_names[, v... | 3 | 2009-12-02T08:03:51Z | [
"python",
"tuples"
] |
Is there a tuple data structure in Python | 1,831,218 | <p>I want to have an 3 item combination like tag, name, and list of values (array) what is the best possible data structure to store such things.</p>
<p>Current I am using dictionary, but it only allows 2 items, but easy traversal using</p>
<pre><code>for k, v in dict.iteritems():
</code></pre>
<p>can we have someth... | 4 | 2009-12-02T07:36:01Z | 1,842,063 | <p>Here's a comment to <a href="http://stackoverflow.com/questions/1831218/is-there-a-tuple-data-structure-in-python/1831334#1831334">@gimel's answer</a>:</p>
<pre><code>>>> import collections
>>> T = collections.namedtuple("T", 'tag name values')
>>> from itertools import starmap
>>&g... | 1 | 2009-12-03T18:52:01Z | [
"python",
"tuples"
] |
python Encoding Problem? | 1,831,378 | <p>I read from source.sql ( sql script ) file</p>
<pre><code>INSERT INTO `Tbl_abc` VALUES (1111, 2222, 'CLEMENT', 'taya', 'MME', 'Gérant', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 4688, 0, NULL, NULL, 'MAILLOT 01/02/09', 'MAILLOT 01/04/09', NULL, NULL);
</code></pre>
<p>And write to dest.sql With my list formated</... | 0 | 2009-12-02T08:14:25Z | 1,831,396 | <p>Please use <code>.encode("utf-8")</code>, when you write to .sql file too.</p>
<p>open the file</p>
<pre><code>fileObj = codecs.open( "someFile", "r", "utf-8" )
</code></pre>
<p>lets say you read it </p>
<pre><code>data=fileOjb.read()
</code></pre>
<p>... do something on data</p>
<pre><code>open("newfile","w")... | 1 | 2009-12-02T08:18:19Z | [
"python"
] |
python Encoding Problem? | 1,831,378 | <p>I read from source.sql ( sql script ) file</p>
<pre><code>INSERT INTO `Tbl_abc` VALUES (1111, 2222, 'CLEMENT', 'taya', 'MME', 'Gérant', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 4688, 0, NULL, NULL, 'MAILLOT 01/02/09', 'MAILLOT 01/04/09', NULL, NULL);
</code></pre>
<p>And write to dest.sql With my list formated</... | 0 | 2009-12-02T08:14:25Z | 1,831,411 | <p>Hi check encoding of your file .sql maybe it is not utf-8!</p>
| 0 | 2009-12-02T08:22:54Z | [
"python"
] |
python Encoding Problem? | 1,831,378 | <p>I read from source.sql ( sql script ) file</p>
<pre><code>INSERT INTO `Tbl_abc` VALUES (1111, 2222, 'CLEMENT', 'taya', 'MME', 'Gérant', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 4688, 0, NULL, NULL, 'MAILLOT 01/02/09', 'MAILLOT 01/04/09', NULL, NULL);
</code></pre>
<p>And write to dest.sql With my list formated</... | 0 | 2009-12-02T08:14:25Z | 1,831,414 | <p>Store your working data internally in Python as Unicode (use decode on read), and always write out using encode.</p>
<p>In your instance, you need to know the encoding of your database to know the correct output encoding. </p>
| 0 | 2009-12-02T08:23:19Z | [
"python"
] |
Python time comparison | 1,831,410 | <p>How do I compare times in python?</p>
<p>I see that date comparisons can be done and there's also "timedelta", but I'm struggling to find out how to check if the current time (from datetime.now()) is earlier, the same, or later than a specified time (e.g. 8am) regardless of the date.</p>
| 42 | 2009-12-02T08:22:33Z | 1,831,421 | <p>datetime have comparison capability</p>
<pre><code>>>> import datetime
>>> import time
>>> a = datetime.datetime.now()
>>> time.sleep(2.0)
>>> b = datetime.datetime.now()
>>> print a < b
True
>>> print a == b
False
</code></pre>
| 0 | 2009-12-02T08:26:04Z | [
"python",
"time",
"comparison"
] |
Python time comparison | 1,831,410 | <p>How do I compare times in python?</p>
<p>I see that date comparisons can be done and there's also "timedelta", but I'm struggling to find out how to check if the current time (from datetime.now()) is earlier, the same, or later than a specified time (e.g. 8am) regardless of the date.</p>
| 42 | 2009-12-02T08:22:33Z | 1,831,422 | <p>You can compare datetime.datetime objects directly</p>
<p>E.g:</p>
<pre><code>>>> a
datetime.datetime(2009, 12, 2, 10, 24, 34, 198130)
>>> b
datetime.datetime(2009, 12, 2, 10, 24, 36, 910128)
>>> a < b
True
>>> a > b
False
>>> a == a
True
>>> b == b
True
... | 7 | 2009-12-02T08:26:08Z | [
"python",
"time",
"comparison"
] |
Python time comparison | 1,831,410 | <p>How do I compare times in python?</p>
<p>I see that date comparisons can be done and there's also "timedelta", but I'm struggling to find out how to check if the current time (from datetime.now()) is earlier, the same, or later than a specified time (e.g. 8am) regardless of the date.</p>
| 42 | 2009-12-02T08:22:33Z | 1,831,453 | <p>You <em>can't</em> compare a specific point in time (such as "right now") against an unfixed, recurring event (8am happens every day).</p>
<p>You can check if now is before or after <em>today's</em> 8am:</p>
<pre><code>>>> import datetime
>>> now = datetime.datetime.now()
>>> today8am = ... | 55 | 2009-12-02T08:32:21Z | [
"python",
"time",
"comparison"
] |
Python time comparison | 1,831,410 | <p>How do I compare times in python?</p>
<p>I see that date comparisons can be done and there's also "timedelta", but I'm struggling to find out how to check if the current time (from datetime.now()) is earlier, the same, or later than a specified time (e.g. 8am) regardless of the date.</p>
| 42 | 2009-12-02T08:22:33Z | 1,831,479 | <p>You can use the <code>time()</code> method of <code>datetime</code> objects to get the time of day, which you can use for comparison without taking the date into account:</p>
<pre><code>>>> this_morning = datetime.datetime(2009, 12, 2, 9, 30)
>>> last_night = datetime.datetime(2009, 12, 1, 20, 0)
... | 38 | 2009-12-02T08:36:19Z | [
"python",
"time",
"comparison"
] |
Python time comparison | 1,831,410 | <p>How do I compare times in python?</p>
<p>I see that date comparisons can be done and there's also "timedelta", but I'm struggling to find out how to check if the current time (from datetime.now()) is earlier, the same, or later than a specified time (e.g. 8am) regardless of the date.</p>
| 42 | 2009-12-02T08:22:33Z | 9,716,793 | <p>Inspired by Roger Pate:</p>
<pre><code>import datetime
def todayAt (hr, min=0, sec=0, micros=0):
now = datetime.datetime.now()
return now.replace(hour=hr, minute=min, second=sec, microsecond=micros)
# Usage demo1:
print todayAt (17), todayAt (17, 15)
# Usage demo2:
timeNow = datetime.datetime.now()
... | 3 | 2012-03-15T09:14:43Z | [
"python",
"time",
"comparison"
] |
Python time comparison | 1,831,410 | <p>How do I compare times in python?</p>
<p>I see that date comparisons can be done and there's also "timedelta", but I'm struggling to find out how to check if the current time (from datetime.now()) is earlier, the same, or later than a specified time (e.g. 8am) regardless of the date.</p>
| 42 | 2009-12-02T08:22:33Z | 15,777,151 | <p>Another way to do this without adding dependencies or using datetime is to simply do some math on the attributes of the time object. It has hours, minutes, seconds, milliseconds, and a timezone. For very simple comparisons, hours and minutes should be sufficient.</p>
<pre><code>d = datetime.utcnow()
t = d.time()
pr... | 1 | 2013-04-03T01:03:01Z | [
"python",
"time",
"comparison"
] |
Why _mysql.co that compiled on one Mac doesn't work on another? | 1,831,979 | <p>I want to use Python-MySQLDB library on Mac so I have compiled the source code to get the _mysql.so under Mac10.5 with my Intel iMac (i386)</p>
<p>This _mysql.co works in 2 of my iMacs and another Macbook. But that's it, it doesn't work in any other Macs.</p>
<p>Does this mean some machine specific info got compil... | 0 | 2009-12-02T10:21:41Z | 1,832,065 | <p>If you've only built one architecture (i386 / PPC) then it won't work on Macs with the opposite architecture. Are the machines that don't work PPC machines, by any chance?</p>
<p>Sometimes build configurations are set up to build only the current architecture by default - I haven't build Python-MySQLDB so I'm not s... | 2 | 2009-12-02T10:36:15Z | [
"python",
"compilation",
"mysql"
] |
Why _mysql.co that compiled on one Mac doesn't work on another? | 1,831,979 | <p>I want to use Python-MySQLDB library on Mac so I have compiled the source code to get the _mysql.so under Mac10.5 with my Intel iMac (i386)</p>
<p>This _mysql.co works in 2 of my iMacs and another Macbook. But that's it, it doesn't work in any other Macs.</p>
<p>Does this mean some machine specific info got compil... | 0 | 2009-12-02T10:21:41Z | 1,833,528 | <p>Perform a <code>file</code> check against the <code>_mysql.so</code> file:</p>
<pre><code>% file _mysql.so
_mysql.so: Mach-O 64-bit bundle x86_64
</code></pre>
<p>Make sure that it is compiled for the right architecture on the Macs on which it is not working. If you are trying to use it on any PowerPC (PPC) Macs, ... | 1 | 2009-12-02T15:13:47Z | [
"python",
"compilation",
"mysql"
] |
Getting data from the database with python(on Django framework) | 1,831,980 | <p>ordinarily if I were writing a sql statement to this I would do something like this,</p>
<pre><code> SELECT * FROM (django_baseaccount LEFT JOIN django_account ON django_baseaccount.user_id = django_account.baseaccount_ptr_id)
LEFT JOIN django_address ON django_account.baseaccount_ptr_id = django_address.user_id... | 0 | 2009-12-02T10:21:42Z | 1,832,015 | <p>Django provides a clean way to fall-back to native SQL for complex queries see the official documentation: <a href="http://docs.djangoproject.com/en/dev/topics/db/sql/#topics-db-sql" rel="nofollow">Performing raw SQL queries</a></p>
| 1 | 2009-12-02T10:28:14Z | [
"python",
"sql",
"mysql",
"django"
] |
Getting data from the database with python(on Django framework) | 1,831,980 | <p>ordinarily if I were writing a sql statement to this I would do something like this,</p>
<pre><code> SELECT * FROM (django_baseaccount LEFT JOIN django_account ON django_baseaccount.user_id = django_account.baseaccount_ptr_id)
LEFT JOIN django_address ON django_account.baseaccount_ptr_id = django_address.user_id... | 0 | 2009-12-02T10:21:42Z | 1,832,232 | <p>Forget the SQL. What do you want to achieve from this query? What do you want to do with the results? </p>
<p>You haven't posted your models. Do they have the foreign keys defined? Can you just do a simple query and use <code>select_related()</code> to get the joined objects?</p>
<p><strong>Edited to add</strong> ... | 1 | 2009-12-02T11:06:04Z | [
"python",
"sql",
"mysql",
"django"
] |
Getting data from the database with python(on Django framework) | 1,831,980 | <p>ordinarily if I were writing a sql statement to this I would do something like this,</p>
<pre><code> SELECT * FROM (django_baseaccount LEFT JOIN django_account ON django_baseaccount.user_id = django_account.baseaccount_ptr_id)
LEFT JOIN django_address ON django_account.baseaccount_ptr_id = django_address.user_id... | 0 | 2009-12-02T10:21:42Z | 1,832,355 | <p>"ordinarily if I were writing a sql statement"</p>
<p>Welcome to ORM. You're not writing SQL so <em>remove this from the question</em>. Do not ever post SQL and ask how to translate SQL into ORM. Translating SQL limits your ability to learn. Stop doing it.</p>
<p>Write down what the result is supposed to be.</... | 5 | 2009-12-02T11:29:32Z | [
"python",
"sql",
"mysql",
"django"
] |
Looking for advice on how to develop applets for Gnome / Ubuntu | 1,832,150 | <p>I am a linux (mostly ubuntu) user with a reasonable understanding of how the system works (although I am certainly <strong>not</strong> a linux guru!). In the past I have developed small cross-platform desktop applications in python/GTK and I delivered them to clients as self-contained filetrees, so that the only de... | 5 | 2009-12-02T10:51:14Z | 1,833,527 | <p>Well, you list python, so you'll want to have <code>pynotify</code> in your arsenal. It wraps DBus, and gives you a direct api for manipulating the osd-notification system.</p>
<pre><code>>>> import pynotify
>>> pynotify.init("Lil' Applet")
True
>>> note = pynotify.Notification(
... ... | 3 | 2009-12-02T15:13:44Z | [
"python",
"linux",
"ubuntu",
"gnome",
"dbus"
] |
Looking for advice on how to develop applets for Gnome / Ubuntu | 1,832,150 | <p>I am a linux (mostly ubuntu) user with a reasonable understanding of how the system works (although I am certainly <strong>not</strong> a linux guru!). In the past I have developed small cross-platform desktop applications in python/GTK and I delivered them to clients as self-contained filetrees, so that the only de... | 5 | 2009-12-02T10:51:14Z | 1,833,769 | <p>As you already know, your first and best friend will be the code written by others - copy, paste, dissect, understand.
Luckily there are a few projects that do what you intend to achieve.
I can recommend <a href="http://git.gnome.org/cgit/conduit/tree/" rel="nofollow">conduit's</a> code as a prime reference how to ... | 3 | 2009-12-02T15:48:53Z | [
"python",
"linux",
"ubuntu",
"gnome",
"dbus"
] |
Looking for advice on how to develop applets for Gnome / Ubuntu | 1,832,150 | <p>I am a linux (mostly ubuntu) user with a reasonable understanding of how the system works (although I am certainly <strong>not</strong> a linux guru!). In the past I have developed small cross-platform desktop applications in python/GTK and I delivered them to clients as self-contained filetrees, so that the only de... | 5 | 2009-12-02T10:51:14Z | 1,841,636 | <p>There are some very good recommendations here already, but let me suggest that you develop your applet not so much "for Ubuntu" as "for Gnome". It doesn't take much extra effort to also make RPM packages for distributions such as Fedora, and Arch Linux packages, to name two examples. There is one major disadvantage ... | 1 | 2009-12-03T17:45:55Z | [
"python",
"linux",
"ubuntu",
"gnome",
"dbus"
] |
Looking for advice on how to develop applets for Gnome / Ubuntu | 1,832,150 | <p>I am a linux (mostly ubuntu) user with a reasonable understanding of how the system works (although I am certainly <strong>not</strong> a linux guru!). In the past I have developed small cross-platform desktop applications in python/GTK and I delivered them to clients as self-contained filetrees, so that the only de... | 5 | 2009-12-02T10:51:14Z | 8,059,430 | <p>When I asked this question two years ago Ubuntu and Gnome were much closer to each other than they are today. At present (end of 2011) gnome adopted the gnome-shell, while Canonical decided to develop their very own UI (<a href="http://en.wikipedia.org/wiki/Unity_%28user_interface%29" rel="nofollow">unity</a>)...</p... | 1 | 2011-11-09T01:38:59Z | [
"python",
"linux",
"ubuntu",
"gnome",
"dbus"
] |
Python SOAP client library using a HTTPS connection with keys | 1,832,433 | <p>I want to query a SOAP service that requires the use of keys.</p>
<p>I could write a SOAP client myself making use of httplib's HTTPSConnection, I'm pretty sure that would work, but it means I have to write a load of XML. Is there a nicer way to do this? Perhaps getting an existing SOAP library to use a HTTPSConnec... | 1 | 2009-12-02T11:49:05Z | 1,832,724 | <p>See <a href="http://twistedmatrix.com/documents/8.2.0/api/twisted.web.xmlrpc.Proxy.html" rel="nofollow"><code>twisted.web.xmlrpc.Proxy</code></a>. The <code>url</code> argument knows about <code>HTTPS</code>:</p>
<blockquote>
<p><code>url</code> - The URL to which to post method calls. Calls will be made over SSL... | 1 | 2009-12-02T12:53:22Z | [
"python",
"soap"
] |
How to refer to the local module in Python? | 1,832,626 | <p>Let's say we have a module <code>m</code>:</p>
<pre><code>var = None
def get_var():
return var
def set_var(v):
var = v
</code></pre>
<p>This will not work as expected, because <code>set_var()</code> will not store <code>v</code> in the module-wide <code>var</code>. It will create a local variable <code>v... | 3 | 2009-12-02T12:28:54Z | 1,832,635 | <pre><code>def set_var(v):
global var
var = v
</code></pre>
<p>The global keyword will allow you to change global variables from within in a function.</p>
| 10 | 2009-12-02T12:31:48Z | [
"python",
"import",
"module",
"packages"
] |
How to refer to the local module in Python? | 1,832,626 | <p>Let's say we have a module <code>m</code>:</p>
<pre><code>var = None
def get_var():
return var
def set_var(v):
var = v
</code></pre>
<p>This will not work as expected, because <code>set_var()</code> will not store <code>v</code> in the module-wide <code>var</code>. It will create a local variable <code>v... | 3 | 2009-12-02T12:28:54Z | 1,832,678 | <p>As <a href="http://stackoverflow.com/questions/1832626/how-to-refer-to-the-local-module-in-python/1832635#1832635">Jeffrey Aylesworth's answer</a> shows, you don't actually need a reference to the local module to achieve the OP's aim. The <code>global</code> keyword can achieve this aim.</p>
<p>However for the sake... | 9 | 2009-12-02T12:43:20Z | [
"python",
"import",
"module",
"packages"
] |
How to refer to the local module in Python? | 1,832,626 | <p>Let's say we have a module <code>m</code>:</p>
<pre><code>var = None
def get_var():
return var
def set_var(v):
var = v
</code></pre>
<p>This will not work as expected, because <code>set_var()</code> will not store <code>v</code> in the module-wide <code>var</code>. It will create a local variable <code>v... | 3 | 2009-12-02T12:28:54Z | 1,833,322 | <p>As a follow up to Jeffrey's answer, I would like to add that, in Python 3, you can more generally access a variable from the closest enclosing scope:</p>
<pre><code>def set_local_var():
var = None
def set_var(v):
nonlocal var
var = v
return (var, set_var)
# Test:
(my_var, my_set) =... | 3 | 2009-12-02T14:42:21Z | [
"python",
"import",
"module",
"packages"
] |
Xcode gcc exit status 1 | 1,832,665 | <p>First of all I am very new to all this.<br>
I recently upgraded to Snow Leopard and installed the Xcode + iPhone dev package, 3.1.2.
I went on to install the Django framework + MYSQLDB handler. During the build stage, the terminal shows me the gcc exit status 1 error. But I have the Xcode already installed?</p>
<p>... | 0 | 2009-12-02T12:39:08Z | 1,832,894 | <p>It normally also shows <em>why</em> a compilation fails. Could you give the text preceding "gcc exited with code 1" or something like that? And perhaps the source file also.</p>
<p>Also look for other threads on this subject, like <a href="http://stackoverflow.com/questions/1465846/install-mysqldb-on-snow-leopard"... | 0 | 2009-12-02T13:26:15Z | [
"python",
"xcode",
"osx",
"gcc",
"mysql"
] |
Xcode gcc exit status 1 | 1,832,665 | <p>First of all I am very new to all this.<br>
I recently upgraded to Snow Leopard and installed the Xcode + iPhone dev package, 3.1.2.
I went on to install the Django framework + MYSQLDB handler. During the build stage, the terminal shows me the gcc exit status 1 error. But I have the Xcode already installed?</p>
<p>... | 0 | 2009-12-02T12:39:08Z | 2,047,532 | <p>I am not sure if you solved your problem. I got the exact same issue after I upgraded from Mac OS 10.4 to 10.6.</p>
<p>Following some blog posts, on a hunch, I ran setup.py pointing to an older gcc version (gcc-4.0).</p>
<p>CC='/usr/bin/gcc-4.0' python setup.py build</p>
<p>The build encountered few warnings.</p... | 1 | 2010-01-12T08:08:15Z | [
"python",
"xcode",
"osx",
"gcc",
"mysql"
] |
Xcode gcc exit status 1 | 1,832,665 | <p>First of all I am very new to all this.<br>
I recently upgraded to Snow Leopard and installed the Xcode + iPhone dev package, 3.1.2.
I went on to install the Django framework + MYSQLDB handler. During the build stage, the terminal shows me the gcc exit status 1 error. But I have the Xcode already installed?</p>
<p>... | 0 | 2009-12-02T12:39:08Z | 11,171,627 | <p>If it helps any, I solved this issue with sym links, and I think it will work for you. I wrote this with my version of gcc in mind, which is 4.2:</p>
<pre><code>cd /usr/bin
rm cc gcc c++ g++
ln -s gcc-4.2 cc
ln -s gcc-4.2 gcc
ln -s c++-4.2 c++
ln -s g++-4.2 g++
ln -s gcc-4.2 gcc-4.0
</code></pre>
<p>There ya go!</... | 0 | 2012-06-23T17:41:28Z | [
"python",
"xcode",
"osx",
"gcc",
"mysql"
] |
Python regex matching Unicode properties | 1,832,893 | <p>Perl and some other current regex engines support Unicode properties, such as the category, in a regex. E.g. in Perl you can use <code>\p{Ll}</code> to match an arbitrary lower-case letter, or <code>p{Zs}</code> for any space separator. I don't see support for this in either the 2.x nor 3.x lines of Python (with due... | 41 | 2009-12-02T13:25:41Z | 1,833,228 | <p>You're right that Unicode property classes are not supported by the Python regex parser.</p>
<p>If you wanted to do a nice hack, that would be generally useful, you could create a preprocessor that scans a string for such class tokens (<code>\p{M}</code> or whatever) and replaces them with the corresponding charact... | 4 | 2009-12-02T14:26:24Z | [
"python",
"regex",
"unicode",
"ucd",
"character-properties"
] |
Python regex matching Unicode properties | 1,832,893 | <p>Perl and some other current regex engines support Unicode properties, such as the category, in a regex. E.g. in Perl you can use <code>\p{Ll}</code> to match an arbitrary lower-case letter, or <code>p{Zs}</code> for any space separator. I don't see support for this in either the 2.x nor 3.x lines of Python (with due... | 41 | 2009-12-02T13:25:41Z | 1,836,283 | <p>Have you tried <a href="https://github.com/mitsuhiko/ponyguruma/" rel="nofollow">Ponyguruma</a>, a Python binding to the <a href="http://www.geocities.jp/kosako3/oniguruma/" rel="nofollow">Oniguruma</a> regular expression engine? In that engine you can simply say <code>\p{Armenian}</code> to match Armenian character... | 22 | 2009-12-02T22:22:09Z | [
"python",
"regex",
"unicode",
"ucd",
"character-properties"
] |
Python regex matching Unicode properties | 1,832,893 | <p>Perl and some other current regex engines support Unicode properties, such as the category, in a regex. E.g. in Perl you can use <code>\p{Ll}</code> to match an arbitrary lower-case letter, or <code>p{Zs}</code> for any space separator. I don't see support for this in either the 2.x nor 3.x lines of Python (with due... | 41 | 2009-12-02T13:25:41Z | 1,852,463 | <p>Note that while <code>\p{Ll}</code> has no equivalent in Python regular expressions, <code>\p{Zs}</code> should be covered by <code>'(?u)\s'</code>.
The <code>(?u)</code>, as the docs say, âMake \w, \W, \b, \B, \d, \D, \s and \S dependent on the Unicode character properties database.â and <code>\s</code> means a... | 2 | 2009-12-05T15:24:31Z | [
"python",
"regex",
"unicode",
"ucd",
"character-properties"
] |
Python regex matching Unicode properties | 1,832,893 | <p>Perl and some other current regex engines support Unicode properties, such as the category, in a regex. E.g. in Perl you can use <code>\p{Ll}</code> to match an arbitrary lower-case letter, or <code>p{Zs}</code> for any space separator. I don't see support for this in either the 2.x nor 3.x lines of Python (with due... | 41 | 2009-12-02T13:25:41Z | 4,160,572 | <p>You can painstakingly use unicodedata on each character:</p>
<pre><code>import unicodedata
def strip_accents(x):
return u''.join(c for c in unicodedata.normalize('NFD', x) if unicodedata.category(c) != 'Mn')
</code></pre>
| 5 | 2010-11-12T00:23:16Z | [
"python",
"regex",
"unicode",
"ucd",
"character-properties"
] |
Python regex matching Unicode properties | 1,832,893 | <p>Perl and some other current regex engines support Unicode properties, such as the category, in a regex. E.g. in Perl you can use <code>\p{Ll}</code> to match an arbitrary lower-case letter, or <code>p{Zs}</code> for any space separator. I don't see support for this in either the 2.x nor 3.x lines of Python (with due... | 41 | 2009-12-02T13:25:41Z | 4,316,097 | <p>The <a href="http://pypi.python.org/pypi/regex">regex</a> module (an alternative to the standard <code>re</code> module) supports Unicode codepoint properties with the <code>\p{}</code> syntax.</p>
| 42 | 2010-11-30T16:37:20Z | [
"python",
"regex",
"unicode",
"ucd",
"character-properties"
] |
Python regex matching Unicode properties | 1,832,893 | <p>Perl and some other current regex engines support Unicode properties, such as the category, in a regex. E.g. in Perl you can use <code>\p{Ll}</code> to match an arbitrary lower-case letter, or <code>p{Zs}</code> for any space separator. I don't see support for this in either the 2.x nor 3.x lines of Python (with due... | 41 | 2009-12-02T13:25:41Z | 9,552,524 | <p>Speaking of homegrown solutions, some time ago I wrote a small <a href="http://difnet.com.br/opensource/unicode_hack.py.txt" rel="nofollow">program</a> to do just that - convert a unicode category written as <code>\p{...}</code> into a range of values, extracted from the unicode <a href="http://unicode.org/versions/... | 3 | 2012-03-04T05:12:51Z | [
"python",
"regex",
"unicode",
"ucd",
"character-properties"
] |
Is using eval in Python a bad practice? | 1,832,940 | <p>I am using the following class to easily store data of my songs.</p>
<pre><code>class Song:
"""The class to store the details of each song"""
attsToStore=('Name', 'Artist', 'Album', 'Genre', 'Location')
def __init__(self):
for att in self.attsToStore:
exec 'self.%s=None'%(att.lower()... | 41 | 2009-12-02T13:34:07Z | 1,832,957 | <p>Yes, using eval is a bad practice. Just to name a few reasons:</p>
<ol>
<li>There is almost always a better way to do it</li>
<li>Very dangerous and insecure</li>
<li>Makes debugging difficult</li>
<li>Slow</li>
</ol>
<p>In your case you can use <a href="http://docs.python.org/library/functions.html#setattr">setat... | 104 | 2009-12-02T13:37:08Z | [
"python",
"eval"
] |
Is using eval in Python a bad practice? | 1,832,940 | <p>I am using the following class to easily store data of my songs.</p>
<pre><code>class Song:
"""The class to store the details of each song"""
attsToStore=('Name', 'Artist', 'Album', 'Genre', 'Location')
def __init__(self):
for att in self.attsToStore:
exec 'self.%s=None'%(att.lower()... | 41 | 2009-12-02T13:34:07Z | 1,832,968 | <p>In this case, yes. Instead of</p>
<pre><code>exec 'self.Foo=val'
</code></pre>
<p>you should use the <a href="http://docs.python.org/library/functions.html">builtin</a> function <code>setattr</code>:</p>
<pre><code>setattr(self, 'Foo', val)
</code></pre>
| 13 | 2009-12-02T13:38:31Z | [
"python",
"eval"
] |
Is using eval in Python a bad practice? | 1,832,940 | <p>I am using the following class to easily store data of my songs.</p>
<pre><code>class Song:
"""The class to store the details of each song"""
attsToStore=('Name', 'Artist', 'Album', 'Genre', 'Location')
def __init__(self):
for att in self.attsToStore:
exec 'self.%s=None'%(att.lower()... | 41 | 2009-12-02T13:34:07Z | 1,834,754 | <p>Using <code>eval</code> is weak, not a clearly <em>bad</em> practice.</p>
<ol>
<li><p>It violates the "Fundamental Principle of Software". Your source is not the sum total of what's executable. In addition to your source, there are the arguments to <code>eval</code>, which must be clearly understood. For this re... | 17 | 2009-12-02T18:08:39Z | [
"python",
"eval"
] |
Is using eval in Python a bad practice? | 1,832,940 | <p>I am using the following class to easily store data of my songs.</p>
<pre><code>class Song:
"""The class to store the details of each song"""
attsToStore=('Name', 'Artist', 'Album', 'Genre', 'Location')
def __init__(self):
for att in self.attsToStore:
exec 'self.%s=None'%(att.lower()... | 41 | 2009-12-02T13:34:07Z | 1,834,815 | <p>It's worth noting that for the specific problem in question, there are several alternatives to using <code>eval</code>:</p>
<p>The simplest, as noted, is using <code>setattr</code>:</p>
<pre><code>def __init__(self):
for name in attsToStore:
setattr(self, name, None)
</code></pre>
<p>A less obvious ap... | 4 | 2009-12-02T18:19:56Z | [
"python",
"eval"
] |
Is using eval in Python a bad practice? | 1,832,940 | <p>I am using the following class to easily store data of my songs.</p>
<pre><code>class Song:
"""The class to store the details of each song"""
attsToStore=('Name', 'Artist', 'Album', 'Genre', 'Location')
def __init__(self):
for att in self.attsToStore:
exec 'self.%s=None'%(att.lower()... | 41 | 2009-12-02T13:34:07Z | 37,081,082 | <p>Yes, it is:</p>
<p>Hack using Python:</p>
<pre><code>>>> eval(input())
"__import__('os').listdir('.')"
...........
........... #dir listing
...........
</code></pre>
<p>The below code will list all tasks running on a Windows machine.</p>
<pre><code>>>> eval(input())
"__import__('subprocess').... | 1 | 2016-05-06T20:41:56Z | [
"python",
"eval"
] |
What does Python's builtin __build_class__ do? | 1,832,997 | <p>In Python 3.1, there is a new builtin function I don't know in the <code>builtins</code> module:</p>
<pre><code>__build_class__(...)
__build_class__(func, name, *bases, metaclass=None, **kwds) -> class
Internal helper function used by the class statement.
</code></pre>
<p>What does this function do? Wh... | 13 | 2009-12-02T13:42:23Z | 1,833,013 | <p><strong>Compiling the <a href="http://www.python.org/dev/peps/pep-3115/">PEP 3115</a> metaclass</strong></p>
<p><a href="http://mail.python.org/pipermail/python-3000/2007-March/006338.html">Guido van Rossum said:</a></p>
<blockquote>
<p>The PEP proposes that the class
statement accepts keyword arguments,
<co... | 13 | 2009-12-02T13:44:54Z | [
"python",
"python-3.x"
] |
how can I save a form with ModelMultipleChoiceField? | 1,833,275 | <p>I have a model Calendar and in a form I want to be able to create multiple instances of it.</p>
<p>Here are my models:</p>
<pre><code>class Event(models.Model):
user = models.ForeignKey(User)
class Group(models.Model):
name = models.CharField(_('Name'), max_length=80)
events = models.ManyToManyField(E... | 2 | 2009-12-02T14:35:47Z | 1,833,688 | <p>That's not how to deal with many-to-many relationships in forms. You can't iterate through fields in a form and save them, it really doesn't work that way.</p>
<p>In this form, there's only one field, which happens to have multiple values. The thing to do here is to iterate through the <em>values</em> of this field... | 2 | 2009-12-02T15:37:34Z | [
"python",
"django",
"django-forms",
"save",
"multiple-instances"
] |
Simple way to simulate a slow network in python | 1,833,563 | <p>Scenario. I have a client with two network connections to a server. One connection uses a mobile phone, and the other is using a wlan connection. </p>
<p>The way that I have solved this is by having the server listen at two ports. But, the mobile connection should be slower than the wlan connection. The data that i... | 6 | 2009-12-02T15:18:55Z | 1,833,908 | <p>Well, what makes a network connection "slower" than another, is due to latency and/or bandwidth. So if you want to have a realistic simulation, you need to find the bandwidth of your mobile phone connection, as well as its latency, and simulate that in your client program. </p>
<p>But you seem to imply that you sen... | 2 | 2009-12-02T16:06:10Z | [
"python",
"networking",
"network-programming"
] |
Simple way to simulate a slow network in python | 1,833,563 | <p>Scenario. I have a client with two network connections to a server. One connection uses a mobile phone, and the other is using a wlan connection. </p>
<p>The way that I have solved this is by having the server listen at two ports. But, the mobile connection should be slower than the wlan connection. The data that i... | 6 | 2009-12-02T15:18:55Z | 1,833,954 | <p>Aside from using an external tool to simulate the kind of network you're interested in, one good approach is to use a substitute implementation of socket.</p>
<p>This involves making the socket construction a parameter to your function, instead of importing the socket module and using it directly. For normal opera... | 8 | 2009-12-02T16:12:49Z | [
"python",
"networking",
"network-programming"
] |
Simple way to simulate a slow network in python | 1,833,563 | <p>Scenario. I have a client with two network connections to a server. One connection uses a mobile phone, and the other is using a wlan connection. </p>
<p>The way that I have solved this is by having the server listen at two ports. But, the mobile connection should be slower than the wlan connection. The data that i... | 6 | 2009-12-02T15:18:55Z | 1,834,042 | <p>At the risk of not answering the question you asked, I would look for software that does this at a lower level.</p>
<p><a href="http://www.netlimiter.com/" rel="nofollow">Netlimiter</a> does this for Windows. I think <a href="http://www.desksoft.com/BWMeter.htm" rel="nofollow">BWMeter</a> and <a href="http://bandwi... | 4 | 2009-12-02T16:23:37Z | [
"python",
"networking",
"network-programming"
] |
Javascript + python url-en/decoding problem | 1,833,776 | <p>Hi there im kinda stucked with the url encoding between python and javascript, i hope you can help me out :S</p>
<p>Javascript:</p>
<pre><code>encodeURIComponent('lôl');
-> "l%C3%B4l"
</code></pre>
<p>Python:</p>
<pre><code>import urllib
test = container.REQUEST.form.get('test')
print test
print urllib.unquo... | 2 | 2009-12-02T15:49:53Z | 1,833,829 | <p>zope already url-decodes it - issue is that you're getting a utf-8 bytestring and printing it on a non-utf-8 terminal. Try decoding the string.</p>
<pre><code>x = 'l\xc3\xb4l'
unicode_x = x.decode('utf-8')
print unicode_x
</code></pre>
| 1 | 2009-12-02T15:56:42Z | [
"javascript",
"python",
"urlencode",
"zope"
] |
How to make some Django settings accessible by staff? | 1,833,833 | <p>In Django, settings are stored in a file, settings.py. This file is part of the code, and goes into the repository. It is only the developers who deal with this file. The admin deals with the models, the data in the database. This is the data that the non-development staff edits, and the site visitors see rendered i... | 9 | 2009-12-02T15:57:55Z | 1,833,915 | <p>How about putting a sitesettings.py (or whatever) somewhere that your admins can access, then in settings.py do</p>
<pre><code>from sitesettings import *
</code></pre>
<p>That seems good and simple, but I may have misunderstood or oversimplified your problem :)</p>
| 1 | 2009-12-02T16:07:04Z | [
"python",
"django",
"settings"
] |
How to make some Django settings accessible by staff? | 1,833,833 | <p>In Django, settings are stored in a file, settings.py. This file is part of the code, and goes into the repository. It is only the developers who deal with this file. The admin deals with the models, the data in the database. This is the data that the non-development staff edits, and the site visitors see rendered i... | 9 | 2009-12-02T15:57:55Z | 1,833,927 | <p>Something like <a href="https://pypi.python.org/pypi/django-dbsettings" rel="nofollow">dbsettings</a> (as you mentioned) seems like the way to go. From the <a href="https://github.com/zlorf/django-dbsettings#storing-settings-in-the-database" rel="nofollow">reasons for existence</a> for that project:</p>
<blockquote... | 6 | 2009-12-02T16:08:50Z | [
"python",
"django",
"settings"
] |
How to make some Django settings accessible by staff? | 1,833,833 | <p>In Django, settings are stored in a file, settings.py. This file is part of the code, and goes into the repository. It is only the developers who deal with this file. The admin deals with the models, the data in the database. This is the data that the non-development staff edits, and the site visitors see rendered i... | 9 | 2009-12-02T15:57:55Z | 1,833,976 | <p>I'm actually a big fan of dbsettings, <strike>and keep meaning to publish my fork that patches it to work with Django 1.1 (not actually a big change)</strike>. Looks like someone has <a href="http://github.com/sciyoshi/django-dbsettings" rel="nofollow">updated it already</a>.</p>
<p>However, you're probably right t... | 6 | 2009-12-02T16:16:13Z | [
"python",
"django",
"settings"
] |
How to make some Django settings accessible by staff? | 1,833,833 | <p>In Django, settings are stored in a file, settings.py. This file is part of the code, and goes into the repository. It is only the developers who deal with this file. The admin deals with the models, the data in the database. This is the data that the non-development staff edits, and the site visitors see rendered i... | 9 | 2009-12-02T15:57:55Z | 1,834,582 | <p>If you must avoid server restarts then a logical place for the settings is the database as Dominic and Daniel said, but you'll need to invalidate cached settings object every time it is updated.</p>
<p>Looks like it's possible to re-set values in the cache with Django's <a href="http://docs.djangoproject.com/en/dev... | 1 | 2009-12-02T17:40:58Z | [
"python",
"django",
"settings"
] |
python regex escape characters | 1,833,873 | <p>We have:</p>
<pre><code>>>> str
'exit\r\ndrwxr-xr-x 2 root root 0 Jan 1 2000
\x1b[1;34mbin\x1b[0m\r\ndrwxr-xr-x 3 root root
0 Jan 1 2000 \x1b[1;34mlib\x1b[0m\r\ndrwxr-xr-x 10 root
root 0 Jan 1 1970 \x1b[1;34mlocal\x1b[0m\r\ndrwxr-xr-x
2 root ... | 1 | 2009-12-02T16:02:01Z | 1,833,934 | <p>You need the following changes:</p>
<ul>
<li>Escape the backslash</li>
<li>Switch to non-greedy matching. Otherwise, everything between the first <code>\x</code> and the last <code>m</code> will be removed, which will be a problem when there is more than one occurrence.</li>
<li>The order of arguments is incorrect<... | 3 | 2009-12-02T16:09:31Z | [
"python",
"regex",
"ansi-escape"
] |
python regex escape characters | 1,833,873 | <p>We have:</p>
<pre><code>>>> str
'exit\r\ndrwxr-xr-x 2 root root 0 Jan 1 2000
\x1b[1;34mbin\x1b[0m\r\ndrwxr-xr-x 3 root root
0 Jan 1 2000 \x1b[1;34mlib\x1b[0m\r\ndrwxr-xr-x 10 root
root 0 Jan 1 1970 \x1b[1;34mlocal\x1b[0m\r\ndrwxr-xr-x
2 root ... | 1 | 2009-12-02T16:02:01Z | 1,833,984 | <p>You have a few issues:</p>
<ul>
<li><p>You're passing arguments to re.sub in the wrong order wrong. It should be:</p>
<p>re.sub(regexp_pattern, replacement, source_string)</p></li>
<li><p>The string doesn't contain "\x". That "\x1b" is the escape character, and it's a single character.</p></li>
<li><p>As interja... | 8 | 2009-12-02T16:17:08Z | [
"python",
"regex",
"ansi-escape"
] |
python regex escape characters | 1,833,873 | <p>We have:</p>
<pre><code>>>> str
'exit\r\ndrwxr-xr-x 2 root root 0 Jan 1 2000
\x1b[1;34mbin\x1b[0m\r\ndrwxr-xr-x 3 root root
0 Jan 1 2000 \x1b[1;34mlib\x1b[0m\r\ndrwxr-xr-x 10 root
root 0 Jan 1 1970 \x1b[1;34mlocal\x1b[0m\r\ndrwxr-xr-x
2 root ... | 1 | 2009-12-02T16:02:01Z | 1,834,669 | <p>These are <a href="http://en.wikipedia.org/wiki/ANSI%5Fescape%5Fsequences" rel="nofollow">ANSI terminal codes</a>. They're signalled by an ESC (byte 27, seen in Python as <code>\x1B</code>) followed by <code>[</code>, then some <code>;</code>-separated parameters and finally a letter to specify which command it is. ... | 3 | 2009-12-02T17:54:51Z | [
"python",
"regex",
"ansi-escape"
] |
python regex escape characters | 1,833,873 | <p>We have:</p>
<pre><code>>>> str
'exit\r\ndrwxr-xr-x 2 root root 0 Jan 1 2000
\x1b[1;34mbin\x1b[0m\r\ndrwxr-xr-x 3 root root
0 Jan 1 2000 \x1b[1;34mlib\x1b[0m\r\ndrwxr-xr-x 10 root
root 0 Jan 1 1970 \x1b[1;34mlocal\x1b[0m\r\ndrwxr-xr-x
2 root ... | 1 | 2009-12-02T16:02:01Z | 1,834,744 | <p>Here is a pyparsing solution to your problem, with a general parsing expression for those pesky escape sequences. By transforming the initial string with a suppressed expression, this returns a string stripped of all matches of the expression.</p>
<pre><code>s = \
'exit\r\ndrwxr-xr-x 2 root root ... | 1 | 2009-12-02T18:06:41Z | [
"python",
"regex",
"ansi-escape"
] |
python regex escape characters | 1,833,873 | <p>We have:</p>
<pre><code>>>> str
'exit\r\ndrwxr-xr-x 2 root root 0 Jan 1 2000
\x1b[1;34mbin\x1b[0m\r\ndrwxr-xr-x 3 root root
0 Jan 1 2000 \x1b[1;34mlib\x1b[0m\r\ndrwxr-xr-x 10 root
root 0 Jan 1 1970 \x1b[1;34mlocal\x1b[0m\r\ndrwxr-xr-x
2 root ... | 1 | 2009-12-02T16:02:01Z | 1,835,154 | <p>Try running <code>ls --color=never -l</code> instead, and you won't get the ANSI escape codes in the first place.</p>
| 1 | 2009-12-02T19:13:38Z | [
"python",
"regex",
"ansi-escape"
] |
Confirmation of Successful HTTP Download in Python | 1,834,004 | <p>Is there a easy and reliable way to confirm that a web download completed successfully to download using Python or WGET [for large files]? I want to make sure the file downloaded in its entirety before performing another action.</p>
| 1 | 2009-12-02T16:19:16Z | 1,834,201 | <p>HTTP doesn't provide a way to check that.</p>
<p>The way used when distributing large files is, after the download, calculate the md5sum of the file and compare it with the md5sum provided by the server.</p>
<p>Example, that's how ubuntu does to distribute and check their CD downloads. <a href="https://help.ubuntu... | 1 | 2009-12-02T16:43:32Z | [
"python",
"wget"
] |
Confirmation of Successful HTTP Download in Python | 1,834,004 | <p>Is there a easy and reliable way to confirm that a web download completed successfully to download using Python or WGET [for large files]? I want to make sure the file downloaded in its entirety before performing another action.</p>
| 1 | 2009-12-02T16:19:16Z | 1,834,351 | <p>Given many (most in practice, I believe) HTTP/1.1 header sections, you can get an expectation about how long the entity body is. If you have that expectation, you can decide if you got all the entity data. See <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.4" rel="nofollow">RFC 2616 section 4.4... | 3 | 2009-12-02T17:06:03Z | [
"python",
"wget"
] |
Can I use the xmodem protocol with PySerial? | 1,834,247 | <p>I have a working connection with my serial device via PySerial, but I also want to transfer files via the xmodem protocol as part of my program. </p>
<p>Which would be the most platform-neutral way to do this? Worst case, I could <code>close()</code> my <code>serial.Serial</code> object in Python and use <code>subp... | 1 | 2009-12-02T16:50:07Z | 1,843,267 | <p>I'm not familiar with the details of the xmodem protocol, but one person answering the <a href="http://stackoverflow.com/questions/358471/xmodem-for-python">xmodem-for-python</a> question appears to be, and has even provided what looks like a crude implementation of xmodem <em>in</em> Python. Perhaps you could use ... | 0 | 2009-12-03T22:03:28Z | [
"python",
"ubuntu",
"pyserial",
"xmodem"
] |
Can I use the xmodem protocol with PySerial? | 1,834,247 | <p>I have a working connection with my serial device via PySerial, but I also want to transfer files via the xmodem protocol as part of my program. </p>
<p>Which would be the most platform-neutral way to do this? Worst case, I could <code>close()</code> my <code>serial.Serial</code> object in Python and use <code>subp... | 1 | 2009-12-02T16:50:07Z | 5,197,116 | <p>There is xmodem module on PyPi. It takes two functions in constructor for reading and writing data, implement them to work with your opened serial port. Below is simple sample of its usage:</p>
<pre><code>import serial
try:
from cStringIO import StringIO
except:
from StringIO import StringIO
from xmodem imp... | 3 | 2011-03-04T17:26:25Z | [
"python",
"ubuntu",
"pyserial",
"xmodem"
] |
Python check windows server version | 1,834,446 | <p>I need to log the current windows version in my python application for reporting purposes, but the built in functions I've found so far cant tell the difference between Windows client and server versions:</p>
<pre><code>os.sys.getwindowsversion()
(6, 0, 6002, 2, 'Service Pack 2')
platform.release()
'Vista'
platform... | 0 | 2009-12-02T17:20:41Z | 1,834,519 | <p>You could use the <a href="http://msdn.microsoft.com/en-us/library/ms724451%28VS.85%29.aspx" rel="nofollow">GetVersionEx</a> Win32 API and check the value of <code>wProductType</code> to differentiate.</p>
<p>Check out the <a href="http://sourceforge.net/projects/pywin32/" rel="nofollow">Python for Windows extensio... | 1 | 2009-12-02T17:30:22Z | [
"python",
"windows"
] |
Python check windows server version | 1,834,446 | <p>I need to log the current windows version in my python application for reporting purposes, but the built in functions I've found so far cant tell the difference between Windows client and server versions:</p>
<pre><code>os.sys.getwindowsversion()
(6, 0, 6002, 2, 'Service Pack 2')
platform.release()
'Vista'
platform... | 0 | 2009-12-02T17:20:41Z | 1,834,543 | <p>Try fetching it using WMI <a href="http://msdn.microsoft.com/en-us/library/aa394239%28VS.85%29.aspx" rel="nofollow"><code>Win32_OperatingSystem</code></a> class (<code>ProductType</code> is <code>3</code> on server systems). <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=09dfc342-648b-4119-b7eb-78... | 0 | 2009-12-02T17:33:13Z | [
"python",
"windows"
] |
Does a File Object Automatically Close when its Reference Count Hits Zero? | 1,834,556 | <p>I was under the impression that file objects are immediately closed when their reference counts hit 0, hence the line:</p>
<pre><code>foo = open('foo').read()
</code></pre>
<p>would get you the file's contents and immediately close the file. However, after reading the answer to <a href="http://stackoverflow.com/qu... | 23 | 2009-12-02T17:35:39Z | 1,834,570 | <p>If you want to be sure, I'd write the code like this:</p>
<pre><code>from __future__ import with_statement
with open('foo') as f:
foo = f.read()
</code></pre>
<p>That way, your file closes as expected, even with exceptions.</p>
<hr>
<p>Much later: here is some code with <code>import dis</code> to show how t... | 19 | 2009-12-02T17:39:04Z | [
"python"
] |
Does a File Object Automatically Close when its Reference Count Hits Zero? | 1,834,556 | <p>I was under the impression that file objects are immediately closed when their reference counts hit 0, hence the line:</p>
<pre><code>foo = open('foo').read()
</code></pre>
<p>would get you the file's contents and immediately close the file. However, after reading the answer to <a href="http://stackoverflow.com/qu... | 23 | 2009-12-02T17:35:39Z | 1,834,730 | <p>No, Python optimize deleting unused objects so It may never close your file (OK at the end of your script at exit it will cleanup).
@ hughdbrown have pointed out nice solution.</p>
| 1 | 2009-12-02T18:05:04Z | [
"python"
] |
Does a File Object Automatically Close when its Reference Count Hits Zero? | 1,834,556 | <p>I was under the impression that file objects are immediately closed when their reference counts hit 0, hence the line:</p>
<pre><code>foo = open('foo').read()
</code></pre>
<p>would get you the file's contents and immediately close the file. However, after reading the answer to <a href="http://stackoverflow.com/qu... | 23 | 2009-12-02T17:35:39Z | 1,834,757 | <p>The answer is in the link you provided.</p>
<p>Garbage collector will close file when it destroys file object, but:</p>
<ul>
<li><p>you don't really have control over when it happens.</p>
<p>While CPython uses reference counting to deterministically release resources
(so you can predict when object will be destro... | 20 | 2009-12-02T18:08:59Z | [
"python"
] |
Does a File Object Automatically Close when its Reference Count Hits Zero? | 1,834,556 | <p>I was under the impression that file objects are immediately closed when their reference counts hit 0, hence the line:</p>
<pre><code>foo = open('foo').read()
</code></pre>
<p>would get you the file's contents and immediately close the file. However, after reading the answer to <a href="http://stackoverflow.com/qu... | 23 | 2009-12-02T17:35:39Z | 1,834,791 | <p><strong>For the cpython implementation of python:</strong> yes, it is guaranteed to be closed when its reference count goes to zero.</p>
<p><strong>For python as an abstract language (e.g., including Jython, IronPython, etc):</strong> no, it is not guaranteed to be closed. In particular, an implementation of Pytho... | 7 | 2009-12-02T18:15:38Z | [
"python"
] |
Serving simple image with App Engine django patch? | 1,834,610 | <p>How the heck do i serve a simple img without all that <a href="http://code.google.com/p/app-engine-patch/wiki/MediaGenerator" rel="nofollow">MediaGenerator</a> nonsense, in Django on App Engine?
I am using app engine patch.</p>
<p>I got layout like this:</p>
<ul>
<li>django_app_engine_project_folder
<ul>
<li>my_ap... | 1 | 2009-12-02T17:46:02Z | 1,834,921 | <p>Well it seems that using app.yaml works out:</p>
<pre><code>- url: /my_app/media/
static_dir: my_app/media
</code></pre>
<p>Which allows me to refer to image a.jpg in folder my_app/media with a url like:</p>
<pre><code><img src="/my_app/media/a.jpg" />
</code></pre>
| 2 | 2009-12-02T18:36:47Z | [
"python",
"django",
"app-engine-patch"
] |
split a comma separated list with links in with beautifulsoup | 1,834,779 | <p>I've got a comma separated list in a table cell in an HTML document, but some of items in the list are linked:</p>
<pre><code><table>
<tr>
<td>Names</td>
<td>Fred, John, Barry, <a href="http://www.example.com/">Roger</a>, James</td>
</tr>
</table&... | 2 | 2009-12-02T18:12:02Z | 1,834,884 | <p>This is one way you could do it:</p>
<pre><code>import BeautifulSoup
soup = BeautifulSoup.BeautifulSoup('''<table>
<tr>
<td>Names</td>
<td>Fred, John, Barry, <a href="http://www.example.com/">Roger</a>, James</td>
</tr>
</table>''')
result = ... | 10 | 2009-12-02T18:30:36Z | [
"python",
"beautifulsoup",
"html-parsing"
] |
How do ldexp and frexp work in python? | 1,834,825 | <p>The python frexp and ldexp functions splits floats into mantissa and exponent.
Do anybody know if this process exposes the actual float structure, or if it requires python to do expensive logarithmic calls?</p>
| 2 | 2009-12-02T18:21:10Z | 1,834,839 | <p>Python 2.6's math.frexp just calls the underlying C library frexp directly. We must assume that the C library simply uses the float representation's parts directly instead of calculating if avaliable (IEEE 754).</p>
<pre><code>static PyObject *
math_frexp(PyObject *self, PyObject *arg)
{
int i;
doub... | 5 | 2009-12-02T18:25:20Z | [
"python",
"floating-point",
"ieee-754",
"exponent",
"mantissa"
] |
How do ldexp and frexp work in python? | 1,834,825 | <p>The python frexp and ldexp functions splits floats into mantissa and exponent.
Do anybody know if this process exposes the actual float structure, or if it requires python to do expensive logarithmic calls?</p>
| 2 | 2009-12-02T18:21:10Z | 1,835,174 | <p>As for speed, here is a quick comparison</p>
<pre><code>$ python -m timeit -c 'from math import frexp' 'frexp(1.1)'
100000 loops, best of 3: 3.7 usec per loop
$ python -m timeit -c 'from math import log' 'log(1.1)'
100000 loops, best of 3: 3.7 usec per loop
$ python -m timeit -c 'from math import ldexp' 'ldexp(1.... | 1 | 2009-12-02T19:17:07Z | [
"python",
"floating-point",
"ieee-754",
"exponent",
"mantissa"
] |
How do ldexp and frexp work in python? | 1,834,825 | <p>The python frexp and ldexp functions splits floats into mantissa and exponent.
Do anybody know if this process exposes the actual float structure, or if it requires python to do expensive logarithmic calls?</p>
| 2 | 2009-12-02T18:21:10Z | 1,836,897 | <p>This is a question you can easily answer yourself:</p>
<pre><code>$ python
>>> import math
>>> help(math.frexp)
Help on built-in function frexp in module math:
</code></pre>
<p>Notice the <em>built-in</em>. It's in C.</p>
<pre><code>>>> import urllib
>>> help(urllib.urlopen)
He... | 1 | 2009-12-03T00:31:38Z | [
"python",
"floating-point",
"ieee-754",
"exponent",
"mantissa"
] |
error: can't start new thread | 1,834,919 | <p>I have a site that runs with follow configuration:</p>
<p>Django + mod-wsgi + apache</p>
<p>In one of user's request, I send another HTTP request to another service, and solve this by httplib library of python.</p>
<p>But sometimes this service don't get answer too long, and timeout for httplib doesn't work. So ... | 12 | 2009-12-02T18:36:44Z | 1,835,038 | <p>You are starting more threads than can be handled by your system. There is a limit to the number of threads that can be active for one process. </p>
<p>Your application is starting threads faster than the threads are running to completion. If you need to start many threads you need to do it in a more controlled man... | 4 | 2009-12-02T18:56:01Z | [
"python",
"django",
"multithreading",
"mod-wsgi",
"httplib"
] |
error: can't start new thread | 1,834,919 | <p>I have a site that runs with follow configuration:</p>
<p>Django + mod-wsgi + apache</p>
<p>In one of user's request, I send another HTTP request to another service, and solve this by httplib library of python.</p>
<p>But sometimes this service don't get answer too long, and timeout for httplib doesn't work. So ... | 12 | 2009-12-02T18:36:44Z | 1,835,043 | <p>The "can't start new thread" error almost certainly due to the fact that you have already have too many threads running within your python process, and due to a resource limit of some kind the request to create a new thread is refused.</p>
<p>You should probably look at the number of threads you're creating; the ma... | 15 | 2009-12-02T18:56:42Z | [
"python",
"django",
"multithreading",
"mod-wsgi",
"httplib"
] |
error: can't start new thread | 1,834,919 | <p>I have a site that runs with follow configuration:</p>
<p>Django + mod-wsgi + apache</p>
<p>In one of user's request, I send another HTTP request to another service, and solve this by httplib library of python.</p>
<p>But sometimes this service don't get answer too long, and timeout for httplib doesn't work. So ... | 12 | 2009-12-02T18:36:44Z | 1,839,232 | <p>I think the best way in your case is to set socket timeout instead of spawning thread:</p>
<pre><code>h = httplib.HTTPSConnection(self.config['server'],
timeout=self.config['timeout'])
</code></pre>
<p>Also you can set global default timeout with <a href="http://docs.python.org/library... | 4 | 2009-12-03T11:03:21Z | [
"python",
"django",
"multithreading",
"mod-wsgi",
"httplib"
] |
error: can't start new thread | 1,834,919 | <p>I have a site that runs with follow configuration:</p>
<p>Django + mod-wsgi + apache</p>
<p>In one of user's request, I send another HTTP request to another service, and solve this by httplib library of python.</p>
<p>But sometimes this service don't get answer too long, and timeout for httplib doesn't work. So ... | 12 | 2009-12-02T18:36:44Z | 1,840,864 | <p>If you are tying to set timeout why don't you use <a href="http://docs.python.org/library/urllib2.html" rel="nofollow">urllib2</a>.</p>
| 3 | 2009-12-03T15:57:48Z | [
"python",
"django",
"multithreading",
"mod-wsgi",
"httplib"
] |
error: can't start new thread | 1,834,919 | <p>I have a site that runs with follow configuration:</p>
<p>Django + mod-wsgi + apache</p>
<p>In one of user's request, I send another HTTP request to another service, and solve this by httplib library of python.</p>
<p>But sometimes this service don't get answer too long, and timeout for httplib doesn't work. So ... | 12 | 2009-12-02T18:36:44Z | 1,842,020 | <p>I completely rewrite code from httplib to pycurl. </p>
<pre><code>c = pycurl.Curl()
c.setopt(pycurl.FOLLOWLOCATION, 1)
c.setopt(pycurl.MAXREDIRS, 5)
c.setopt(pycurl.CONNECTTIMEOUT, CONNECTION_TIMEOUT)
c.setopt(pycurl.TIMEOUT, COOPERATION_TIMEOUT)
c.setopt(pycurl.NOSIGNAL, 1)
c.setopt(pycurl.POST, 1)
c.setopt(pycurl... | 4 | 2009-12-03T18:46:52Z | [
"python",
"django",
"multithreading",
"mod-wsgi",
"httplib"
] |
pygst - glimagesink callback | 1,834,990 | <p>I'm trying to use 'glimagesink' element with python.
The element (which is GObject inside) has <code>client-draw-callback</code> property which should (in C++ at least) contain a function (<code>bool func(uint t, uint w, uint h)</code>) pointer.
I've tried <code>element.set_property('client-draw-callback', myfunc)</... | 0 | 2009-12-02T18:48:04Z | 2,267,320 | <p>This isn't the problem you're having (as far as I can tell) but it's important to note that
this API has changed recently, now it expects a void pointer of data which allows you to pass in a handle to user_data (or NULL) when you connect your callback.</p>
<pre><code>gboolean drawCallback (GLuint texture, GLuint wi... | 0 | 2010-02-15T16:28:28Z | [
"python",
"opengl",
"ctypes",
"gstreamer"
] |
How do I uninstall Python 2.5? | 1,835,003 | <p>I recently upgraded to Mac OS 10.6 and didn't realise that it shipped with <a href="http://en.wikipedia.org/wiki/Python%5F%28programming%5Flanguage%29" rel="nofollow">Python</a> 2.6.
I installed Python 2.5.4 and now it is the default Python installation.
Can I uninstall Python 2.5.4 and keep 2.6?</p>
| 3 | 2009-12-02T18:50:34Z | 1,835,149 | <p>Use the uninstall utility of the same package manager you used to install it.</p>
<p>As a sidenote, you can just modify the PATH not to point to the 2.5.4 installation by default, and both can live happily side-by-side.</p>
| 2 | 2009-12-02T19:12:20Z | [
"python",
"osx"
] |
How do I uninstall Python 2.5? | 1,835,003 | <p>I recently upgraded to Mac OS 10.6 and didn't realise that it shipped with <a href="http://en.wikipedia.org/wiki/Python%5F%28programming%5Flanguage%29" rel="nofollow">Python</a> 2.6.
I installed Python 2.5.4 and now it is the default Python installation.
Can I uninstall Python 2.5.4 and keep 2.6?</p>
| 3 | 2009-12-02T18:50:34Z | 1,835,265 | <p>Not only path but also link to <code>python</code> as it is now resolved as python2.5, not python2.6.</p>
| 0 | 2009-12-02T19:31:50Z | [
"python",
"osx"
] |
How do I uninstall Python 2.5? | 1,835,003 | <p>I recently upgraded to Mac OS 10.6 and didn't realise that it shipped with <a href="http://en.wikipedia.org/wiki/Python%5F%28programming%5Flanguage%29" rel="nofollow">Python</a> 2.6.
I installed Python 2.5.4 and now it is the default Python installation.
Can I uninstall Python 2.5.4 and keep 2.6?</p>
| 3 | 2009-12-02T18:50:34Z | 1,837,394 | <p>While there is no uninstaller for the python.org OS X python installers (because they use the standard Apple installer mechanism which does not provide an uninstaller by default), it is not difficult to remove. I've documented the full process <a href="http://bugs.python.org/issue7107">here</a> but keep in mind tha... | 6 | 2009-12-03T03:13:53Z | [
"python",
"osx"
] |
In Python, is the idiom "from Module import ClassName" typical? | 1,835,014 | <p>Since I prefer small files, I typically place a single "public" class per Python module. I name the module with the same name as the class it contains. So for example, the class <code>ToolSet</code> would be defined in <code>ToolSet.py</code>.</p>
<p>Within a package, if another module needs to instanciate an objec... | 3 | 2009-12-02T18:52:37Z | 1,835,079 | <p>Yes. Both are idiomatic Python in my opinion.</p>
<p>I tend to use the <code>from module import name</code> form for some modules in the standard library, such as <code>datetime</code>, but mostly for closely related modules, or names that are frequently used in the module. For example, I typically import ORM class... | 0 | 2009-12-02T19:01:37Z | [
"import",
"python"
] |
In Python, is the idiom "from Module import ClassName" typical? | 1,835,014 | <p>Since I prefer small files, I typically place a single "public" class per Python module. I name the module with the same name as the class it contains. So for example, the class <code>ToolSet</code> would be defined in <code>ToolSet.py</code>.</p>
<p>Within a package, if another module needs to instanciate an objec... | 3 | 2009-12-02T18:52:37Z | 1,835,089 | <p>To answer your first question, that is the idiom I use, and its use is supported by <a href="http://www.python.org/dev/peps/pep-0008/" rel="nofollow">PEP8 the python style guide</a></p>
<blockquote>
<p>it's okay to say this though:</p>
<p>from subprocess import Popen, PIPE</p>
</blockquote>
<p>I like it as ... | 5 | 2009-12-02T19:03:14Z | [
"import",
"python"
] |
In Python, is the idiom "from Module import ClassName" typical? | 1,835,014 | <p>Since I prefer small files, I typically place a single "public" class per Python module. I name the module with the same name as the class it contains. So for example, the class <code>ToolSet</code> would be defined in <code>ToolSet.py</code>.</p>
<p>Within a package, if another module needs to instanciate an objec... | 3 | 2009-12-02T18:52:37Z | 1,835,090 | <p>To address if it is pythonic, take a look at what is generally the definitive answer on the internet: <a href="http://effbot.org/zone/import-confusion.htm" rel="nofollow">http://effbot.org/zone/import-confusion.htm</a></p>
<p>Also take a look at ~unutbu's link which discusses this in greater detail.</p>
| 0 | 2009-12-02T19:03:28Z | [
"import",
"python"
] |
In Python, is the idiom "from Module import ClassName" typical? | 1,835,014 | <p>Since I prefer small files, I typically place a single "public" class per Python module. I name the module with the same name as the class it contains. So for example, the class <code>ToolSet</code> would be defined in <code>ToolSet.py</code>.</p>
<p>Within a package, if another module needs to instanciate an objec... | 3 | 2009-12-02T18:52:37Z | 1,835,635 | <p>I use <code>from itertools import chain, ifilter, islice, izip</code> all the time, because it allows me to program as though those were built-in methods, which to my way of thinking they really ought to be. </p>
<p>Once, in a frenzy of misguided correctness, I went through a big block of code and replaced <code>f... | 0 | 2009-12-02T20:39:41Z | [
"import",
"python"
] |
Python: check if an object is a list or tuple (but not string) | 1,835,018 | <p>This is what I normally do in order to ascertain that the input is a <code>list</code>/<code>tuple</code> - but not a <code>str</code>. Because many times I stumbled upon bugs where a function passes a <code>str</code> object by mistake, and the target function does <code>for x in lst</code> assuming that <code>lst<... | 257 | 2009-12-02T18:53:07Z | 1,835,044 | <p>I think</p>
<pre><code>assert not isinstance(lst, basestring)
</code></pre>
<p>Is actually what you want, otherwise you'll miss out on a lot of things which act like lists, but aren't subclasses of <code>list</code> or <code>tuple</code>.</p>
| 208 | 2009-12-02T18:56:51Z | [
"python",
"list",
"types",
"assert"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.