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 |
|---|---|---|---|---|---|---|---|---|---|
What is the associativity of Python's ** operator? | 2,383,034 | <p>I was just playing around with the python command line and the ** operator, which as far as I know performs a power function. So 2 ** 3 should be (and is) 8 because 2 * 2 * 2 = 8.</p>
<p>Can someone explain the behavior I found? I don't see any way to group the operations with parentheses to actually get a result... | 5 | 2010-03-04T21:59:18Z | 2,383,063 | <p>Also:</p>
<pre><code>2 ** (2 ** 2 **2)
</code></pre>
<p>One way or the other, it becomes 2 ** 16</p>
| 0 | 2010-03-04T22:03:12Z | [
"python"
] |
What is the associativity of Python's ** operator? | 2,383,034 | <p>I was just playing around with the python command line and the ** operator, which as far as I know performs a power function. So 2 ** 3 should be (and is) 8 because 2 * 2 * 2 = 8.</p>
<p>Can someone explain the behavior I found? I don't see any way to group the operations with parentheses to actually get a result... | 5 | 2010-03-04T21:59:18Z | 2,383,081 | <p>The ** operator is right associative:</p>
<p><code>
2 ** (2 ** (2 ** 2)) = 2 ** (2 ** 4) = 2 ** 16 = 65536
</code></p>
| 0 | 2010-03-04T22:06:16Z | [
"python"
] |
What is the associativity of Python's ** operator? | 2,383,034 | <p>I was just playing around with the python command line and the ** operator, which as far as I know performs a power function. So 2 ** 3 should be (and is) 8 because 2 * 2 * 2 = 8.</p>
<p>Can someone explain the behavior I found? I don't see any way to group the operations with parentheses to actually get a result... | 5 | 2010-03-04T21:59:18Z | 2,383,102 | <p>Either it associates to the left or the right. To discover the answer yourself, do the experiment.</p>
<pre><code>>>> 3 ** 3 ** 3
7625597484987
>>> (3 ** 3) ** 3
19683
>>> 3 ** (3 ** 3)
7625597484987
</code></pre>
<p>Thus, it associates to the right.</p>
<p>Or you can read the docs. goo... | 3 | 2010-03-04T22:09:06Z | [
"python"
] |
Can nginx forward to Pylons, ignore response, return alternate response? | 2,383,036 | <p>One of my URLs is for a tracking cookie. In the basic configuration, the pylons controller parses the query string, does a DB query, and sets the cookie accordingly.</p>
<p>I want to move to nginx. I am wondering if this is possible:</p>
<ol>
<li>nginx fetches value of cookie from memcached</li>
<li>nginx writes t... | 0 | 2010-03-04T21:59:43Z | 2,394,377 | <p>The scenario you described is hardly possible "as is". Problems:</p>
<ul>
<li>Nginx cannot read cookie from memcached, as far as I know. It can pass response body only.</li>
<li>Nginx can indeed call "post_action", but this functionality is in beta and you'd better avoid it.</li>
</ul>
<p>Frankly, I don't complete... | 2 | 2010-03-06T22:52:40Z | [
"python",
"web-applications",
"nginx",
"pylons"
] |
Change Node Display Size in Networkx | 2,383,121 | <p>I am not using GraphViz because I am having problems with making it play nice with Networkx. I know this is weird, but I've tried many suggestions to fix this problem, but I just seem to have some of the worst luck in the world. Therefore the problem that I have must be solved withing Networkx without using GraphViz... | 9 | 2010-03-04T22:12:11Z | 2,383,859 | <p>Try <a href="http://networkx.lanl.gov/reference/generated/networkx.draw.html#networkx.draw"><code>nx.draw(G, node_size=size</code>)</a>, where <code>size</code> can be a scalar or an array of length equal to the number of nodes.</p>
| 7 | 2010-03-05T00:57:21Z | [
"python",
"networkx"
] |
pyqt QTreeWidget setItemWidget dissapears after drag/drop | 2,383,212 | <p>I'm trying to keep a widget put into a QTreeWidgetItem after a reparent (drag and drop) using QTreeWidget.setItemWidget()</p>
<p>But the result, if you compile the following code - is that the widget inside the QTreeWidgetItem disappears.
Any idea why? What code would fix this (repopulate the QTreeWidgetItem with ... | 1 | 2010-03-04T22:30:55Z | 2,436,729 | <p>I would love to know why as well, it happens to me too.</p>
<p>It seems the "underlying C/C++ object has been deleted" for the itemWidget. Thats what I get anyway when I try to setItemWidget() again after the widget disappears in the hope that that would fix it.</p>
<p>I put in an event to get called when the QTre... | 0 | 2010-03-13T00:28:56Z | [
"python",
"user-interface",
"qt",
"pyqt",
"qtreewidget"
] |
pyqt QTreeWidget setItemWidget dissapears after drag/drop | 2,383,212 | <p>I'm trying to keep a widget put into a QTreeWidgetItem after a reparent (drag and drop) using QTreeWidget.setItemWidget()</p>
<p>But the result, if you compile the following code - is that the widget inside the QTreeWidgetItem disappears.
Any idea why? What code would fix this (repopulate the QTreeWidgetItem with ... | 1 | 2010-03-04T22:30:55Z | 2,441,033 | <p>managed to get a relatively "working" fix in by writing my own treeDropEvent... however if someone has a more elegant solution, please feel free to share. the code below will solve anyone else's headaches for drag/drop with setItemWidgets in a tree, cheers.</p>
<pre><code>from PyQt4.QtCore import *
from PyQt4.QtGui... | 0 | 2010-03-14T03:59:11Z | [
"python",
"user-interface",
"qt",
"pyqt",
"qtreewidget"
] |
%windir% in Python? | 2,383,306 | <p>How can I do something like</p>
<pre><code>if sys.argv[0] != '%windir%\\blabla.exe'
</code></pre>
<p>I'm having no success at all</p>
| 0 | 2010-03-04T22:46:27Z | 2,383,316 | <p>Use <a href="http://docs.python.org/library/os.html#os.environ" rel="nofollow"><code>os.environ</code></a> to get the value of the environment variable, and string interpolation to put it with the rest of the string:</p>
<pre><code>execfile = r'%s\blabla.exe' % (os.environ['windir'],)
if sys.argv[0] != execfile:
... | 0 | 2010-03-04T22:48:16Z | [
"python",
"windows"
] |
%windir% in Python? | 2,383,306 | <p>How can I do something like</p>
<pre><code>if sys.argv[0] != '%windir%\\blabla.exe'
</code></pre>
<p>I'm having no success at all</p>
| 0 | 2010-03-04T22:46:27Z | 2,383,325 | <p>You need:</p>
<pre><code>if sys.argv[0] != os.environ.get("windir")
</code></pre>
<p>That should do it for you. Just add your <code>blabla.exe</code> on the end of that.</p>
| 0 | 2010-03-04T22:49:25Z | [
"python",
"windows"
] |
%windir% in Python? | 2,383,306 | <p>How can I do something like</p>
<pre><code>if sys.argv[0] != '%windir%\\blabla.exe'
</code></pre>
<p>I'm having no success at all</p>
| 0 | 2010-03-04T22:46:27Z | 2,383,329 | <p>This should illustrate how to get the location of Windows:</p>
<pre><code>>>> import os
>>> os.environ['windir']
'C:\\Windows'
</code></pre>
| 4 | 2010-03-04T22:49:49Z | [
"python",
"windows"
] |
%windir% in Python? | 2,383,306 | <p>How can I do something like</p>
<pre><code>if sys.argv[0] != '%windir%\\blabla.exe'
</code></pre>
<p>I'm having no success at all</p>
| 0 | 2010-03-04T22:46:27Z | 2,383,333 | <pre><code>import os
if sys.argv[0] != os.path.join(os.environ['WINDIR'],'blalah.exe'):
</code></pre>
| 5 | 2010-03-04T22:50:20Z | [
"python",
"windows"
] |
%windir% in Python? | 2,383,306 | <p>How can I do something like</p>
<pre><code>if sys.argv[0] != '%windir%\\blabla.exe'
</code></pre>
<p>I'm having no success at all</p>
| 0 | 2010-03-04T22:46:27Z | 2,383,502 | <pre><code>if sys.argv[0] != '%windir%\\blabla.exe'
</code></pre>
<p>What are you trying to do here?</p>
<p><code>argv[0]</code> is, generally, the filename of the script you are invoking. It would seem unlikely to be <code>blabla.exe</code>, unless you're using some packaging tool to compile yourself into an EXE. If... | 2 | 2010-03-04T23:31:04Z | [
"python",
"windows"
] |
How to I make the result of this a variable? | 2,383,546 | <p>right now its set up to write to a file, but I want it to output the value to a variable. not sure how.</p>
<pre><code>from BeautifulSoup import BeautifulSoup
import sys, re, urllib2
import codecs
woof1 = urllib2.urlopen('someurl').read()
woof_1 = BeautifulSoup(woof1)
woof2 = urllib2.urlopen('someurl').read()
woo... | -1 | 2010-03-04T23:41:24Z | 2,383,569 | <pre><code>values = []
for row in woof_1.findAll("tr", { "class" : "row_b" }):
for col in row.findAll(re.compile('td')):
if col.string:
values.append(col.string)
result = ''.join(values)
</code></pre>
| -1 | 2010-03-04T23:46:39Z | [
"python",
"variables",
"beautifulsoup",
"scrape"
] |
How to I make the result of this a variable? | 2,383,546 | <p>right now its set up to write to a file, but I want it to output the value to a variable. not sure how.</p>
<pre><code>from BeautifulSoup import BeautifulSoup
import sys, re, urllib2
import codecs
woof1 = urllib2.urlopen('someurl').read()
woof_1 = BeautifulSoup(woof1)
woof2 = urllib2.urlopen('someurl').read()
woo... | -1 | 2010-03-04T23:41:24Z | 2,383,576 | <p><strike>maybe like this.</p>
<pre><code>gedb = "";
for row in woof_1.findAll("tr", { "class" : "row_b" }):
for col in row.findAll(re.compile('td')):
if col.string:
gedb += col.string
</code></pre>
<p></strike></p>
| -1 | 2010-03-04T23:47:30Z | [
"python",
"variables",
"beautifulsoup",
"scrape"
] |
How to I make the result of this a variable? | 2,383,546 | <p>right now its set up to write to a file, but I want it to output the value to a variable. not sure how.</p>
<pre><code>from BeautifulSoup import BeautifulSoup
import sys, re, urllib2
import codecs
woof1 = urllib2.urlopen('someurl').read()
woof_1 = BeautifulSoup(woof1)
woof2 = urllib2.urlopen('someurl').read()
woo... | -1 | 2010-03-04T23:41:24Z | 2,383,577 | <pre><code>import cStringIO as StringIO # or import StringIO if on a fringe platform
buf = StringIO.StringIO()
for row in woof_1.findAll("tr", { "class" : "row_b" }):
for col in row.findAll(re.compile('td')):
buf.write(col.string if col.string else '')
result = buf.getvalue()
</code></pre>
| -1 | 2010-03-04T23:47:31Z | [
"python",
"variables",
"beautifulsoup",
"scrape"
] |
How to I make the result of this a variable? | 2,383,546 | <p>right now its set up to write to a file, but I want it to output the value to a variable. not sure how.</p>
<pre><code>from BeautifulSoup import BeautifulSoup
import sys, re, urllib2
import codecs
woof1 = urllib2.urlopen('someurl').read()
woof_1 = BeautifulSoup(woof1)
woof2 = urllib2.urlopen('someurl').read()
woo... | -1 | 2010-03-04T23:41:24Z | 2,383,583 | <p>Get rid of all mentions of GE_DB.</p>
<p>Do a
<code>outputtext = ""</code>
towards the beginning.</p>
<p>Replace <code>GE_DB.write(col.string if col.string else '')</code> with <code>outputtext += col.string if col.string else ''</code></p>
| -1 | 2010-03-04T23:48:45Z | [
"python",
"variables",
"beautifulsoup",
"scrape"
] |
Using Numpy to find the average distance in a set of points | 2,383,645 | <p>I have an array of points in unknown dimensional space, such as:</p>
<pre><code>data=numpy.array(
[[ 115, 241, 314],
[ 153, 413, 144],
[ 535, 2986, 41445]])
</code></pre>
<p>and I would like to find the average euclidean distance between all points.</p>
<p>Please note that I have over 20,000 points, so I would li... | 5 | 2010-03-05T00:03:46Z | 2,383,703 | <p>Well, I don't think that there is a super fast way to do this, but this should do it:</p>
<pre><code>tot = 0.
for i in xrange(data.shape[0]-1):
tot += ((((data[i+1:]-data[i])**2).sum(1))**.5).sum()
avg = tot/((data.shape[0]-1)*(data.shape[0])/2.)
</code></pre>
| 3 | 2010-03-05T00:17:56Z | [
"python",
"performance",
"numpy",
"distance",
"euclidean-distance"
] |
Using Numpy to find the average distance in a set of points | 2,383,645 | <p>I have an array of points in unknown dimensional space, such as:</p>
<pre><code>data=numpy.array(
[[ 115, 241, 314],
[ 153, 413, 144],
[ 535, 2986, 41445]])
</code></pre>
<p>and I would like to find the average euclidean distance between all points.</p>
<p>Please note that I have over 20,000 points, so I would li... | 5 | 2010-03-05T00:03:46Z | 2,383,735 | <p>There's no getting around the number of evaluations: </p>
<p><img src="http://www.equationsheet.com/latexrender/pictures/27744c0bd81116aa31c138ab38a2aa87.gif" alt="Sum[n-i, {i, 0, n}] ="> </p>
<p>But you can save yourself the expense of all those square roots if you can get by with an <a href="http://www.flipcode.... | 3 | 2010-03-05T00:26:57Z | [
"python",
"performance",
"numpy",
"distance",
"euclidean-distance"
] |
Using Numpy to find the average distance in a set of points | 2,383,645 | <p>I have an array of points in unknown dimensional space, such as:</p>
<pre><code>data=numpy.array(
[[ 115, 241, 314],
[ 153, 413, 144],
[ 535, 2986, 41445]])
</code></pre>
<p>and I would like to find the average euclidean distance between all points.</p>
<p>Please note that I have over 20,000 points, so I would li... | 5 | 2010-03-05T00:03:46Z | 2,383,747 | <p>If you have access to scipy, you could try the following:</p>
<p><a href="http://docs.scipy.org/doc/scipy/reference/spatial.distance.html"><code>scipy.spatial.distance.cdist(data,data)</code></a></p>
| 6 | 2010-03-05T00:29:30Z | [
"python",
"performance",
"numpy",
"distance",
"euclidean-distance"
] |
Using Numpy to find the average distance in a set of points | 2,383,645 | <p>I have an array of points in unknown dimensional space, such as:</p>
<pre><code>data=numpy.array(
[[ 115, 241, 314],
[ 153, 413, 144],
[ 535, 2986, 41445]])
</code></pre>
<p>and I would like to find the average euclidean distance between all points.</p>
<p>Please note that I have over 20,000 points, so I would li... | 5 | 2010-03-05T00:03:46Z | 2,383,797 | <p>Now that you've stated your goal of finding the outliers, you are probably better off computing the sample mean and, with that, the sample variance, since both those operations will give you an O(nd) operation. With that, you should be able to find outliers (e.g. excluding points further from the mean than some frac... | 3 | 2010-03-05T00:41:23Z | [
"python",
"performance",
"numpy",
"distance",
"euclidean-distance"
] |
Using Numpy to find the average distance in a set of points | 2,383,645 | <p>I have an array of points in unknown dimensional space, such as:</p>
<pre><code>data=numpy.array(
[[ 115, 241, 314],
[ 153, 413, 144],
[ 535, 2986, 41445]])
</code></pre>
<p>and I would like to find the average euclidean distance between all points.</p>
<p>Please note that I have over 20,000 points, so I would li... | 5 | 2010-03-05T00:03:46Z | 2,384,005 | <p>If you want a fast and inexact solution, you could probably adapt the <a href="http://en.wikipedia.org/wiki/Fast_multipole_method" rel="nofollow">Fast Multipole Method</a> algorithm.</p>
<p>Points that are separated by a small distance have a smaller contribution to the final average distance, so it would make sens... | 0 | 2010-03-05T01:38:21Z | [
"python",
"performance",
"numpy",
"distance",
"euclidean-distance"
] |
Using Numpy to find the average distance in a set of points | 2,383,645 | <p>I have an array of points in unknown dimensional space, such as:</p>
<pre><code>data=numpy.array(
[[ 115, 241, 314],
[ 153, 413, 144],
[ 535, 2986, 41445]])
</code></pre>
<p>and I would like to find the average euclidean distance between all points.</p>
<p>Please note that I have over 20,000 points, so I would li... | 5 | 2010-03-05T00:03:46Z | 2,384,080 | <p>Is it ever worthwhile to optimize without a working solution? Also, computation of a distance matrix over the entire data set rarely needs to be fast because you only do it once--when you need to know a distance between two points, you just look it up, it's already calculated. </p>
<p>So if you don't have a place ... | 3 | 2010-03-05T01:57:31Z | [
"python",
"performance",
"numpy",
"distance",
"euclidean-distance"
] |
Regex: Using lookahead assertion to check if character exist at most a certain number of times | 2,383,682 | <p>How do I use lookahead assertion to determine if a certain character exist at most a certain number of times in a string.</p>
<p>For example, let's say I want to check a string that has at least one character to make sure that it contains "@" at most 2 times. Thanks in advance. Using python if that matters.</p>
| 10 | 2010-03-05T00:13:37Z | 2,383,704 | <p>There are lots of ways to do this, for example:</p>
<pre><code>/^(?=([^@]*@){,2}[^@]*$)./
</code></pre>
| 5 | 2010-03-05T00:18:12Z | [
"python",
"regex"
] |
Regex: Using lookahead assertion to check if character exist at most a certain number of times | 2,383,682 | <p>How do I use lookahead assertion to determine if a certain character exist at most a certain number of times in a string.</p>
<p>For example, let's say I want to check a string that has at least one character to make sure that it contains "@" at most 2 times. Thanks in advance. Using python if that matters.</p>
| 10 | 2010-03-05T00:13:37Z | 2,383,719 | <p>Using a negative lookahead assertion, you can make sure that @ doesn't occur three times:</p>
<pre><code>(?!.*@.*@.*@.*).*
</code></pre>
| 0 | 2010-03-05T00:22:17Z | [
"python",
"regex"
] |
Regex: Using lookahead assertion to check if character exist at most a certain number of times | 2,383,682 | <p>How do I use lookahead assertion to determine if a certain character exist at most a certain number of times in a string.</p>
<p>For example, let's say I want to check a string that has at least one character to make sure that it contains "@" at most 2 times. Thanks in advance. Using python if that matters.</p>
| 10 | 2010-03-05T00:13:37Z | 2,383,724 | <p>I believe Mark's answer wont quite work as you need to exclude the @ from being matched at other times. Try this:</p>
<p><code>^(?=(([^@]*@){0,2}[^@]*$))</code></p>
<p>Edit:
Mark fixed his answer, ours should be the same now. Also, fixed.</p>
| 0 | 2010-03-05T00:24:00Z | [
"python",
"regex"
] |
How can I make an error verifiy with os.makedirs in Python? | 2,383,816 | <p>How can I make a verify error for this command?</p>
<pre><code>if blablablabla:
os.makedirs('C:\\test\\')
</code></pre>
<p>If the folder already exists, he return me an error... how can I make it ignore this error? and move on ?</p>
| 3 | 2010-03-05T00:46:44Z | 2,383,829 | <pre><code>try:
os.makedirs('C:\\test\\')
except OSError:
pass
</code></pre>
<p>You also might want to check the specific "already exists" error (since <code>OSError</code> could mean other things, like <em>permission denied</em>...</p>
<pre><code>import errno
try:
os.makedirs('C:\\test\\')
except OSError... | 12 | 2010-03-05T00:50:10Z | [
"python"
] |
How can I make an error verifiy with os.makedirs in Python? | 2,383,816 | <p>How can I make a verify error for this command?</p>
<pre><code>if blablablabla:
os.makedirs('C:\\test\\')
</code></pre>
<p>If the folder already exists, he return me an error... how can I make it ignore this error? and move on ?</p>
| 3 | 2010-03-05T00:46:44Z | 2,383,836 | <p>you can try/except?</p>
<pre><code>try:
os.makedirs('C:\\test\\')
except: pass
</code></pre>
| -2 | 2010-03-05T00:52:14Z | [
"python"
] |
_winreg.CreateKey problem in Python | 2,383,970 | <p>I'm trying to create a key like this</p>
<pre><code>_winreg.CreateKey(_winreg.HKEY_LOCAL_MACHINE, 'Software\\Microsoft\\Shared Tools\\MSCONFIG\\startupreg\\test\\')
</code></pre>
<p>and the key is beeing created here</p>
<pre><code>HKLM\Software\Wow6432Node\Microsoft\Shared Tools\MSCONFIG\startupreg\test\
</code>... | 2 | 2010-03-05T01:30:15Z | 2,383,981 | <p><a href="http://msdn.microsoft.com/en-us/library/aa384253%28VS.85%29.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/aa384253%28VS.85%29.aspx</a></p>
| 0 | 2010-03-05T01:33:12Z | [
"python",
"windows",
"registry"
] |
_winreg.CreateKey problem in Python | 2,383,970 | <p>I'm trying to create a key like this</p>
<pre><code>_winreg.CreateKey(_winreg.HKEY_LOCAL_MACHINE, 'Software\\Microsoft\\Shared Tools\\MSCONFIG\\startupreg\\test\\')
</code></pre>
<p>and the key is beeing created here</p>
<pre><code>HKLM\Software\Wow6432Node\Microsoft\Shared Tools\MSCONFIG\startupreg\test\
</code>... | 2 | 2010-03-05T01:30:15Z | 11,216,141 | <p>You can read the article Glenn referred to, but it will not be much help.</p>
<p>What you probably need is proper access rights combined with <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa384129%28v=vs.85%29.aspx" rel="nofollow">access to the 64-bit registry view</a>:</p>
<pre><code>with _winr... | 1 | 2012-06-26T21:24:44Z | [
"python",
"windows",
"registry"
] |
Why aren't there any dates in the Netflix.com NewWatchInstantlyRSS feed entries (when parsed with feedparser)? | 2,384,056 | <p>The output from the following:</p>
<pre><code>import feedparser
d = feedparser.parse('http://www.netflix.com/NewWatchInstantlyRSS')
d.entries[177].keys()
</code></pre>
<p>is:</p>
<pre><code>['summary_detail', 'links', 'title', 'summary', 'guidislink', 'title_detail', 'link', 'id']
</code></pre>
<p>According to <... | 0 | 2010-03-05T01:50:25Z | 2,384,074 | <p>IF you look at the raw source of the RSS feed at <a href="http://www.netflix.com/NewWatchInstantlyRSS" rel="nofollow">http://www.netflix.com/NewWatchInstantlyRSS</a> (Open in a web browser and view the source) you'll see they did not include a date element. There SHOULD be, but there is not.</p>
<p>EDIT: Sorry I di... | 1 | 2010-03-05T01:54:33Z | [
"python",
"rss",
"feedparser",
"netflix"
] |
python: _winreg problem | 2,384,064 | <p>the windows registry may contain keys whose names with embedded nulls</p>
<p>when i call <code>_winreg.OpenKey(key, subkey_string_with_embbeded_null)</code> i get the following error:</p>
<pre><code>TypeError: OpenKey() argument 2 must be string without null bytes or None, not str
</code></pre>
<p>Q1: is the mean... | 2 | 2010-03-05T01:52:38Z | 2,384,145 | <p>Q1: right.</p>
<p>Q2: download and install <a href="http://python.net/crew/skippy/win32/Downloads.html" rel="nofollow">win32all</a>.</p>
| 4 | 2010-03-05T02:18:06Z | [
"python",
"winreg"
] |
Why is ''>0 True in Python? | 2,384,078 | <p>In Python 2.6.4:</p>
<pre><code>>> ''>0
True
</code></pre>
<p>Why is that?</p>
| 24 | 2010-03-05T01:57:02Z | 2,384,090 | <p>from <a href="http://docs.python.org/tutorial/datastructures.html#id1">http://docs.python.org/tutorial/datastructures.html#id1</a></p>
<p>Note that comparing objects of different types is legal. The outcome is deterministic but arbitrary: the types are ordered by their name. Thus, a list is always smaller than a st... | 21 | 2010-03-05T02:00:40Z | [
"python",
"operators",
"logic"
] |
Why is ''>0 True in Python? | 2,384,078 | <p>In Python 2.6.4:</p>
<pre><code>>> ''>0
True
</code></pre>
<p>Why is that?</p>
| 24 | 2010-03-05T01:57:02Z | 2,384,139 | <p>The original design motivation for allowing order-comparisons of arbitrary objects was to allow sorting of heterogenous lists -- usefully, that would put all strings next to each other in alphabetical order, and all numbers next to each other in numerical order, although which of the two blocks came first was not gu... | 55 | 2010-03-05T02:16:19Z | [
"python",
"operators",
"logic"
] |
Connect to a samba share with python in a platform independent manner? | 2,384,165 | <p>Is there an abstraction that will allow me to connect to a samba share in python regardless of my platform?</p>
<p><strong>More information</strong></p>
<p>I do not want to mount a share. I simply want to upload files to a share, such as smbclient's put. </p>
<p>Thanks,
Pete</p>
| 0 | 2010-03-05T02:23:05Z | 2,384,285 | <p>As per <a href="http://stackoverflow.com/questions/2232420/how-to-mount-a-network-directory-using-python">this question</a>, I would use <code>subprocess</code> to execute a <code>mount</code> command in Unix-y systems (most all of them save windows) -- and <code>mountvol</code> on windows, which that SO question do... | 0 | 2010-03-05T02:58:56Z | [
"python",
"abstraction",
"samba"
] |
Connect to a samba share with python in a platform independent manner? | 2,384,165 | <p>Is there an abstraction that will allow me to connect to a samba share in python regardless of my platform?</p>
<p><strong>More information</strong></p>
<p>I do not want to mount a share. I simply want to upload files to a share, such as smbclient's put. </p>
<p>Thanks,
Pete</p>
| 0 | 2010-03-05T02:23:05Z | 12,208,181 | <p>pysmb seems to do this:
<a href="http://packages.python.org/pysmb/" rel="nofollow">http://packages.python.org/pysmb/</a></p>
| 2 | 2012-08-31T02:33:48Z | [
"python",
"abstraction",
"samba"
] |
Crontab job does not start... ideas? | 2,384,225 | <p>thanks for helping me setting my cron jobs, crontab has really been a gold mine for me.</p>
<p>Unfortunately I have a problem, and have no idea what so ever what it might be... basically a job does not start while the neighbour jobs do. I'll explain</p>
<hr>
<p>This is my crontabs job list:</p>
<blockquote>
<p... | 0 | 2010-03-05T02:40:31Z | 2,384,246 | <p>From the crontab manpage:</p>
<blockquote>
<p>BUGS
Although <strong>cron requires that each entry in a crontab end in a
newline character</strong>,
neither the crontab command nor the cron daemon will detect this
error. Instead,
the crontab will appear to load normally. However, ... | 3 | 2010-03-05T02:47:05Z | [
"python",
"linux",
"ubuntu",
"cron",
"crontab"
] |
Crontab job does not start... ideas? | 2,384,225 | <p>thanks for helping me setting my cron jobs, crontab has really been a gold mine for me.</p>
<p>Unfortunately I have a problem, and have no idea what so ever what it might be... basically a job does not start while the neighbour jobs do. I'll explain</p>
<hr>
<p>This is my crontabs job list:</p>
<blockquote>
<p... | 0 | 2010-03-05T02:40:31Z | 2,384,258 | <p>Cron always runs in an environment different to what you think :-)</p>
<p>I always have my cronjobs set up like:</p>
<pre><code>*/10 * * * * ( date ; python /webapps/foo/manage.py fetch_articles ) >>/tmp/fetch.out 2>&1
</code></pre>
<p>to ensure that there's something logged that I can look at.</p>
... | 6 | 2010-03-05T02:51:39Z | [
"python",
"linux",
"ubuntu",
"cron",
"crontab"
] |
Crontab job does not start... ideas? | 2,384,225 | <p>thanks for helping me setting my cron jobs, crontab has really been a gold mine for me.</p>
<p>Unfortunately I have a problem, and have no idea what so ever what it might be... basically a job does not start while the neighbour jobs do. I'll explain</p>
<hr>
<p>This is my crontabs job list:</p>
<blockquote>
<p... | 0 | 2010-03-05T02:40:31Z | 2,384,281 | <p>I think ~unutbu's answer is probably correct if it's the second job that isn't running.</p>
<p>However another thing to check is whether <code>/webapps/bar/manage.py</code> requires exclusive access to any resources, eg network sockets/tempfiles etc. Since you are starting 2 processes at the same time, you may be t... | 1 | 2010-03-05T02:58:08Z | [
"python",
"linux",
"ubuntu",
"cron",
"crontab"
] |
Better way to script USB device mount in Linux | 2,384,290 | <p>I'm writing a python module for a device that interacts with a user supplied USB memory stick. The user can insert a USB memory stick in the device USB slot, and the device will dump data onto the memory stick without user intervention. If the device is running when the user inserts the USB stick, I have hooked into... | 4 | 2010-03-05T03:00:02Z | 2,384,509 | <p>I'm not entirely certain how portable this is. Also, this information would presumably also be available over D-Bus from <a href="http://www.freedesktop.org/wiki/Software/udisks" rel="nofollow">udisks</a> or <a href="http://www.freedesktop.org/wiki/Software/hal" rel="nofollow">HAL</a> but neither of those is presen... | 1 | 2010-03-05T04:08:11Z | [
"python",
"linux",
"usb"
] |
Better way to script USB device mount in Linux | 2,384,290 | <p>I'm writing a python module for a device that interacts with a user supplied USB memory stick. The user can insert a USB memory stick in the device USB slot, and the device will dump data onto the memory stick without user intervention. If the device is running when the user inserts the USB stick, I have hooked into... | 4 | 2010-03-05T03:00:02Z | 2,414,732 | <p>This seems to work combining <code>/proc/partitions</code> and the <code>/sys/class/block</code> approach ephimient took.</p>
<pre><code>#!/usr/bin/python
import os
partitionsFile = open("/proc/partitions")
lines = partitionsFile.readlines()[2:]#Skips the header lines
for line in lines:
words = [x.strip() for x... | 2 | 2010-03-10T05:27:35Z | [
"python",
"linux",
"usb"
] |
Better way to script USB device mount in Linux | 2,384,290 | <p>I'm writing a python module for a device that interacts with a user supplied USB memory stick. The user can insert a USB memory stick in the device USB slot, and the device will dump data onto the memory stick without user intervention. If the device is running when the user inserts the USB stick, I have hooked into... | 4 | 2010-03-05T03:00:02Z | 22,454,071 | <p>After <a href="http://stackoverflow.com/questions/483460/how-to-mount-from-command-line-like-the-nautilus-does">looking at this thread</a> about doing what ubuntu does with nautilus, i found a few recommendations and decided to go with accessing udisks through shell commands. </p>
<p>The Mass storage device class i... | 0 | 2014-03-17T12:17:52Z | [
"python",
"linux",
"usb"
] |
Better way to script USB device mount in Linux | 2,384,290 | <p>I'm writing a python module for a device that interacts with a user supplied USB memory stick. The user can insert a USB memory stick in the device USB slot, and the device will dump data onto the memory stick without user intervention. If the device is running when the user inserts the USB stick, I have hooked into... | 4 | 2010-03-05T03:00:02Z | 29,411,921 | <p>why don't you simply use an udev rule? i had to deal with a similar situation, and my solution was to create a file in /etc/udev/rules.d containing following rule:</p>
<pre><code>SUBSYSTEMS=="scsi", KERNEL=="sd[b-h]1", RUN+="/bin/mount -o umask=000 /dev/%k /media/usbdrive"
</code></pre>
<p>one assumption here is t... | 0 | 2015-04-02T11:33:00Z | [
"python",
"linux",
"usb"
] |
py2app Not Finding BeautifulSoup | 2,384,296 | <p>I have a script that uses <a href="http://www.crummy.com/software/BeautifulSoup/" rel="nofollow">BeautifulSoup</a> that I want to make into a standalone app using <a href="http://svn.pythonmac.org/py2app/py2app/trunk/doc/index.html" rel="nofollow">py2app</a>. When I run the app made by py2app I get an error saying ... | 0 | 2010-03-05T03:01:08Z | 2,384,375 | <p>Ppy2app doesn't work with python eggs. You need to extract the contents of the egg (a zip file), or install BeuatifulSoup from a different source. I Believe BeautifulSoup is 1 source file, so you could just copy it into you app folder.</p>
| 1 | 2010-03-05T03:24:18Z | [
"python",
"beautifulsoup",
"py2app"
] |
List of evented / asynchronous languages | 2,384,314 | <p>I'm working on a system than has to be pretty scalable from the beginning. I've started looking at / playing around with asynchronous/evented approaches to writing serverside code. I've played around with both ruby's EventMachine and node.js.</p>
<p>EventMachine is cool, but doesn't have asynchronous file I/O, whic... | 9 | 2010-03-05T03:07:00Z | 2,384,352 | <p>F# has asynchronous workflows, which are a tremendous way to write async code.</p>
| 3 | 2010-03-05T03:16:07Z | [
"javascript",
"python",
"ruby",
"asynchronous",
"lisp"
] |
List of evented / asynchronous languages | 2,384,314 | <p>I'm working on a system than has to be pretty scalable from the beginning. I've started looking at / playing around with asynchronous/evented approaches to writing serverside code. I've played around with both ruby's EventMachine and node.js.</p>
<p>EventMachine is cool, but doesn't have asynchronous file I/O, whic... | 9 | 2010-03-05T03:07:00Z | 2,384,368 | <p><a href="http://ftp.sunet.se/pub/lang/erlang/">Erlang</a> may be the language with the highest intrinsic scalability for server-side code (it manages multiprocessing for you, mostly by doing async, cooperative task switching "under the covers") -- if you can stomach its peculiar syntax and (often) peculiar semantics... | 19 | 2010-03-05T03:21:22Z | [
"javascript",
"python",
"ruby",
"asynchronous",
"lisp"
] |
List of evented / asynchronous languages | 2,384,314 | <p>I'm working on a system than has to be pretty scalable from the beginning. I've started looking at / playing around with asynchronous/evented approaches to writing serverside code. I've played around with both ruby's EventMachine and node.js.</p>
<p>EventMachine is cool, but doesn't have asynchronous file I/O, whic... | 9 | 2010-03-05T03:07:00Z | 2,387,765 | <p>I would recommend that you take another look at <a href="http://NodeJS.Org/">node.js</a>. One of the biggest problems with using libraries to do event-based programming in an object-oriented programming language (rather than using an event-based programming language in the first place), is that usually all the <em>o... | 13 | 2010-03-05T15:20:18Z | [
"javascript",
"python",
"ruby",
"asynchronous",
"lisp"
] |
List of evented / asynchronous languages | 2,384,314 | <p>I'm working on a system than has to be pretty scalable from the beginning. I've started looking at / playing around with asynchronous/evented approaches to writing serverside code. I've played around with both ruby's EventMachine and node.js.</p>
<p>EventMachine is cool, but doesn't have asynchronous file I/O, whic... | 9 | 2010-03-05T03:07:00Z | 2,395,529 | <p>Since you have expressed interest in Lisp, you might want to consider <a href="http://clojure.org" rel="nofollow">Clojure</a> - a Lisp dialect for the JVM with a strong focus on <a href="http://clojure.org/concurrent_programming" rel="nofollow">concurrency</a>. Pretty much anything can be run asynchronously by runni... | 4 | 2010-03-07T07:39:19Z | [
"javascript",
"python",
"ruby",
"asynchronous",
"lisp"
] |
Python in SU cron gives different output than manually execution | 2,384,327 | <p>Ubuntu Server 9.10,
Here is my file, test.py</p>
<pre><code>import commands
blkid = commands.getoutput('blkid')
print blkid
</code></pre>
<p>When I manually run (as SU) this:</p>
<pre><code>python test.py
</code></pre>
<p>I get the output of the <em>blkid</em> as expected:</p>
<pre><code>/dev/sda1: UUID="3f0ac5... | 0 | 2010-03-05T03:10:15Z | 2,384,348 | <p>The problem is probably with your <code>$PATH</code> versus root's (<code>os.environ['PATH']</code> if you're looking at it in Python rather than shell;-). root's PATH is typically very conservative (it would be risky for it NOT to be!) and since you're running <code>blkid</code> without specifying an absolute path... | 2 | 2010-03-05T03:15:40Z | [
"python",
"cron",
"sudo",
"crontab"
] |
Python in SU cron gives different output than manually execution | 2,384,327 | <p>Ubuntu Server 9.10,
Here is my file, test.py</p>
<pre><code>import commands
blkid = commands.getoutput('blkid')
print blkid
</code></pre>
<p>When I manually run (as SU) this:</p>
<pre><code>python test.py
</code></pre>
<p>I get the output of the <em>blkid</em> as expected:</p>
<pre><code>/dev/sda1: UUID="3f0ac5... | 0 | 2010-03-05T03:10:15Z | 2,384,350 | <p>The environment (and PATH) of a cron job is not necessarily the same as your login shell.</p>
| 0 | 2010-03-05T03:15:59Z | [
"python",
"cron",
"sudo",
"crontab"
] |
rounded rectangle in pygtk | 2,384,374 | <p>what is the best way to draw a rounded rectangle in a pygtk application</p>
| 0 | 2010-03-05T03:24:00Z | 2,384,585 | <p>Probably <a href="http://www.cairographics.org/pycairo/" rel="nofollow">pycairo</a></p>
| 0 | 2010-03-05T04:37:49Z | [
"python",
"gtk",
"pygtk"
] |
rounded rectangle in pygtk | 2,384,374 | <p>what is the best way to draw a rounded rectangle in a pygtk application</p>
| 0 | 2010-03-05T03:24:00Z | 2,396,082 | <pre><code>#!/usr/bin/env python
import gtk
def rounded_rectangle(cr, x, y, w, h, r=20):
# This is just one of the samples from
# http://www.cairographics.org/cookbook/roundedrectangles/
# A****BQ
# H C
# * *
# G D
# F****E
cr.move_to(x+r,y) ... | 5 | 2010-03-07T11:29:37Z | [
"python",
"gtk",
"pygtk"
] |
rounded rectangle in pygtk | 2,384,374 | <p>what is the best way to draw a rounded rectangle in a pygtk application</p>
| 0 | 2010-03-05T03:24:00Z | 6,959,843 | <p>Coincidentally, I have put, myself, a code snippet on the same tutorial page cited in @ptomato 's code. The advantage is the use of <code>arc</code> instead of <code>curve</code>, because it will create true circular arc corners. Here it goes:</p>
<pre><code>def draw_rounded(cr, area, radius):
""" draws rectang... | 1 | 2011-08-05T16:54:23Z | [
"python",
"gtk",
"pygtk"
] |
wx.ProgressDialog too small | 2,384,397 | <p>My program uses <a href="http://www.wxpython.org/docs/api/wx.ProgressDialog-class.html" rel="nofollow"><code>wx.ProgressDialog</code></a> to give feedback on a process that is in multiple stages. At the beginning of each stage, I use the second argument of <code>Update</code> to change the message in the dialog.</p... | 2 | 2010-03-05T03:32:14Z | 2,385,927 | <p>call wx.Fit() on the dialog, or you can use SetSize((x, y))</p>
| 5 | 2010-03-05T10:15:04Z | [
"python",
"wxpython"
] |
How to introspect django model fields? | 2,384,436 | <p>I am trying to obtain class information on a field inside a model, when I only know name of the field and name of the model (both plain strings). How is it possible?</p>
<p>I can load the model dynamically:</p>
<pre><code>from django.db import models
model = models.get_model('myapp','mymodel')
</code></pre>
<p>No... | 32 | 2010-03-05T03:45:00Z | 2,384,902 | <p>You can use model's <code>_meta</code> attribute to get field object and from field you can get relationship and much more e.g. consider a employee table which has a foreign key to a department table</p>
<pre><code>In [1]: from django.db import models
In [2]: model = models.get_model('timeapp', 'Employee')
In [3]... | 68 | 2010-03-05T06:10:31Z | [
"python",
"django-models",
"introspection"
] |
How to introspect django model fields? | 2,384,436 | <p>I am trying to obtain class information on a field inside a model, when I only know name of the field and name of the model (both plain strings). How is it possible?</p>
<p>I can load the model dynamically:</p>
<pre><code>from django.db import models
model = models.get_model('myapp','mymodel')
</code></pre>
<p>No... | 32 | 2010-03-05T03:45:00Z | 37,011,778 | <p>The answer from Anurag Uniyal to use <code>get_field_by_name</code> is now (5 years later) outdated as <code>get_field_by_name</code> is deprecated.
Django will give you the following hint:</p>
<blockquote>
<p>RemovedInDjango110Warning: 'get_field_by_name is an unofficial API
that has been deprecated. You may b... | 1 | 2016-05-03T18:31:37Z | [
"python",
"django-models",
"introspection"
] |
Sqlalchemy - Can we use date comparison in relation definition? | 2,384,438 | <p>I have this mapper defined:</p>
<pre><code>mapper(Resource, resource_table,
properties = {'type' : relation(ResourceType,lazy = False),
'groups' : relation(Group, secondary = model.tables['resource_group'],
backref = 'resources'),
'parent' : relation(Relation, uselist=False, primaryjoin =
and_(re... | 0 | 2010-03-05T03:45:56Z | 2,384,607 | <p>I have actually found what was wrong.
The relation is actually working.
The problem was solved by setting the end_date to something like datetime.now() - 1 second, so it happens before the resource is actually refreshed by SQLAlchemy.
A milliseconds issue I suppose.</p>
<p>Richard Lopes</p>
| 0 | 2010-03-05T04:43:53Z | [
"python",
"database",
"orm",
"sqlalchemy",
"mapper"
] |
python library for file upload and persistent connections? | 2,384,496 | <p>I tried urllib{2}, pycurl and I'm looking at twisted's new http client.
But:</p>
<ul>
<li>I found urllib2 difficult to perform a file upload</li>
<li>pycurl multi looks right but unpythonic</li>
<li>twisted's http client does not support persistent connection (didn't check the file upload capability)</li>
</ul>
<p... | 1 | 2010-03-05T04:03:10Z | 2,391,090 | <p><a href="http://www.picloud.com" rel="nofollow">PiCloud</a>'s library uses urllib2_file which easily does upload via multipart data. I forget where we got the module (we later modified it). the urllib2_file is covered under a BSD license.</p>
| 2 | 2010-03-06T02:08:45Z | [
"python",
"httpwebrequest",
"twisted",
"pycurl"
] |
python library for file upload and persistent connections? | 2,384,496 | <p>I tried urllib{2}, pycurl and I'm looking at twisted's new http client.
But:</p>
<ul>
<li>I found urllib2 difficult to perform a file upload</li>
<li>pycurl multi looks right but unpythonic</li>
<li>twisted's http client does not support persistent connection (didn't check the file upload capability)</li>
</ul>
<p... | 1 | 2010-03-05T04:03:10Z | 7,800,617 | <p>I rolled my own on top of <code>httplib</code> before discovering <a href="http://pypi.python.org/pypi/urllib3/1.0.1" rel="nofollow" title="urllib3">urllib3</a>, which does both of these things. </p>
| 1 | 2011-10-17T23:02:20Z | [
"python",
"httpwebrequest",
"twisted",
"pycurl"
] |
OperationalError creating an index in sqlite | 2,384,754 | <p><strong>EDIT: TL;DR version</strong></p>
<p>I typed this</p>
<pre><code>CREATE INDEX IF NOT EXISTS IDX_FILE_SIZE table_name (file_size);
</code></pre>
<p>instead of this</p>
<pre><code>CREATE INDEX IF NOT EXISTS IDX_FILE_SIZE ON table_name (file_size);
</code></pre>
<p>Don't do that.</p>
| 6 | 2010-03-05T05:37:18Z | 2,386,990 | <p>Some silly questions:</p>
<p>Is it a concidence that the offending statement is missing the word <code>ON</code>?</p>
<p>CREATE INDEX IF NOT EXISTS IDX_FILE_FULLPATH_FILE_PARENT_DIR <strong>ON</strong> table_name (file_fullpath, file_parent_dir);<br>
CREATE INDEX IF NOT EXISTS IDX_FILE_SIZE table_name (file_size);... | 5 | 2010-03-05T13:24:21Z | [
"python",
"sql",
"sqlite",
"indexing"
] |
can't call __add__ through __getattr__( __getattribute__ ) | 2,384,905 | <p>It is object of the class A, in container's class tmpA. Not all method
from A are in the tmpA. So for example:
A + B is present , tmpA + B isn't present. I try to call method from A for tmpA. I
can to call simple method, such as change(), but <code>__add__</code> - don't
work. If to remove inheritance from obje... | 2 | 2010-03-05T06:10:57Z | 2,384,982 | <p>I think <code>X + Y</code> is taken as <code>X.__add__(Y)</code>.</p>
<p>So if you use</p>
<p><code>class tempA(A)</code> then <code>temp_a + b</code> works because it <strong><em>inherits</em></strong> <code>__add__</code> method and uses it like <code>temp_a.__add__(b)</code>.</p>
<p>but if you use</p>
<p><cod... | 2 | 2010-03-05T06:36:53Z | [
"python"
] |
can't call __add__ through __getattr__( __getattribute__ ) | 2,384,905 | <p>It is object of the class A, in container's class tmpA. Not all method
from A are in the tmpA. So for example:
A + B is present , tmpA + B isn't present. I try to call method from A for tmpA. I
can to call simple method, such as change(), but <code>__add__</code> - don't
work. If to remove inheritance from obje... | 2 | 2010-03-05T06:10:57Z | 2,384,983 | <p>Special methods are looked up <strong>on the class</strong>, that is, <strong>not</strong> on the <em>instance</em> of the class (except for some irregularities in old-style classes, which just mean a huge headache). So in particular the class's <code>__getattr__</code> (for sane, new-style classes) is <strong>not<... | 5 | 2010-03-05T06:37:11Z | [
"python"
] |
can't call __add__ through __getattr__( __getattribute__ ) | 2,384,905 | <p>It is object of the class A, in container's class tmpA. Not all method
from A are in the tmpA. So for example:
A + B is present , tmpA + B isn't present. I try to call method from A for tmpA. I
can to call simple method, such as change(), but <code>__add__</code> - don't
work. If to remove inheritance from obje... | 2 | 2010-03-05T06:10:57Z | 2,384,986 | <p>When you say <code>tmp_a + b</code>, Python looks in <code>tmp_a.__class__.__dict__</code> and then <code>object.__dict__</code> for the <code>__add__</code> method (bypassing the hasattr/getattr type lookup)</p>
<p>Since it is not found anywhere, Python then looks to see if <code>b</code> has an <code>__radd__</co... | 1 | 2010-03-05T06:37:45Z | [
"python"
] |
What is the appropriate way to intercept WSGI start_response? | 2,384,908 | <p>I have WSGI middleware that needs to capture the HTTP status (e.g. <code>200 OK</code>) that inner layers of middleware return by calling <code>start_response</code>. Currently I'm doing the following, but abusing a list doesn't seem to be the ârightâ solution to me:</p>
<pre>class TransactionalMiddlewareInter... | 3 | 2010-03-05T06:11:56Z | 2,385,908 | <p>You can assign the status as an injected field of <code>local_start</code> function itself rather than using <code>status</code> list. I used something similar, works fine:</p>
<pre><code>class TransactionalMiddlewareInterface(object):
def __init__(self, application, **config):
self.application = applic... | 3 | 2010-03-05T10:11:51Z | [
"python",
"wsgi",
"middleware",
"correctness"
] |
What are the helpful online resources there for Python beginners? | 2,385,380 | <p><strong>Specifically for the ff: topics:</strong> </p>
<ul>
<li>Windows installation</li>
<li>Using mod_wsgi/mod_python</li>
<li>Python best practices</li>
<li>Python security stuff</li>
<li>Using Pylons</li>
</ul>
<p>Thanks</p>
| 0 | 2010-03-05T08:22:05Z | 2,385,521 | <p>Best practices: <a href="http://python.net/~goodger/projects/pycon/2007/idiomatic/handout.html" rel="nofollow">http://python.net/~goodger/projects/pycon/2007/idiomatic/handout.html</a></p>
<p>Pylons: <a href="http://pylonsbook.com/" rel="nofollow">http://pylonsbook.com/</a></p>
<p>And obviously, the Python docs: <... | 0 | 2010-03-05T08:56:43Z | [
"python",
"installation",
"pylons"
] |
What are the helpful online resources there for Python beginners? | 2,385,380 | <p><strong>Specifically for the ff: topics:</strong> </p>
<ul>
<li>Windows installation</li>
<li>Using mod_wsgi/mod_python</li>
<li>Python best practices</li>
<li>Python security stuff</li>
<li>Using Pylons</li>
</ul>
<p>Thanks</p>
| 0 | 2010-03-05T08:22:05Z | 2,385,560 | <p><a href="http://docs.python.org/tutorial/" rel="nofollow">The official Python tutorial</a> is a High quality, very well written introduction to Python.</p>
<p><a href="http://wiki.python.org/moin/BeginnersGuide" rel="nofollow">The Begginers guide</a> is a good source of all interesting materials of Python.</p>
<p>... | 1 | 2010-03-05T09:06:06Z | [
"python",
"installation",
"pylons"
] |
Pointer argument to boost python | 2,385,561 | <p>What's the best way to make a function that has pointer as argument work with boost python?
I see there are many possibilities for return values in the docs, but I don't know how to do it with arguments.</p>
<pre><code>void Tesuto::testp(std::string* s)
{
if (!s)
cout << " NULL s" << endl;
... | 5 | 2010-03-05T09:06:07Z | 2,531,363 | <p>As far as I can tell, after doing a bit of googling on the subject, is that you can't. Python doesn't support pointer argument types by default. If you wanted to, you could probably edit the python interpreter by hand, but this seems to me to be production code of some sort, so that probably isn't an option.</p>
<p... | 4 | 2010-03-27T23:43:25Z | [
"python",
"boost",
"pointers",
"arguments",
"argument-passing"
] |
how do I include a boolean AND within a regex? | 2,385,762 | <p>Is there a way to get single regex to satisfy this condition??</p>
<p>I am looking for a "word" that has three letters from the set MBIPI, any order,
but MUST contain an I.</p>
<p>ie.</p>
<p>re.match("[MBDPI]{3}", foo) and "I" in foo</p>
<p>So this is the correct result (in python using the re module), but can ... | 4 | 2010-03-05T09:47:24Z | 2,385,782 | <p>Or is about the only thing you can do:</p>
<pre><code>\b(I[MBDPI]{2}|[MBDPI]I[MBDPI]|[MBDPI]{2}I)\b
</code></pre>
<p>The <code>\b</code> character matches a zero-width word boundary. This ensures you match something that is exactly three characters long.</p>
<p>You're otherwise running into the limits to what a <... | 2 | 2010-03-05T09:50:35Z | [
"python",
"regex"
] |
how do I include a boolean AND within a regex? | 2,385,762 | <p>Is there a way to get single regex to satisfy this condition??</p>
<p>I am looking for a "word" that has three letters from the set MBIPI, any order,
but MUST contain an I.</p>
<p>ie.</p>
<p>re.match("[MBDPI]{3}", foo) and "I" in foo</p>
<p>So this is the correct result (in python using the re module), but can ... | 4 | 2010-03-05T09:47:24Z | 2,385,809 | <p>You can fake boolean AND by using lookaheads. According to <a href="http://www.regular-expressions.info/lookaround2.html" rel="nofollow">http://www.regular-expressions.info/lookaround2.html</a>, this will work for your case:</p>
<pre><code>"\b(?=[MBDPI]{3}\b)\w*I\w*"
</code></pre>
| 3 | 2010-03-05T09:55:15Z | [
"python",
"regex"
] |
how do I include a boolean AND within a regex? | 2,385,762 | <p>Is there a way to get single regex to satisfy this condition??</p>
<p>I am looking for a "word" that has three letters from the set MBIPI, any order,
but MUST contain an I.</p>
<p>ie.</p>
<p>re.match("[MBDPI]{3}", foo) and "I" in foo</p>
<p>So this is the correct result (in python using the re module), but can ... | 4 | 2010-03-05T09:47:24Z | 2,385,819 | <p>You could use lookahead to see if an <code>I</code> is present:</p>
<pre><code>(?=[MBDPI]{0,2}I)[MBDPI]{3}
</code></pre>
| 2 | 2010-03-05T09:57:00Z | [
"python",
"regex"
] |
how do I include a boolean AND within a regex? | 2,385,762 | <p>Is there a way to get single regex to satisfy this condition??</p>
<p>I am looking for a "word" that has three letters from the set MBIPI, any order,
but MUST contain an I.</p>
<p>ie.</p>
<p>re.match("[MBDPI]{3}", foo) and "I" in foo</p>
<p>So this is the correct result (in python using the re module), but can ... | 4 | 2010-03-05T09:47:24Z | 21,048,476 | <blockquote>
<p>with regex I know I can use | as a boolean OR operator, but is there a boolean AND equivalent?</p>
</blockquote>
<p>A and B = not ( not A or not B) = (?![^A]|[^B])</p>
<p>A and B being expressions that actually may have members in common.</p>
| 0 | 2014-01-10T15:45:32Z | [
"python",
"regex"
] |
Which is best in Python: urllib2, PycURL or mechanize? | 2,385,855 | <p>Ok so I need to download some web pages using Python and did a quick investigation of my options.</p>
<p>Included with Python:</p>
<p><a href="http://docs.python.org/library/urllib.html">urllib</a> - seems to me that I should use urllib2 instead. urllib has no cookie support, HTTP/FTP/local files only (no SSL)</p>... | 70 | 2010-03-05T10:02:48Z | 2,385,955 | <ul>
<li><code>urllib2</code> is found in every Python install everywhere, so is a good base upon which to start.</li>
<li><code>PycURL</code> is useful for people already used to using libcurl, exposes more of the low-level details of HTTP, plus it gains any fixes or improvements applied to libcurl.</li>
<li><code>mec... | 35 | 2010-03-05T10:21:12Z | [
"python",
"urllib2",
"mechanize",
"pycurl"
] |
Which is best in Python: urllib2, PycURL or mechanize? | 2,385,855 | <p>Ok so I need to download some web pages using Python and did a quick investigation of my options.</p>
<p>Included with Python:</p>
<p><a href="http://docs.python.org/library/urllib.html">urllib</a> - seems to me that I should use urllib2 instead. urllib has no cookie support, HTTP/FTP/local files only (no SSL)</p>... | 70 | 2010-03-05T10:02:48Z | 2,386,102 | <p>I think this talk (at pycon 2009), has the answers for what you're looking for (Asheesh Laroia has lots of experience on the matter). And he points out the good and the bad from most of your listing</p>
<ul>
<li><a href="http://pyvideo.org/video/166/pycon-2009--scrape-the-web--strategies-for-progr0">Scrape the Web:... | 42 | 2010-03-05T10:48:30Z | [
"python",
"urllib2",
"mechanize",
"pycurl"
] |
Which is best in Python: urllib2, PycURL or mechanize? | 2,385,855 | <p>Ok so I need to download some web pages using Python and did a quick investigation of my options.</p>
<p>Included with Python:</p>
<p><a href="http://docs.python.org/library/urllib.html">urllib</a> - seems to me that I should use urllib2 instead. urllib has no cookie support, HTTP/FTP/local files only (no SSL)</p>... | 70 | 2010-03-05T10:02:48Z | 2,386,219 | <p>Don't worry about "last updated". HTTP hasn't changed much in the last few years ;)</p>
<p>urllib2 is best (as it's inbuilt), then switch to mechanize if you need cookies from Firefox. mechanize can be used as a drop-in replacement for urllib2 - they have similar methods etc. Using Firefox cookies means you can get... | 2 | 2010-03-05T11:09:02Z | [
"python",
"urllib2",
"mechanize",
"pycurl"
] |
Which is best in Python: urllib2, PycURL or mechanize? | 2,385,855 | <p>Ok so I need to download some web pages using Python and did a quick investigation of my options.</p>
<p>Included with Python:</p>
<p><a href="http://docs.python.org/library/urllib.html">urllib</a> - seems to me that I should use urllib2 instead. urllib has no cookie support, HTTP/FTP/local files only (no SSL)</p>... | 70 | 2010-03-05T10:02:48Z | 2,387,246 | <p>Urllib2 only supports HTTP GET and POST, there might be workarounds, but If your app depends on other HTTP verbs, you will probably prefer a different module.</p>
| 2 | 2010-03-05T14:10:29Z | [
"python",
"urllib2",
"mechanize",
"pycurl"
] |
Which is best in Python: urllib2, PycURL or mechanize? | 2,385,855 | <p>Ok so I need to download some web pages using Python and did a quick investigation of my options.</p>
<p>Included with Python:</p>
<p><a href="http://docs.python.org/library/urllib.html">urllib</a> - seems to me that I should use urllib2 instead. urllib has no cookie support, HTTP/FTP/local files only (no SSL)</p>... | 70 | 2010-03-05T10:02:48Z | 3,402,375 | <p>Every python library that speaks HTTP has its own advantages.</p>
<p>Use the one that has the minimum amount of features necessary for a particular task.</p>
<p>Your list is missing at least <a href="http://code.google.com/p/urllib3/" rel="nofollow">urllib3</a> - a cool third party HTTP library which can reuse a H... | 1 | 2010-08-04T03:27:06Z | [
"python",
"urllib2",
"mechanize",
"pycurl"
] |
Which is best in Python: urllib2, PycURL or mechanize? | 2,385,855 | <p>Ok so I need to download some web pages using Python and did a quick investigation of my options.</p>
<p>Included with Python:</p>
<p><a href="http://docs.python.org/library/urllib.html">urllib</a> - seems to me that I should use urllib2 instead. urllib has no cookie support, HTTP/FTP/local files only (no SSL)</p>... | 70 | 2010-03-05T10:02:48Z | 8,775,397 | <p>Python <a href="http://pypi.python.org/pypi/requests">requests</a> is also a good candidate for HTTP stuff. It has a nicer api IMHO, an example http request from their offcial documentation:</p>
<pre><code>>>> r = requests.get('https://api.github.com', auth=('user', 'pass'))
>>> r.status_code
204
... | 35 | 2012-01-08T04:32:34Z | [
"python",
"urllib2",
"mechanize",
"pycurl"
] |
Which is best in Python: urllib2, PycURL or mechanize? | 2,385,855 | <p>Ok so I need to download some web pages using Python and did a quick investigation of my options.</p>
<p>Included with Python:</p>
<p><a href="http://docs.python.org/library/urllib.html">urllib</a> - seems to me that I should use urllib2 instead. urllib has no cookie support, HTTP/FTP/local files only (no SSL)</p>... | 70 | 2010-03-05T10:02:48Z | 11,097,715 | <p>Take a look on Grab (http://grablib.org). It is a network library which provides two main interfaces:
1) Grab for creating network requests and parsing retrieved data
2) Spider for creating bulk site scrapers</p>
<p>Under the hood Grab uses pycurl and lxml but it is possible to use other network transports (for ex... | 1 | 2012-06-19T09:00:37Z | [
"python",
"urllib2",
"mechanize",
"pycurl"
] |
Which is best in Python: urllib2, PycURL or mechanize? | 2,385,855 | <p>Ok so I need to download some web pages using Python and did a quick investigation of my options.</p>
<p>Included with Python:</p>
<p><a href="http://docs.python.org/library/urllib.html">urllib</a> - seems to me that I should use urllib2 instead. urllib has no cookie support, HTTP/FTP/local files only (no SSL)</p>... | 70 | 2010-03-05T10:02:48Z | 14,419,832 | <p>To "get some webpages", use <em>requests</em>!</p>
<p>From <a href="http://docs.python-requests.org/en/latest/" rel="nofollow">http://docs.python-requests.org/en/latest/</a> :</p>
<blockquote>
<p>Pythonâs standard urllib2 module provides most of the HTTP
capabilities you need, but the API is thoroughly broke... | 3 | 2013-01-19T23:02:41Z | [
"python",
"urllib2",
"mechanize",
"pycurl"
] |
Counting Duplicates Integers in Python | 2,385,867 | <p>How do I find the total number of duplicates in a string?
i.e., if it was <code>j= [1,1,1,2,2,2]</code> it would find <code>4</code> duplicates?
I've only been able to find counting which shows how many times each individual number occurred.</p>
| 6 | 2010-03-05T10:04:39Z | 2,385,877 | <pre><code>>>> j= [1,1,1,2,2,2]
>>> len(j) - len(set(j))
4
</code></pre>
<p>and btw, <code>j</code> is a list and not a string, although for the purpose of this exercise it doesn't really matter.</p>
| 17 | 2010-03-05T10:05:58Z | [
"python",
"count",
"duplicates"
] |
Counting Duplicates Integers in Python | 2,385,867 | <p>How do I find the total number of duplicates in a string?
i.e., if it was <code>j= [1,1,1,2,2,2]</code> it would find <code>4</code> duplicates?
I've only been able to find counting which shows how many times each individual number occurred.</p>
| 6 | 2010-03-05T10:04:39Z | 2,386,056 | <p>There seems to be a popular answer already, but if you would like to maintain the individual duplicate counts as well, the new <code>Counter()</code> collection object in Python 2.7 is perfect for this.</p>
<pre><code>>>> from collections import Counter
>>> j = [1,1,1,2,2,2]
>>> Counter... | 7 | 2010-03-05T10:41:04Z | [
"python",
"count",
"duplicates"
] |
Why does the "name" parameter to __setattr__ include the class, but __getattr__ doesn't? | 2,386,418 | <p>The following code:</p>
<pre><code>class MyClass():
def test(self):
self.__x = 0
def __setattr__(self, name, value):
print name
def __getattr__(self, name):
print name
raise AttributeError(name)
x = MyClass()
x.test()
x.__y
</code></pre>
<p>Outputs:</p>
<pre><code>_M... | 2 | 2010-03-05T11:47:38Z | 2,386,437 | <p>The double underscore invokes name mangling. If you don't need name mangling, don't use double undescore</p>
<p><a href="http://stackoverflow.com/questions/1301346/the-meaning-of-a-single-and-a-double-underscore-before-an-object-name-in-python">http://stackoverflow.com/questions/1301346/the-meaning-of-a-single-and-... | 4 | 2010-03-05T11:52:46Z | [
"python",
"setattr",
"getattr"
] |
Why does the "name" parameter to __setattr__ include the class, but __getattr__ doesn't? | 2,386,418 | <p>The following code:</p>
<pre><code>class MyClass():
def test(self):
self.__x = 0
def __setattr__(self, name, value):
print name
def __getattr__(self, name):
print name
raise AttributeError(name)
x = MyClass()
x.test()
x.__y
</code></pre>
<p>Outputs:</p>
<pre><code>_M... | 2 | 2010-03-05T11:47:38Z | 2,386,451 | <p>I'm not sure exactly why this occurs, but if you use <code>_x</code> rather than <code>__x</code> it works as you would expect.</p>
| 1 | 2010-03-05T11:55:33Z | [
"python",
"setattr",
"getattr"
] |
how can I make a suggestion for a new feature in python | 2,386,421 | <p>Suppose I think I have a great idea for some feature that should be in python's standard library.
Not something of the magnitude of a new keyword etc, just a suggestion for another decorator that would help a lot, IMO.</p>
<p>How can I suggest such a feature to the consideration of the "python committee :)"? </p>
| 3 | 2010-03-05T11:48:38Z | 2,386,438 | <p>You can add your suggestion to the issue tracker <a href="http://bugs.python.org/" rel="nofollow">http://bugs.python.org/</a>. they usually implement things posted there.</p>
| 3 | 2010-03-05T11:52:52Z | [
"python",
"pep"
] |
how can I make a suggestion for a new feature in python | 2,386,421 | <p>Suppose I think I have a great idea for some feature that should be in python's standard library.
Not something of the magnitude of a new keyword etc, just a suggestion for another decorator that would help a lot, IMO.</p>
<p>How can I suggest such a feature to the consideration of the "python committee :)"? </p>
| 3 | 2010-03-05T11:48:38Z | 2,386,453 | <p>Either add it to the tracker, or join the developer mailing list and suggest it there. Better to do that if you feel you can contribute at least to developing the specification, if not the feature itself.</p>
| 0 | 2010-03-05T11:56:00Z | [
"python",
"pep"
] |
how can I make a suggestion for a new feature in python | 2,386,421 | <p>Suppose I think I have a great idea for some feature that should be in python's standard library.
Not something of the magnitude of a new keyword etc, just a suggestion for another decorator that would help a lot, IMO.</p>
<p>How can I suggest such a feature to the consideration of the "python committee :)"? </p>
| 3 | 2010-03-05T11:48:38Z | 2,386,461 | <p>An alternative to the issue tracker suggested by mpalcona: you can submit it for discussion on the <code>python-dev</code> mailing list.</p>
<p>And always, a reference implementation (something that works, even if not in all cases and not efficiently) is always welcomed.</p>
| 0 | 2010-03-05T11:56:26Z | [
"python",
"pep"
] |
how can I make a suggestion for a new feature in python | 2,386,421 | <p>Suppose I think I have a great idea for some feature that should be in python's standard library.
Not something of the magnitude of a new keyword etc, just a suggestion for another decorator that would help a lot, IMO.</p>
<p>How can I suggest such a feature to the consideration of the "python committee :)"? </p>
| 3 | 2010-03-05T11:48:38Z | 2,386,465 | <p>Perhaps post your idea on the <a href="http://www.python.org/community/lists/" rel="nofollow">Python mailing list</a></p>
| 1 | 2010-03-05T11:56:45Z | [
"python",
"pep"
] |
how can I make a suggestion for a new feature in python | 2,386,421 | <p>Suppose I think I have a great idea for some feature that should be in python's standard library.
Not something of the magnitude of a new keyword etc, just a suggestion for another decorator that would help a lot, IMO.</p>
<p>How can I suggest such a feature to the consideration of the "python committee :)"? </p>
| 3 | 2010-03-05T11:48:38Z | 2,386,470 | <p>Python is Open Source, which means that all of these processes are very open. It also means that you can have far more success if you can implement the suggestion and prove its merits yourself.</p>
<p>Normally you should establish that your proposal is a good way to solve the particular problem. This can be discuss... | 3 | 2010-03-05T11:57:43Z | [
"python",
"pep"
] |
how can I make a suggestion for a new feature in python | 2,386,421 | <p>Suppose I think I have a great idea for some feature that should be in python's standard library.
Not something of the magnitude of a new keyword etc, just a suggestion for another decorator that would help a lot, IMO.</p>
<p>How can I suggest such a feature to the consideration of the "python committee :)"? </p>
| 3 | 2010-03-05T11:48:38Z | 2,386,555 | <p>It really depends on the nature of the suggestion.</p>
<p>If it's a bug, it should definitely be put on the tracker. Otherwise, it probably should not go in the tracker right away. Python developers have specifically asked that the tracker not be used to create discussions, but to track implementation-specific aspe... | 6 | 2010-03-05T12:14:02Z | [
"python",
"pep"
] |
how can I make a suggestion for a new feature in python | 2,386,421 | <p>Suppose I think I have a great idea for some feature that should be in python's standard library.
Not something of the magnitude of a new keyword etc, just a suggestion for another decorator that would help a lot, IMO.</p>
<p>How can I suggest such a feature to the consideration of the "python committee :)"? </p>
| 3 | 2010-03-05T11:48:38Z | 2,387,822 | <p>Don't waste time "suggesting" things. Invest time <strong>doing</strong> things.</p>
<p>Simply do this.</p>
<ol>
<li><p>Build it.</p></li>
<li><p>Use it.</p></li>
<li><p>Post it to SourceForge.</p></li>
<li><p>Put a link to the SourceForge project on PyPi.</p></li>
</ol>
<p>Done.</p>
<p>If it's actually a "grea... | 0 | 2010-03-05T15:27:04Z | [
"python",
"pep"
] |
Creating a custom Django form field that uses two <input>s | 2,386,541 | <p>How can I make a Django field that renders itself as a pair of input
fields?</p>
<p>Reasoning: I am trying to write a new custom field. I will use it for a
captcha-like service. The service works by requesting a question -
then receiving one and a <em>token</em>. The validation happens by sending the
<em>answer</em... | 5 | 2010-03-05T12:11:24Z | 2,386,611 | <p>Have a look at the <a href="http://code.djangoproject.com/browser/django/trunk/django/forms/extras/widgets.py" rel="nofollow">SelectDateWidget</a>. It splits the input of a date into three select boxes.</p>
<p>And the doc string says:</p>
<blockquote>
<p>This also serves as an example of a Widget that has more t... | 2 | 2010-03-05T12:24:25Z | [
"python",
"django",
"django-forms"
] |
Creating a custom Django form field that uses two <input>s | 2,386,541 | <p>How can I make a Django field that renders itself as a pair of input
fields?</p>
<p>Reasoning: I am trying to write a new custom field. I will use it for a
captcha-like service. The service works by requesting a question -
then receiving one and a <em>token</em>. The validation happens by sending the
<em>answer</em... | 5 | 2010-03-05T12:11:24Z | 2,386,650 | <p>I think you're looking for the <a href="http://docs.djangoproject.com/en/dev/ref/forms/widgets/#django.forms.MultiWidget">MultiWidget</a>, you can simply give it 2 regular widgets and it will render the combination.</p>
| 9 | 2010-03-05T12:29:16Z | [
"python",
"django",
"django-forms"
] |
Creating a custom Django form field that uses two <input>s | 2,386,541 | <p>How can I make a Django field that renders itself as a pair of input
fields?</p>
<p>Reasoning: I am trying to write a new custom field. I will use it for a
captcha-like service. The service works by requesting a question -
then receiving one and a <em>token</em>. The validation happens by sending the
<em>answer</em... | 5 | 2010-03-05T12:11:24Z | 2,387,330 | <p>Here you have a ready example(taken from my blog):</p>
<pre><code>class ComplexMultiWidget(forms.MultiWidget):
def __init__(self, attrs=None):
widgets = (
forms.TextInput(),
forms.SelectMultiple(choices=(('J', 'John'),
('P', 'Paul'),
... | 4 | 2010-03-05T14:24:07Z | [
"python",
"django",
"django-forms"
] |
Why is "import *" bad? | 2,386,714 | <p>It is recommended to not to use <code>import *</code> in Python. </p>
<p>Can anyone please share the reason for that, so that I can avoid it doing next time?</p>
| 65 | 2010-03-05T12:40:41Z | 2,386,740 | <ul>
<li><p>Because it puts a lot of stuff into your namespace (might shadow some other object from previous import and you won't know about it). </p></li>
<li><p>Because you don't know exactly what is imported and can't find place from what module certain thing was imported easily (readability). </p></li>
<li><p>Becau... | 105 | 2010-03-05T12:43:42Z | [
"python",
"python-import"
] |
Why is "import *" bad? | 2,386,714 | <p>It is recommended to not to use <code>import *</code> in Python. </p>
<p>Can anyone please share the reason for that, so that I can avoid it doing next time?</p>
| 65 | 2010-03-05T12:40:41Z | 2,386,754 | <p><a href="http://docs.python.org/tutorial/modules.html">http://docs.python.org/tutorial/modules.html</a></p>
<blockquote>
<p>Note that in general the practice of importing <code>*</code> from a module or package is frowned upon, since it often causes <strong>poorly readable code</strong>. </p>
</blockquote>
| 9 | 2010-03-05T12:45:31Z | [
"python",
"python-import"
] |
Why is "import *" bad? | 2,386,714 | <p>It is recommended to not to use <code>import *</code> in Python. </p>
<p>Can anyone please share the reason for that, so that I can avoid it doing next time?</p>
| 65 | 2010-03-05T12:40:41Z | 2,386,759 | <p>That is because you are polluting the namespace. You will import all the functions and classes in your own namespace, which may clash with the functions you define yourself.</p>
<p>Furthermore, I think using a qualified name is more clear for the maintenance task; you see on the code line itself where a function co... | 14 | 2010-03-05T12:45:55Z | [
"python",
"python-import"
] |
Why is "import *" bad? | 2,386,714 | <p>It is recommended to not to use <code>import *</code> in Python. </p>
<p>Can anyone please share the reason for that, so that I can avoid it doing next time?</p>
| 65 | 2010-03-05T12:40:41Z | 2,386,926 | <p>It is OK to do <code>from ... import *</code> in an interactive session.</p>
| 8 | 2010-03-05T13:14:16Z | [
"python",
"python-import"
] |
Why is "import *" bad? | 2,386,714 | <p>It is recommended to not to use <code>import *</code> in Python. </p>
<p>Can anyone please share the reason for that, so that I can avoid it doing next time?</p>
| 65 | 2010-03-05T12:40:41Z | 2,386,943 | <p>According to the <a href="http://www.python.org/dev/peps/pep-0020/">Python Zen</a>:</p>
<blockquote>
<p>Explicit is better than implicit.</p>
</blockquote>
<p>... can't argue with that, surely?</p>
| 30 | 2010-03-05T13:17:04Z | [
"python",
"python-import"
] |
Why is "import *" bad? | 2,386,714 | <p>It is recommended to not to use <code>import *</code> in Python. </p>
<p>Can anyone please share the reason for that, so that I can avoid it doing next time?</p>
| 65 | 2010-03-05T12:40:41Z | 2,386,952 | <p>Say you have the following code in a module called foo:</p>
<pre><code>import ElementTree as etree
</code></pre>
<p>and then in your own module you have:</p>
<pre><code>from lxml import etree
from foo import *
</code></pre>
<p>You now have a difficult-to-debug module that <em>looks like</em> it has lxml's etree ... | 6 | 2010-03-05T13:18:20Z | [
"python",
"python-import"
] |
Why is "import *" bad? | 2,386,714 | <p>It is recommended to not to use <code>import *</code> in Python. </p>
<p>Can anyone please share the reason for that, so that I can avoid it doing next time?</p>
| 65 | 2010-03-05T12:40:41Z | 2,454,460 | <p>You don't pass <code>**locals()</code> to functions, do you?</p>
<p>Since Python lacks an "include" statement, <em>and</em> the <code>self</code> parameter is explicit, <em>and</em> scoping rules are quite simple, it's usually very easy to point a finger at a variable and tell where that object comes from -- withou... | 19 | 2010-03-16T12:59:33Z | [
"python",
"python-import"
] |
Why is "import *" bad? | 2,386,714 | <p>It is recommended to not to use <code>import *</code> in Python. </p>
<p>Can anyone please share the reason for that, so that I can avoid it doing next time?</p>
| 65 | 2010-03-05T12:40:41Z | 34,478,530 | <p>These are all good answers. I'm going to add that when teaching new people to code in Python, dealing with <code>import *</code> is very difficult. Even if you or they didn't write the code, it's still a stumbling block.</p>
<p>I teach children (about 8 years old) to program in Python to manipulate Minecraft. I lik... | 2 | 2015-12-27T07:38:22Z | [
"python",
"python-import"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.