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 |
|---|---|---|---|---|---|---|---|---|---|
method of iterating over sqlalchemy model's defined columns? | 2,537,471 | <p>I've been trying to figure out how to iterate over the list of columns defined in a SqlAlchemy model. I want it for writing some serialization and copy methods to a couple of models. I can't just iterate over the obj.<strong>dict</strong> since it contains a lot of SA specific items. </p>
<p>Anyone know of a way to... | 55 | 2010-03-29T11:27:43Z | 33,394,575 | <p>I know this is an old question, but what about:</p>
<pre><code>class JobStatus(Base):
...
def columns(self):
return [col for col in dir(self) if isinstance(col, db.Column)]
</code></pre>
<p>Then, to get column names: <code>jobStatus.columns()</code></p>
<p>That would return <code>['id', 'desc']<... | 0 | 2015-10-28T15:03:27Z | [
"python",
"sqlalchemy"
] |
OpenType programming | 2,537,485 | <p>Hi all<br>
Recently i asked two questions (<a href="http://stackoverflow.com/questions/2519564/how-to-write-programs-using-advanced-opentype-features">1</a> and <a href="http://stackoverflow.com/questions/2492508/opentype-with-python">2</a>) about using OpenType features in programs written by python and .net langua... | 1 | 2010-03-29T11:30:05Z | 2,537,509 | <p><strong>Pango+Cairo does what you want</strong></p>
<p>You might want to check out <a href="http://www.pango.org/" rel="nofollow">Pango</a> which is a text layout and rendering engine which can handle OpenType ... see <a href="http://mces.blogspot.com/2007/05/advanced-opentype-features-in-pango.html" rel="nofollow"... | 1 | 2010-03-29T11:34:19Z | [
".net",
"python",
"opentype"
] |
OpenType programming | 2,537,485 | <p>Hi all<br>
Recently i asked two questions (<a href="http://stackoverflow.com/questions/2519564/how-to-write-programs-using-advanced-opentype-features">1</a> and <a href="http://stackoverflow.com/questions/2492508/opentype-with-python">2</a>) about using OpenType features in programs written by python and .net langua... | 1 | 2010-03-29T11:30:05Z | 23,448,045 | <p>What do you want do at last?</p>
<p>Just rendering some text but NOT with simple Windows provided API? Have a look at <a href="http://marc.info/?l=cairo&m=121692252128947" rel="nofollow">this</a>.</p>
<p>Configuring fonts OpenType features on rendering for a simple text (same script and language)? Try to imple... | 1 | 2014-05-03T18:02:36Z | [
".net",
"python",
"opentype"
] |
Uploading multiple files with size restriction in Javascript | 2,537,618 | <p>Can anybody tell me how i can upload multiple files with size restriction in javascript.</p>
| 1 | 2010-03-29T11:56:40Z | 2,537,629 | <p>You can't. </p>
<p>You would need to use an alternative, e.g. a Flash-based uploader like <a href="http://www.swfupload.org" rel="nofollow">SWFUpload</a>.</p>
| 4 | 2010-03-29T11:58:12Z | [
"javascript",
"python"
] |
Uploading multiple files with size restriction in Javascript | 2,537,618 | <p>Can anybody tell me how i can upload multiple files with size restriction in javascript.</p>
| 1 | 2010-03-29T11:56:40Z | 2,537,675 | <p>Multiple files you can do, via multiple <code><input type="file"></code> elements. HTML5 (at least) also provides the <a href="http://www.w3.org/TR/html5/forms.html#file-upload-state" rel="nofollow"><code>multiple</code></a> attribute for a single <code><input type="file"></code> element, which is suppor... | 2 | 2010-03-29T12:07:27Z | [
"javascript",
"python"
] |
Using urllib2 with SOCKS proxy | 2,537,726 | <p>Is it possible to fetch pages with urllib2 through a SOCKS proxy on a one socks server per opener basic? I've seen the solution using setdefaultproxy method, but I need to have different socks in different openers.</p>
<p>So there is SocksiPy library, which works great, but it has to be used this way:</p>
<pre><co... | 13 | 2010-03-29T12:17:38Z | 2,538,530 | <p><strong>== EDIT == (old HTTP-Proxy example was here..)</strong></p>
<p>My fault.. urllib2 has no builtin support for SOCKS proxying.. </p>
<p>There are some '<em>hacks</em>' adding SOCKS to urllib2 (or the socket object in general) <a href="http://bytes.com/topic/python/answers/478365-i-wanna-use-urllib2-get-page-... | 0 | 2010-03-29T14:16:24Z | [
"python",
"urllib2",
"socks"
] |
Using urllib2 with SOCKS proxy | 2,537,726 | <p>Is it possible to fetch pages with urllib2 through a SOCKS proxy on a one socks server per opener basic? I've seen the solution using setdefaultproxy method, but I need to have different socks in different openers.</p>
<p>So there is SocksiPy library, which works great, but it has to be used this way:</p>
<pre><co... | 13 | 2010-03-29T12:17:38Z | 2,561,966 | <p>You have only one socket for all openers and implementing socks is in socket level. So, you can't.<br>
I suggest you to use pycurl library, it much more flexible.</p>
| 0 | 2010-04-01T16:31:08Z | [
"python",
"urllib2",
"socks"
] |
Using urllib2 with SOCKS proxy | 2,537,726 | <p>Is it possible to fetch pages with urllib2 through a SOCKS proxy on a one socks server per opener basic? I've seen the solution using setdefaultproxy method, but I need to have different socks in different openers.</p>
<p>So there is SocksiPy library, which works great, but it has to be used this way:</p>
<pre><co... | 13 | 2010-03-29T12:17:38Z | 2,570,384 | <p>Try with <a href="http://pycurl.sourceforge.net/">pycurl</a>:</p>
<pre><code>import pycurl
c1 = pycurl.Curl()
c1.setopt(pycurl.URL, 'http://www.google.com')
c1.setopt(pycurl.PROXY, 'localhost')
c1.setopt(pycurl.PROXYPORT, 8080)
c1.setopt(pycurl.PROXYTYPE, pycurl.PROXYTYPE_SOCKS5)
c2 = pycurl.Curl()
c2.setopt(pycur... | 15 | 2010-04-03T05:54:34Z | [
"python",
"urllib2",
"socks"
] |
Using urllib2 with SOCKS proxy | 2,537,726 | <p>Is it possible to fetch pages with urllib2 through a SOCKS proxy on a one socks server per opener basic? I've seen the solution using setdefaultproxy method, but I need to have different socks in different openers.</p>
<p>So there is SocksiPy library, which works great, but it has to be used this way:</p>
<pre><co... | 13 | 2010-03-29T12:17:38Z | 2,586,244 | <p>You might be able to use threading locks if there aren't too many connections being made at once, and you need to access from multiple threads:</p>
<pre><code>import socks
import socket
import thread
lock = thread.allocate_lock()
socket.socket = socks.socksocket
def GetConn():
lock.acquire()
import urllib2... | 0 | 2010-04-06T15:52:45Z | [
"python",
"urllib2",
"socks"
] |
Using urllib2 with SOCKS proxy | 2,537,726 | <p>Is it possible to fetch pages with urllib2 through a SOCKS proxy on a one socks server per opener basic? I've seen the solution using setdefaultproxy method, but I need to have different socks in different openers.</p>
<p>So there is SocksiPy library, which works great, but it has to be used this way:</p>
<pre><co... | 13 | 2010-03-29T12:17:38Z | 2,875,064 | <p>You could do you it by setting evironmental variable HTTP_PROXY in following format:</p>
<p>user:pass@proxy:port</p>
<p>or if you use bat/cmd, add before calling script:</p>
<p>set HTTP_PROXY=user:pass@proxy:port</p>
<p>I am using such cmd-file to make easy_install work under proxy.</p>
| -3 | 2010-05-20T15:10:21Z | [
"python",
"urllib2",
"socks"
] |
Using urllib2 with SOCKS proxy | 2,537,726 | <p>Is it possible to fetch pages with urllib2 through a SOCKS proxy on a one socks server per opener basic? I've seen the solution using setdefaultproxy method, but I need to have different socks in different openers.</p>
<p>So there is SocksiPy library, which works great, but it has to be used this way:</p>
<pre><co... | 13 | 2010-03-29T12:17:38Z | 4,647,583 | <p>A cumbersome but working solution for using a SOCKS proxy is to set up provixy with proxy chaining and then set the HTTP_PROXY provided by privoxy via system variable or any other way.</p>
| 0 | 2011-01-10T14:03:59Z | [
"python",
"urllib2",
"socks"
] |
Using urllib2 with SOCKS proxy | 2,537,726 | <p>Is it possible to fetch pages with urllib2 through a SOCKS proxy on a one socks server per opener basic? I've seen the solution using setdefaultproxy method, but I need to have different socks in different openers.</p>
<p>So there is SocksiPy library, which works great, but it has to be used this way:</p>
<pre><co... | 13 | 2010-03-29T12:17:38Z | 8,478,479 | <p>Yes, you can. I repeat my answer on <a href="http://stackoverflow.com/a/8100870/88231">How can I use a SOCKS 4/5 proxy with urllib2?</a>
You need to create an opener for every proxy like you do with an http proxy. The code for adding this feature to SocksiPy is available in GitHub <a href="https://gist.github.com/86... | 10 | 2011-12-12T17:43:59Z | [
"python",
"urllib2",
"socks"
] |
Sans-serif math with latex in matplotlib | 2,537,868 | <p>The following script:</p>
<pre><code>import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as mpl
mpl.rc('font', family='sans-serif')
mpl.rc('text', usetex=True)
fig = mpl.figure()
ax = fig.add_subplot(1,1,1)
ax.text(0.2,0.5,r"Math font: $451^\circ$")
ax.text(0.2,0.7,r"Normal font (except for degree sy... | 12 | 2010-03-29T12:39:38Z | 16,501,185 | <p>You may want to check out <a href="https://github.com/nschloe/matplotlib2tikz" rel="nofollow">https://github.com/nschloe/matplotlib2tikz</a>. Also, matplotlib was recently equipped with a TikZ/PGF backend, cf. <a href="https://github.com/matplotlib/matplotlib/issues/319" rel="nofollow">https://github.com/matplotlib/... | 1 | 2013-05-11T19:55:51Z | [
"python",
"latex",
"matplotlib"
] |
Sans-serif math with latex in matplotlib | 2,537,868 | <p>The following script:</p>
<pre><code>import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as mpl
mpl.rc('font', family='sans-serif')
mpl.rc('text', usetex=True)
fig = mpl.figure()
ax = fig.add_subplot(1,1,1)
ax.text(0.2,0.5,r"Math font: $451^\circ$")
ax.text(0.2,0.7,r"Normal font (except for degree sy... | 12 | 2010-03-29T12:39:38Z | 20,709,149 | <p>I always have <code>text.usetex = True</code> in my matplotlibrc file. In addition to that, I use this as well:</p>
<pre><code>mpl.rcParams['text.latex.preamble'] = [
r'\usepackage{siunitx}', # i need upright \micro symbols, but you need...
r'\sisetup{detect-all}', # ...this to force siunitx to ac... | 15 | 2013-12-20T17:43:00Z | [
"python",
"latex",
"matplotlib"
] |
Sans-serif math with latex in matplotlib | 2,537,868 | <p>The following script:</p>
<pre><code>import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as mpl
mpl.rc('font', family='sans-serif')
mpl.rc('text', usetex=True)
fig = mpl.figure()
ax = fig.add_subplot(1,1,1)
ax.text(0.2,0.5,r"Math font: $451^\circ$")
ax.text(0.2,0.7,r"Normal font (except for degree sy... | 12 | 2010-03-29T12:39:38Z | 20,791,035 | <p>The easiest way is to use matplotlib's internal TeX, e.g.:</p>
<pre><code>import pylab as plt
params = {'text.usetex': False, 'mathtext.fontset': 'stixsans'}
plt.rcParams.update(params)
</code></pre>
<p>If you use an external LaTeX, you can use, e.g., CM Bright fonts:</p>
<pre><code>params = {'text.usetex': True,... | 7 | 2013-12-26T20:47:27Z | [
"python",
"latex",
"matplotlib"
] |
Sans-serif math with latex in matplotlib | 2,537,868 | <p>The following script:</p>
<pre><code>import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as mpl
mpl.rc('font', family='sans-serif')
mpl.rc('text', usetex=True)
fig = mpl.figure()
ax = fig.add_subplot(1,1,1)
ax.text(0.2,0.5,r"Math font: $451^\circ$")
ax.text(0.2,0.7,r"Normal font (except for degree sy... | 12 | 2010-03-29T12:39:38Z | 29,013,129 | <p>This will enable you to use the Computer Modern Sans font if you, as I, prefer it over Helvetica:</p>
<pre><code>mpl.rcParams['text.usetex'] = True
mpl.rcParams['text.latex.preamble'] = [r'\usepackage[cm]{sfmath}']
mpl.rcParams['font.family'] = 'sans-serif'
mpl.rcParams['font.sans-serif'] = 'cm'
</code></pre>
| 0 | 2015-03-12T14:57:19Z | [
"python",
"latex",
"matplotlib"
] |
Regex to match the first file in a rar archive file set in Python | 2,537,882 | <p>I need to uncompress all the files in a directory and for this I need to find the first file in the set. I'm currently doing this using a bunch of if statements and loops. Can i do this this using regex? </p>
<p>Here's a list of files that i need to match:</p>
<pre><code>yes.rar
yes.part1.rar
yes.part01.rar
yes.pa... | 2 | 2010-03-29T12:41:18Z | 2,537,935 | <p>There's no need to use look behind assertions for this. Since you start looking from the beginning of the string, you can do everything with look-aheads that you can with look-behinds. This should work:</p>
<pre><code>^((?!\.part(?!0*1\.rar$)\d+\.rar$).)*\.(?:rar|r?0*1)$
</code></pre>
<p>To capture the first part ... | 2 | 2010-03-29T12:50:20Z | [
"python",
"regex"
] |
Regex to match the first file in a rar archive file set in Python | 2,537,882 | <p>I need to uncompress all the files in a directory and for this I need to find the first file in the set. I'm currently doing this using a bunch of if statements and loops. Can i do this this using regex? </p>
<p>Here's a list of files that i need to match:</p>
<pre><code>yes.rar
yes.part1.rar
yes.part01.rar
yes.pa... | 2 | 2010-03-29T12:41:18Z | 2,538,034 | <p>Don't rely on the names of the files to determine which one is first. You're going to end up finding an edge case where you get the wrong file.</p>
<p><a href="http://www.win-rar.com/index.php?id=24&kb_article_id=162" rel="nofollow">RAR's headers</a> will tell you which file is the first on in the volume, assum... | 5 | 2010-03-29T13:05:24Z | [
"python",
"regex"
] |
Regex to match the first file in a rar archive file set in Python | 2,537,882 | <p>I need to uncompress all the files in a directory and for this I need to find the first file in the set. I'm currently doing this using a bunch of if statements and loops. Can i do this this using regex? </p>
<p>Here's a list of files that i need to match:</p>
<pre><code>yes.rar
yes.part1.rar
yes.part01.rar
yes.pa... | 2 | 2010-03-29T12:41:18Z | 5,266,085 | <p>Are you sure you want to match these cases?</p>
<blockquote>
<p>yes.r01</p>
</blockquote>
<p>They are not the first archives: .rar always is.</p>
<p>It's bla.rar, bla.r00 and then only bla.r01. You'll probably extract the files twice if you match .r01 and .rar as first archive.</p>
<blockquote>
<p>yes.r001</... | 0 | 2011-03-10T21:22:35Z | [
"python",
"regex"
] |
Is it possible to temporarily disable Python's string interpolation? | 2,537,929 | <p>I have a python logger set up, using python's logging module. I want to store the string I'm using with the logging Formatter object in a configuration file using the ConfigParser module.</p>
<p>The format string is stored in a dictionary of settings in a separate file that handles the reading and writing of the c... | 5 | 2010-03-29T12:49:28Z | 2,537,969 | <p>Did you try to escape percents with <code>%%</code>?</p>
| 7 | 2010-03-29T12:55:38Z | [
"python",
"string-interpolation"
] |
Is it possible to temporarily disable Python's string interpolation? | 2,537,929 | <p>I have a python logger set up, using python's logging module. I want to store the string I'm using with the logging Formatter object in a configuration file using the ConfigParser module.</p>
<p>The format string is stored in a dictionary of settings in a separate file that handles the reading and writing of the c... | 5 | 2010-03-29T12:49:28Z | 2,538,009 | <p>What is the problem with the code above? Interpolation is only performed if the <code>%</code> operator is applied to the string. If you don't use <code>%</code> you can use the formatting string like any other string.</p>
| 1 | 2010-03-29T13:02:47Z | [
"python",
"string-interpolation"
] |
Is it possible to temporarily disable Python's string interpolation? | 2,537,929 | <p>I have a python logger set up, using python's logging module. I want to store the string I'm using with the logging Formatter object in a configuration file using the ConfigParser module.</p>
<p>The format string is stored in a dictionary of settings in a separate file that handles the reading and writing of the c... | 5 | 2010-03-29T12:49:28Z | 2,538,141 | <p>You might wanna use <code>ConfigParser.RawConfigParser</code> instead of <code>ConfigParser.ConfigParser</code>. Only the latter does magical interpolation on config values.</p>
<p><strong>EDIT:</strong></p>
<p>Actually, using <code>ConfigParser.SafeConfigParser</code> you'll able to escape format strings with an ... | 8 | 2010-03-29T13:21:17Z | [
"python",
"string-interpolation"
] |
Is it possible to temporarily disable Python's string interpolation? | 2,537,929 | <p>I have a python logger set up, using python's logging module. I want to store the string I'm using with the logging Formatter object in a configuration file using the ConfigParser module.</p>
<p>The format string is stored in a dictionary of settings in a separate file that handles the reading and writing of the c... | 5 | 2010-03-29T12:49:28Z | 2,538,144 | <p>There's <code>RawConfigParser</code> which is like <code>ConfigParser</code> without the interpolation behaviour. If you don't use the interpolation feature in any other part of the configuration file, you can simply replace <code>ConfigParser</code> with <code>RawConfigParser</code> in your code.</p>
<p>See the do... | 4 | 2010-03-29T13:21:33Z | [
"python",
"string-interpolation"
] |
Is it possible to temporarily disable Python's string interpolation? | 2,537,929 | <p>I have a python logger set up, using python's logging module. I want to store the string I'm using with the logging Formatter object in a configuration file using the ConfigParser module.</p>
<p>The format string is stored in a dictionary of settings in a separate file that handles the reading and writing of the c... | 5 | 2010-03-29T12:49:28Z | 2,538,529 | <p>What version of Python are you using? An upgrade to 2.6.4 may help, see</p>
<p><a href="http://bugs.python.org/issue5741" rel="nofollow">http://bugs.python.org/issue5741</a></p>
| 1 | 2010-03-29T14:16:17Z | [
"python",
"string-interpolation"
] |
django: grouping in an order_by query? | 2,538,096 | <p>I want to allocate rankings to users, based on a points field. </p>
<p>Easy enough you'd think with an <code>order_by</code> query. But how do I deal with the situation where two users have the same number of points and need to share the same ranking? Should I use <code>annotate</code> to find users with the same n... | 0 | 2010-03-29T13:14:48Z | 2,538,186 | <p>Quick & untested code, hopefully you get the idea:</p>
<pre><code>top_users = User.objects.filter(...)
prizes = ['First prize', 'Second', 'Third', ...]
prize = 0
previous_points = None
try:
for user in top_users:
if user.points_total < previous_points:
# always skipped in first iterat... | 0 | 2010-03-29T13:28:54Z | [
"python",
"django"
] |
django: grouping in an order_by query? | 2,538,096 | <p>I want to allocate rankings to users, based on a points field. </p>
<p>Easy enough you'd think with an <code>order_by</code> query. But how do I deal with the situation where two users have the same number of points and need to share the same ranking? Should I use <code>annotate</code> to find users with the same n... | 0 | 2010-03-29T13:14:48Z | 2,539,452 | <p>I'd just use <code>itertools.groupby</code>. Something like:</p>
<pre><code>top_users = [(k, list(g)) for k,g in groupby(top_users, key=lambda x: x.score))]
for u in top_users[0][1]:
u.status = 'First prize'
for u in top_users[1][1]:
u.status = 'Second prize'
for u in top_users[2][1]:
u.status = 'Third... | 1 | 2010-03-29T16:11:08Z | [
"python",
"django"
] |
Sunrise / set calculations | 2,538,190 | <p>I'm trying to calculate the sunset / rise times using python based on the link provided below.</p>
<p>My results done through excel and python do not match the real values. Any ideas on what I could be doing wrong?</p>
<p>My Excel sheet can be found under .. <a href="http://transpotools.com/sun_time.xls">http://tr... | 5 | 2010-03-29T13:29:45Z | 2,538,264 | <p>I suspect this has something to do with not actually performing floating point division. In python if a and b are both integers, a / b is also an integer:</p>
<pre><code> $ python
>>> 1 / 2
0
</code></pre>
<p>Your options are either to coerce to float one of your arguments (that is, instead of a/b... | 1 | 2010-03-29T13:41:34Z | [
"python",
"math",
"astronomy"
] |
Sunrise / set calculations | 2,538,190 | <p>I'm trying to calculate the sunset / rise times using python based on the link provided below.</p>
<p>My results done through excel and python do not match the real values. Any ideas on what I could be doing wrong?</p>
<p>My Excel sheet can be found under .. <a href="http://transpotools.com/sun_time.xls">http://tr... | 5 | 2010-03-29T13:29:45Z | 2,538,657 | <p>Why all the calls to <code>radians</code> and <code>degrees</code>? I thought the input data was already in decimal degrees.</p>
<p>I get a result of 7:37am if I:</p>
<ul>
<li>strip out all of the calls to radians and degrees</li>
<li>correct the lat / long to: <code>45.9</code> and <code>-66.6</code> respectively... | 3 | 2010-03-29T14:29:31Z | [
"python",
"math",
"astronomy"
] |
Sunrise / set calculations | 2,538,190 | <p>I'm trying to calculate the sunset / rise times using python based on the link provided below.</p>
<p>My results done through excel and python do not match the real values. Any ideas on what I could be doing wrong?</p>
<p>My Excel sheet can be found under .. <a href="http://transpotools.com/sun_time.xls">http://tr... | 5 | 2010-03-29T13:29:45Z | 2,539,597 | <p>You could use <a href="http://pypi.python.org/pypi/pyephem/"><code>ephem</code></a> python module:</p>
<pre><code>#!/usr/bin/env python
import datetime
import ephem # to install, type$ pip install pyephem
def calculate_time(d, m, y, lat, long, is_rise, utc_time):
o = ephem.Observer()
o.lat, o.long, o.date ... | 10 | 2010-03-29T16:31:20Z | [
"python",
"math",
"astronomy"
] |
Changes to multiple entities within a single transaction | 2,538,194 | <p>I am trying to make changes to multiple entities within a single transaction in app engine platform. As I understand in order to succeed doing so, App Engine needs to know in advance which entities will be updated together, so it knows to store them in a way that supports transactions. And therefore, user must decla... | 1 | 2010-03-29T13:30:33Z | 2,538,268 | <p>Using <a href="http://code.google.com/intl/pl-PL/appengine/docs/python/datastore/modelclass.html#Model" rel="nofollow">parent</a> argument to model constructor</p>
| 2 | 2010-03-29T13:42:07Z | [
"python"
] |
Changes to multiple entities within a single transaction | 2,538,194 | <p>I am trying to make changes to multiple entities within a single transaction in app engine platform. As I understand in order to succeed doing so, App Engine needs to know in advance which entities will be updated together, so it knows to store them in a way that supports transactions. And therefore, user must decla... | 1 | 2010-03-29T13:30:33Z | 5,140,283 | <p>Just take obj of first class as a parent parameter in second class constructor...</p>
<p>like</p>
<pre><code>class GroupA(db.Model):
counterA = db.IntegerProperty()
class ExampleA(db.Model):
exampleA = db.IntegerProperty()
def increment_counterA():
obj = GroupA()
obj.counterA = '89'
obj.put(... | 0 | 2011-02-28T09:40:26Z | [
"python"
] |
How can I format strings to query with mysqldb in Python? | 2,538,311 | <p>How do I do this correctly:</p>
<p>I want to do a query like this:</p>
<p><pre><code>query = """SELECT * FROM sometable
order by %s %s
limit %s, %s;"""
conn = app_globals.pool.connection()
cur = conn.cursor()
cur.execute(query, (sortname, sortorder, limit1, limit2) )
resu... | 6 | 2010-03-29T13:47:50Z | 2,538,362 | <blockquote>
<p><a href="http://mysql-python.sourceforge.net/MySQLdb.html#functions-and-attributes">paramstyle<br>
Parameter placeholders can <strong>only</strong> be used to insert column values. They can <strong>not</strong> be used for other parts of SQL, such as table names, statements, etc.</a></p>
</blockquo... | 8 | 2010-03-29T13:55:11Z | [
"python",
"string",
"mysql"
] |
How can I format strings to query with mysqldb in Python? | 2,538,311 | <p>How do I do this correctly:</p>
<p>I want to do a query like this:</p>
<p><pre><code>query = """SELECT * FROM sometable
order by %s %s
limit %s, %s;"""
conn = app_globals.pool.connection()
cur = conn.cursor()
cur.execute(query, (sortname, sortorder, limit1, limit2) )
resu... | 6 | 2010-03-29T13:47:50Z | 2,538,386 | <p>Not all parts of an SQL query can be parametrized. The DESC keyword for example is not
a parameter. Try </p>
<pre><code>query = """SELECT * FROM sometable
order by %s """ + sortorder + """
limit %s, %s"""
cur.execute(query, (sortname, limit1, limit2) )
</code></pre>
| 0 | 2010-03-29T13:57:20Z | [
"python",
"string",
"mysql"
] |
How can I format strings to query with mysqldb in Python? | 2,538,311 | <p>How do I do this correctly:</p>
<p>I want to do a query like this:</p>
<p><pre><code>query = """SELECT * FROM sometable
order by %s %s
limit %s, %s;"""
conn = app_globals.pool.connection()
cur = conn.cursor()
cur.execute(query, (sortname, sortorder, limit1, limit2) )
resu... | 6 | 2010-03-29T13:47:50Z | 2,538,388 | <p>You could try this alternatively...</p>
<pre><code>query = """SELECT * FROM sometable
order by {0} {1}
limit {2}, {3};"""
sortname = 'somecol'
sortorder = 'DESC'
limit1 = 'limit1'
limit2 = 'limit2'
print(query.format(sortname, sortorder, limit1, limit2))
</code></pre>
| -1 | 2010-03-29T13:57:28Z | [
"python",
"string",
"mysql"
] |
How can I format strings to query with mysqldb in Python? | 2,538,311 | <p>How do I do this correctly:</p>
<p>I want to do a query like this:</p>
<p><pre><code>query = """SELECT * FROM sometable
order by %s %s
limit %s, %s;"""
conn = app_globals.pool.connection()
cur = conn.cursor()
cur.execute(query, (sortname, sortorder, limit1, limit2) )
resu... | 6 | 2010-03-29T13:47:50Z | 2,538,414 | <p>%s placeholders inside query string are reserved for parameters. %s in 'order by %s %s' are not parameters. You should make query string in 2 steps:</p>
<pre><code>query = """SELECT * FROM sometable order by %s %s limit %%s, %%s;"""
query = query % ('somecol', 'DESC')
conn = app_globals.pool.connection()
cur = conn... | 5 | 2010-03-29T14:00:59Z | [
"python",
"string",
"mysql"
] |
virtualenv does not copy standard modules like shutil and urllib2 | 2,538,523 | <p>When I create a new virtualenv, <code>virtualenv .virtualenvs/my_env</code>, there is only a subset of the standard python modules copied/linked to the new virtualenv.</p>
<p>For example, when I do <code>ls -l</code> in .virtualenvs/my_env/lib/python2.6, I see:</p>
<pre><code>...
... os.py -> /usr/lib/python2.6... | 2 | 2010-03-29T14:15:33Z | 2,538,901 | <p>virtualenv munges <code>sys.path</code> to insert your virtual environment <em>in front</em> of the system libraries, but the system libraries are still on the path, so they should still be accessible.</p>
<p>So, for instance, do:</p>
<pre><code>>>> import os
>>> os
<module 'posixpath' from '/... | 6 | 2010-03-29T14:59:48Z | [
"python",
"virtualenv"
] |
Rearranging a sequence | 2,538,538 | <p>I'm have trouble rearranging sequences so the amount of letters in the given original sequence are the same in the random generated sequences. For example:</p>
<p>If i have a string 'AAAC'
I need that string rearranged randomly so the amount of A's and C's are the same.</p>
| 0 | 2010-03-29T14:16:58Z | 2,538,569 | <pre><code>import random
chars = list("AAAC")
random.shuffle(chars)
return ''.join(chars)
</code></pre>
| 6 | 2010-03-29T14:20:33Z | [
"python",
"random"
] |
Python - compare nested lists and append matches to new list? | 2,538,708 | <p>I wish to compare to nested lists of unequal length. I am interested only in a match between the first element of each sub list. Should a match exist, I wish to add the match to another list for subsequent transformation into a tab delimited file. Here is an example of what I am working with:</p>
<pre><code>x = [['... | 3 | 2010-03-29T14:36:17Z | 2,538,751 | <pre><code>if i[1] == j[1]
</code></pre>
<p>checks whether the <em>second</em> elements of the arrays are identical. You want <code>if i[0] == j[0]</code>.</p>
<p>Otherwise, I find your code quite readable and wouldn't necessarily change it.</p>
| 1 | 2010-03-29T14:41:05Z | [
"python",
"list",
"compare"
] |
Python - compare nested lists and append matches to new list? | 2,538,708 | <p>I wish to compare to nested lists of unequal length. I am interested only in a match between the first element of each sub list. Should a match exist, I wish to add the match to another list for subsequent transformation into a tab delimited file. Here is an example of what I am working with:</p>
<pre><code>x = [['... | 3 | 2010-03-29T14:36:17Z | 2,538,754 | <p>I don't know if I interpret your question correctly, but given your example it seems that you might be using a wrong index:</p>
<p>change</p>
<pre><code>if i[1] == j[1]:
</code></pre>
<p>into</p>
<pre><code>if i[0] == j[0]:
</code></pre>
| 2 | 2010-03-29T14:41:59Z | [
"python",
"list",
"compare"
] |
Python - compare nested lists and append matches to new list? | 2,538,708 | <p>I wish to compare to nested lists of unequal length. I am interested only in a match between the first element of each sub list. Should a match exist, I wish to add the match to another list for subsequent transformation into a tab delimited file. Here is an example of what I am working with:</p>
<pre><code>x = [['... | 3 | 2010-03-29T14:36:17Z | 2,538,759 | <p>A simplier expression should work here too:</p>
<pre><code>list_of_lists = filter(lambda l: l[0][0] == l[1][0], zip(x, y))
map(lambda l: l[1], list_of_lists)
</code></pre>
| 0 | 2010-03-29T14:42:25Z | [
"python",
"list",
"compare"
] |
Python - compare nested lists and append matches to new list? | 2,538,708 | <p>I wish to compare to nested lists of unequal length. I am interested only in a match between the first element of each sub list. Should a match exist, I wish to add the match to another list for subsequent transformation into a tab delimited file. Here is an example of what I am working with:</p>
<pre><code>x = [['... | 3 | 2010-03-29T14:36:17Z | 2,538,760 | <p>You can do this a lot more simply by using sets.</p>
<pre><code>set_x = set([i[0] for i in x])
set_y = set([i[0] for i in y])
matches = list(set_x & set_y)
</code></pre>
| 1 | 2010-03-29T14:42:37Z | [
"python",
"list",
"compare"
] |
Python - compare nested lists and append matches to new list? | 2,538,708 | <p>I wish to compare to nested lists of unequal length. I am interested only in a match between the first element of each sub list. Should a match exist, I wish to add the match to another list for subsequent transformation into a tab delimited file. Here is an example of what I am working with:</p>
<pre><code>x = [['... | 3 | 2010-03-29T14:36:17Z | 2,541,596 | <ul>
<li><p>Use sets to obtain collections with no duplicates. </p>
<ul>
<li>You'll have to use tuples instead of lists as the items because set items must be hashable.</li>
</ul></li>
<li><p>The code you posted doesn't seem to generate the output you posted. I do not have any idea how you are supposed to generate tha... | 5 | 2010-03-29T22:05:40Z | [
"python",
"list",
"compare"
] |
Django says the "id may not be NULL" but why is it? | 2,538,771 | <p>I'm going crazy today. I just tried to insert a new record and it threw back a "post_blogpost.id may not be NULL" error. Here's my model:</p>
<pre><code>class BlogPost(models.Model):
title = models.CharField(max_length=100)
slug = models.SlugField(max_length=100)
who = models.ForeignKey(User, d... | 3 | 2010-03-29T14:43:55Z | 2,538,805 | <p>The only thing I can think of is that the table schema has become desynchronized from the model in that someone removed the <code>AUTOINCREMENT</code> attribute from the PK of the table.</p>
| 6 | 2010-03-29T14:47:08Z | [
"python",
"django",
"django-models"
] |
Django says the "id may not be NULL" but why is it? | 2,538,771 | <p>I'm going crazy today. I just tried to insert a new record and it threw back a "post_blogpost.id may not be NULL" error. Here's my model:</p>
<pre><code>class BlogPost(models.Model):
title = models.CharField(max_length=100)
slug = models.SlugField(max_length=100)
who = models.ForeignKey(User, d... | 3 | 2010-03-29T14:43:55Z | 2,538,911 | <p>I've also experienced odd editing results in the admin. Usually they were related to foreign keys. When the edit page has a bunch of empty model instances on one page so that you can easily create new ones by filling them out, sometimes I managed to do something wrong such that an attempt would be made to save the e... | 1 | 2010-03-29T15:01:08Z | [
"python",
"django",
"django-models"
] |
python: image to 2-dimensional list | 2,539,002 | <p>Is there a python lib that could make a 2-dimensional list of (R,G,B) data out of an image file?</p>
| 2 | 2010-03-29T15:11:58Z | 2,539,014 | <p>You might want to take a look at the <a href="http://www.pythonware.com/library/pil/handbook/image.htm" rel="nofollow">Python Imaging Library</a>. It has the ability to be directly converted to a 2 by 2 by 3 <a href="http://docs.scipy.org/doc/numpy/reference/generated/numpy.asarray.html" rel="nofollow">numpy array</... | 12 | 2010-03-29T15:13:29Z | [
"python"
] |
python: image to 2-dimensional list | 2,539,002 | <p>Is there a python lib that could make a 2-dimensional list of (R,G,B) data out of an image file?</p>
| 2 | 2010-03-29T15:11:58Z | 2,539,042 | <p>Or ImageMagick at <a href="http://wiki.python.org/moin/ImageMagick" rel="nofollow">http://wiki.python.org/moin/ImageMagick</a></p>
| 3 | 2010-03-29T15:17:03Z | [
"python"
] |
Logging users out of a Django site after N minutes of inactivity | 2,539,109 | <p>I'm working on a website that requires us to log a user out after N minutes of inactivity. Are there any best practices for this using Django? </p>
| 9 | 2010-03-29T15:24:57Z | 2,539,299 | <p>Try setting settings.SESSION_COOKIE_AGE to N * 60 seconds. </p>
<p><a href="http://docs.djangoproject.com/en/dev/ref/settings/#session-cookie-age" rel="nofollow">http://docs.djangoproject.com/en/dev/ref/settings/#session-cookie-age</a></p>
| 0 | 2010-03-29T15:48:40Z | [
"python",
"django",
"authentication"
] |
Logging users out of a Django site after N minutes of inactivity | 2,539,109 | <p>I'm working on a website that requires us to log a user out after N minutes of inactivity. Are there any best practices for this using Django? </p>
| 9 | 2010-03-29T15:24:57Z | 2,539,307 | <p>Take a look at the <a href="http://docs.djangoproject.com/en/dev/topics/http/sessions/#topics-http-sessions">session middleware</a> and its settings. Specifically these two:</p>
<blockquote>
<p>SESSION_COOKIE_AGE</p>
<p>Default: 1209600 (2 weeks, in seconds)</p>
<p>The age of session cookies, in
secon... | 20 | 2010-03-29T15:50:00Z | [
"python",
"django",
"authentication"
] |
Logging users out of a Django site after N minutes of inactivity | 2,539,109 | <p>I'm working on a website that requires us to log a user out after N minutes of inactivity. Are there any best practices for this using Django? </p>
| 9 | 2010-03-29T15:24:57Z | 2,539,518 | <p>Setting the session cookie age in the django session middleware just sets the expiry time in the set-cookie header passed back to the browser. It's only browser compliance with the expiry time that enforces the "log out".</p>
<p>Depending on your reasons for needing the idle log-out, you might not consider browser ... | 2 | 2010-03-29T16:20:51Z | [
"python",
"django",
"authentication"
] |
Python if statement efficiency | 2,539,116 | <p>A friend (fellow low skill level recreational python scripter) asked me to look over some code. I noticed that he had 7 separate statements that basically said.</p>
<pre><code>if ( a and b and c):
do something
</code></pre>
<p>the statements a,b,c all tested their equality or lack of to set values. As I looked... | 8 | 2010-03-29T15:25:38Z | 2,539,142 | <p><code>if (a and b and c)</code> will fail if <code>a</code> is falsy, and not bother checking <code>b</code> or <code>c</code>.</p>
<p>That said, I personally feel that nested conditionals are easier to read than 2^n combinations of conditionals.</p>
<p>In general, if you want to determine which way of doing somet... | 0 | 2010-03-29T15:30:01Z | [
"python",
"performance"
] |
Python if statement efficiency | 2,539,116 | <p>A friend (fellow low skill level recreational python scripter) asked me to look over some code. I noticed that he had 7 separate statements that basically said.</p>
<pre><code>if ( a and b and c):
do something
</code></pre>
<p>the statements a,b,c all tested their equality or lack of to set values. As I looked... | 8 | 2010-03-29T15:25:38Z | 2,539,148 | <p><code>if</code> statements will skip everything in an <code>else</code> bracket if it evaluates to true. It should be noted that worrying about this sort of problem, unless it's done millions of times per program execution, is called "premature optimization" and should be avoided. If your code is clearer with three ... | 23 | 2010-03-29T15:31:24Z | [
"python",
"performance"
] |
Python if statement efficiency | 2,539,116 | <p>A friend (fellow low skill level recreational python scripter) asked me to look over some code. I noticed that he had 7 separate statements that basically said.</p>
<pre><code>if ( a and b and c):
do something
</code></pre>
<p>the statements a,b,c all tested their equality or lack of to set values. As I looked... | 8 | 2010-03-29T15:25:38Z | 2,539,152 | <p>I doubt you'd see a measurable difference so I'd recommend doing whatever makes the code most readable.</p>
| 2 | 2010-03-29T15:32:06Z | [
"python",
"performance"
] |
Python if statement efficiency | 2,539,116 | <p>A friend (fellow low skill level recreational python scripter) asked me to look over some code. I noticed that he had 7 separate statements that basically said.</p>
<pre><code>if ( a and b and c):
do something
</code></pre>
<p>the statements a,b,c all tested their equality or lack of to set values. As I looked... | 8 | 2010-03-29T15:25:38Z | 2,539,153 | <p>At least in python, efficiency is second to readability and "Flat is better than nested".</p>
<p>See <a href="http://www.python.org/dev/peps/pep-0020/">The Zen of Python</a></p>
| 8 | 2010-03-29T15:32:09Z | [
"python",
"performance"
] |
Python if statement efficiency | 2,539,116 | <p>A friend (fellow low skill level recreational python scripter) asked me to look over some code. I noticed that he had 7 separate statements that basically said.</p>
<pre><code>if ( a and b and c):
do something
</code></pre>
<p>the statements a,b,c all tested their equality or lack of to set values. As I looked... | 8 | 2010-03-29T15:25:38Z | 2,539,157 | <p>I would say the single test is as fast as the separate tests. Python also makes use of so called <a href="http://en.wikipedia.org/wiki/Short-circuit_evaluation"><strong>short-circuit evaluation</strong></a>.</p>
<p>That means for <code>(a and b and c)</code>, that <code>b</code> or <code>c</code> would not be teste... | 21 | 2010-03-29T15:32:22Z | [
"python",
"performance"
] |
Python if statement efficiency | 2,539,116 | <p>A friend (fellow low skill level recreational python scripter) asked me to look over some code. I noticed that he had 7 separate statements that basically said.</p>
<pre><code>if ( a and b and c):
do something
</code></pre>
<p>the statements a,b,c all tested their equality or lack of to set values. As I looked... | 8 | 2010-03-29T15:25:38Z | 2,539,161 | <p>Code:</p>
<pre><code>import dis
def foo():
if ( a and b and c):
pass
else:
pass
def bar():
if a:
if b:
if c:
pass
print 'foo():'
dis.dis(foo)
print 'bar():'
dis.dis(bar)
</code></pre>
<p>Output:</p>
<pre><code>foo():
4 0 LOAD_GLOBAL 0 (a)
3... | 11 | 2010-03-29T15:32:46Z | [
"python",
"performance"
] |
Python if statement efficiency | 2,539,116 | <p>A friend (fellow low skill level recreational python scripter) asked me to look over some code. I noticed that he had 7 separate statements that basically said.</p>
<pre><code>if ( a and b and c):
do something
</code></pre>
<p>the statements a,b,c all tested their equality or lack of to set values. As I looked... | 8 | 2010-03-29T15:25:38Z | 2,539,880 | <p>If you are worried about b or c being functions that are called instead of just variables that are evaluated, then this code shows that short-circuiting is your friend:</p>
<pre><code>a = False
def b():
print "b was called"
return True
if a and b():
print "this shouldn't happen"
else:
print "if b w... | 3 | 2010-03-29T17:18:45Z | [
"python",
"performance"
] |
Python if statement efficiency | 2,539,116 | <p>A friend (fellow low skill level recreational python scripter) asked me to look over some code. I noticed that he had 7 separate statements that basically said.</p>
<pre><code>if ( a and b and c):
do something
</code></pre>
<p>the statements a,b,c all tested their equality or lack of to set values. As I looked... | 8 | 2010-03-29T15:25:38Z | 2,541,780 | <p><code>if (a and b and c)</code> is faster and better, for the sake of the "Real Programmer's code optimization" and code readability.</p>
| 0 | 2010-03-29T22:49:17Z | [
"python",
"performance"
] |
Lightweight Object->Database in Python | 2,539,147 | <p>I am in need of a lightweight way to store dictionaries of data into a database. What I need is something that: </p>
<ol>
<li>Creates a database table from a simple type description (int, float, datetime etc)</li>
<li>Takes a dictionary object and inserts it into the database (including handling datetime objects!)<... | 2 | 2010-03-29T15:30:55Z | 2,539,210 | <p>Seeing as you have mentioned sql, python and orm in your tags, are you looking for <a href="http://www.djangoproject.com/" rel="nofollow">Django</a>? Of all the web frameworks I've tried, I like this one the best. You'd be looking at models, specifically. This could be too fancy for your needs, perhaps, but that sho... | 0 | 2010-03-29T15:39:03Z | [
"python",
"sql",
"orm"
] |
Lightweight Object->Database in Python | 2,539,147 | <p>I am in need of a lightweight way to store dictionaries of data into a database. What I need is something that: </p>
<ol>
<li>Creates a database table from a simple type description (int, float, datetime etc)</li>
<li>Takes a dictionary object and inserts it into the database (including handling datetime objects!)<... | 2 | 2010-03-29T15:30:55Z | 2,539,228 | <p>SQLAlchemy's <a href="http://www.sqlalchemy.org/docs/sqlexpression.html" rel="nofollow">SQL expression layer</a> can easily cover the first two requirements. If you also want reference handling then you'll need to use the ORM, but this might fail your lightweight requirement depending on your definition of lightweig... | 4 | 2010-03-29T15:40:53Z | [
"python",
"sql",
"orm"
] |
Lightweight Object->Database in Python | 2,539,147 | <p>I am in need of a lightweight way to store dictionaries of data into a database. What I need is something that: </p>
<ol>
<li>Creates a database table from a simple type description (int, float, datetime etc)</li>
<li>Takes a dictionary object and inserts it into the database (including handling datetime objects!)<... | 2 | 2010-03-29T15:30:55Z | 2,539,235 | <p>SQLAlchemy offers an ORM much like django, but does not require that you work within a web framework.</p>
| 3 | 2010-03-29T15:41:22Z | [
"python",
"sql",
"orm"
] |
Lightweight Object->Database in Python | 2,539,147 | <p>I am in need of a lightweight way to store dictionaries of data into a database. What I need is something that: </p>
<ol>
<li>Creates a database table from a simple type description (int, float, datetime etc)</li>
<li>Takes a dictionary object and inserts it into the database (including handling datetime objects!)<... | 2 | 2010-03-29T15:30:55Z | 2,539,238 | <p>From it's description, perhaps <a href="http://divmod.org/trac/wiki/DivmodAxiom" rel="nofollow">Axiom</a> is a pythonic tool for this .</p>
| 1 | 2010-03-29T15:41:28Z | [
"python",
"sql",
"orm"
] |
How do I set a matplotlib colorbar extents? | 2,539,331 | <p>I'd like to display a colorbar representing an image's raw values along side a matplotlib imshow subplot which displays that image, normalized.</p>
<p>I've been able to draw the image and a colorbar successfully like this, but the colorbar min and max values represent the normalized (0,1) image instead of the raw (... | 4 | 2010-03-29T15:53:27Z | 2,539,590 | <p>It looks like you passed the wrong object to the colorbar constructor. </p>
<p>This should work:</p>
<pre><code># make namespace explicit
from matplotlib import pyplot as PLT
cbar = fig.colorbar(result)
</code></pre>
<p>The snippet above is based on the code in your answer; here's a complete, stand-alone example... | 7 | 2010-03-29T16:30:28Z | [
"python",
"matplotlib"
] |
How do I set a matplotlib colorbar extents? | 2,539,331 | <p>I'd like to display a colorbar representing an image's raw values along side a matplotlib imshow subplot which displays that image, normalized.</p>
<p>I've been able to draw the image and a colorbar successfully like this, but the colorbar min and max values represent the normalized (0,1) image instead of the raw (... | 4 | 2010-03-29T15:53:27Z | 11,312,125 | <p>I know that it might be too late, but...<br>
For me replacing in the last line of Adam's code <code>result</code> by <code>ax</code> works out.</p>
| 1 | 2012-07-03T13:35:34Z | [
"python",
"matplotlib"
] |
How to create a draggable legend in matplotlib? | 2,539,477 | <p>I'm drawing a legend on an axes object in matplotlib but the default positioning which claims to place it in a smart place doesn't seem to work. Ideally, I'd like to have the legend be draggable by the user. How can this be done?</p>
| 31 | 2010-03-29T16:15:47Z | 2,546,149 | <p>Note: This is now built into matplotlib</p>
<pre><code>leg = plt.legend()
if leg:
leg.draggable()
</code></pre>
<p>will work as expected</p>
<hr>
<p>Well, I found bits and pieces of the solution scattered among mailing lists. I've come up with a nice modular chunk of code that you can drop in and use... here... | 21 | 2010-03-30T14:50:24Z | [
"python",
"matplotlib",
"draggable",
"legend"
] |
How to create a draggable legend in matplotlib? | 2,539,477 | <p>I'm drawing a legend on an axes object in matplotlib but the default positioning which claims to place it in a smart place doesn't seem to work. Ideally, I'd like to have the legend be draggable by the user. How can this be done?</p>
| 31 | 2010-03-29T16:15:47Z | 7,477,491 | <p>In newer versions of Matplotlib (v1.0.1), this is built-in.</p>
<pre><code>def draw(self):
ax = self.figure.add_subplot(111)
scatter = ax.scatter(np.random.randn(100), np.random.randn(100))
legend = ax.legend()
legend.draggable(state=True)
</code></pre>
<p>If you are using matplotlib interactively... | 11 | 2011-09-19T21:25:50Z | [
"python",
"matplotlib",
"draggable",
"legend"
] |
Python mechanize to follow image links? | 2,539,498 | <p>mechanize's <code>Browser</code> class is great and it's follow_link() function is great too. But what to do with this kind of links:</p>
<pre><code><a href="http://example.com"><img src="â¦"></a>
</code></pre>
<p>Is there any way to follow such links? The <code>text</code> attribute of this typ... | 3 | 2010-03-29T16:17:54Z | 2,540,948 | <p>To follow such links you need to add <strong><em>nr</em></strong> parameter to <strong>follow_link()</strong> method.<br>
Try this:</p>
<pre><code>import mechanize
br = mechanize.Browser()
br.open('http://www.systempuntoout.com')
for link in br.links():
print(link)
br.follow_link(text='[IMG]', nr=0)
print br
&g... | 5 | 2010-03-29T20:15:38Z | [
"python",
"image",
"hyperlink",
"mechanize"
] |
Simple non-network concurrency with Twisted | 2,539,599 | <p>I have a problem with using Twisted for simple concurrency in python. The problem is - I don't know how to do it and all online resources are about Twisted networking abilities. So I am turning to SO-gurus for some guidance.</p>
<p>Python 2.5 is used.</p>
<p>Simplified version of my problem runs as follows:</p>
<... | 4 | 2010-03-29T16:31:27Z | 2,540,258 | <p>To actually compute things concurrently, you'll probably need to employ multiple Python processes. A single Python process can interleave calculations, but it won't execute them in parallel (with a few exceptions).</p>
<p>Twisted is a good way to coordinate these multiple processes and collect their results. One ... | 3 | 2010-03-29T18:21:05Z | [
"python",
"concurrency",
"twisted"
] |
Simple non-network concurrency with Twisted | 2,539,599 | <p>I have a problem with using Twisted for simple concurrency in python. The problem is - I don't know how to do it and all online resources are about Twisted networking abilities. So I am turning to SO-gurus for some guidance.</p>
<p>Python 2.5 is used.</p>
<p>Simplified version of my problem runs as follows:</p>
<... | 4 | 2010-03-29T16:31:27Z | 2,541,109 | <p>Do you need Twisted at all?</p>
<p>From your description of the problem I'd say that <a href="http://docs.python.org/library/multiprocessing.html" rel="nofollow">multiprocessing</a> would fit the bill. Create a number of <code>Process</code> objects that are given a reference to a single <code>Queue</code> instanc... | 2 | 2010-03-29T20:39:28Z | [
"python",
"concurrency",
"twisted"
] |
Simple non-network concurrency with Twisted | 2,539,599 | <p>I have a problem with using Twisted for simple concurrency in python. The problem is - I don't know how to do it and all online resources are about Twisted networking abilities. So I am turning to SO-gurus for some guidance.</p>
<p>Python 2.5 is used.</p>
<p>Simplified version of my problem runs as follows:</p>
<... | 4 | 2010-03-29T16:31:27Z | 2,541,346 | <p>As Jean-Paul said, Twisted is great for coordinating multiple processes. However, unless you need to use Twisted, and simply need a distributed processing pool, there are possibly better suited tools out there.</p>
<p>One I can think of which hasn't been mentioned is <a href="http://celeryproject.org" rel="nofollow... | 4 | 2010-03-29T21:19:11Z | [
"python",
"concurrency",
"twisted"
] |
Simple non-network concurrency with Twisted | 2,539,599 | <p>I have a problem with using Twisted for simple concurrency in python. The problem is - I don't know how to do it and all online resources are about Twisted networking abilities. So I am turning to SO-gurus for some guidance.</p>
<p>Python 2.5 is used.</p>
<p>Simplified version of my problem runs as follows:</p>
<... | 4 | 2010-03-29T16:31:27Z | 2,650,408 | <p>It seems to me that you are misunderstanding the fundamentals of how Twisted operates. I recommend you give the <a href="http://krondo.com/blog/?page_id=1327" rel="nofollow">Twisted Intro</a> a shot by <a href="http://krondo.com" rel="nofollow">Dave Peticolas</a>. It has been a great help to me, and I've been usin... | 1 | 2010-04-16T03:33:04Z | [
"python",
"concurrency",
"twisted"
] |
Python NLTK figure out tense | 2,539,782 | <p>I have a web application that translates sentences into English; the user chooses options from drop downs that basically provide the context. Now I want to turn the word and the context into an English sentence.</p>
<p>One case is that the user chooses 'who' and 'when', 'who' could be: I, you, you two, he, she, we,... | 1 | 2010-03-29T17:03:59Z | 2,540,925 | <p>NLTK is a fairly large project containing a lot of useful tools. I'd suggest starting out by reading the <a href="http://www.nltk.org/book" rel="nofollow">NLTK Book</a>, which is very well done. You can probably skim the first few chapters.</p>
<p>The stuff you're looking for is in chapters 7 and beyond.</p>
| 3 | 2010-03-29T20:12:26Z | [
"python",
"nltk"
] |
What is the equivalent for pycassa ColumnFamily.get_range() with Lazyboy? | 2,540,040 | <p>I think everything is in the question.
I'm looking for the Lazyboy equivalent for Pycassa ColumnFamily.get_range() -- with features like column_start, column_finish et column_count --.</p>
<p>Thanks.</p>
| 1 | 2010-03-29T17:46:05Z | 2,547,768 | <p>check out this file in lazyboy:</p>
<p><a href="http://github.com/digg/lazyboy/blob/master/lazyboy/iterators.py" rel="nofollow">http://github.com/digg/lazyboy/blob/master/lazyboy/iterators.py</a></p>
<p>it has a few different range methods. </p>
<p>E.g., line 121: def key_range(key, start="", finish="", count=100... | 1 | 2010-03-30T18:47:55Z | [
"python",
"database",
"nosql",
"cassandra"
] |
Return current 11-digit timestamp in Python | 2,540,043 | <p>How can I return the current time of the local machine?</p>
| 8 | 2010-03-29T17:46:33Z | 2,540,058 | <p>Do you mean this: <a href="http://docs.python.org/library/time.html#time.time">time.time()</a>?</p>
<p>From the docs:</p>
<p><em>Return the time as a floating point number expressed in seconds since the epoch, in UTC</em></p>
<pre><code>>>> import time
>>> time.time()
1269884900.480978
>>&... | 17 | 2010-03-29T17:48:40Z | [
"python",
"timestamp"
] |
Scipy sparse... arrays? | 2,540,059 | <p>So, I'm doing some Kmeans classification using numpy arrays that are quite sparse-- lots and lots of zeroes. I figured that I'd use scipy's 'sparse' package to reduce the storage overhead, but I'm a little confused about how to create arrays, not matrices.</p>
<p>I've gone through this tutorial on how to create sp... | 25 | 2010-03-29T17:48:57Z | 2,540,230 | <p>You could create a subclass of one of the existing 2d sparse arrays</p>
<pre><code>from scipy.sparse import dok_matrix
class sparse1d(dok_matrix):
def __init__(self, v):
dok_matrix.__init__(self, (v,))
def dot(self, other):
return dok_matrix.dot(self, other.transpose())[0,0]
a=sparse1d((1,... | 1 | 2010-03-29T18:16:22Z | [
"python",
"matrix",
"numpy",
"scipy",
"sparse-matrix"
] |
Scipy sparse... arrays? | 2,540,059 | <p>So, I'm doing some Kmeans classification using numpy arrays that are quite sparse-- lots and lots of zeroes. I figured that I'd use scipy's 'sparse' package to reduce the storage overhead, but I'm a little confused about how to create arrays, not matrices.</p>
<p>I've gone through this tutorial on how to create sp... | 25 | 2010-03-29T17:48:57Z | 2,540,495 | <p>I'm not sure that it is really much better or faster, but you could do this to avoid using the transpose:</p>
<pre><code>Asp.multiply(Bsp).sum()
</code></pre>
<p>This just takes the element-by-element product of the two matrices and sums the products. You could make a subclass of whatever matrix format you are usi... | 0 | 2010-03-29T18:59:31Z | [
"python",
"matrix",
"numpy",
"scipy",
"sparse-matrix"
] |
Scipy sparse... arrays? | 2,540,059 | <p>So, I'm doing some Kmeans classification using numpy arrays that are quite sparse-- lots and lots of zeroes. I figured that I'd use scipy's 'sparse' package to reduce the storage overhead, but I'm a little confused about how to create arrays, not matrices.</p>
<p>I've gone through this tutorial on how to create sp... | 25 | 2010-03-29T17:48:57Z | 6,754,832 | <p>Use a <code>scipy.sparse</code> format that is row or column based: <code>csc_matrix</code> and <code>csr_matrix</code>. </p>
<p>These use efficient, C implementations under the hood (including multiplication), and transposition is a no-op (esp. if you call <code>transpose(copy=False)</code>), just like with numpy ... | 24 | 2011-07-19T22:23:11Z | [
"python",
"matrix",
"numpy",
"scipy",
"sparse-matrix"
] |
How can I check for unused import in many Python files? | 2,540,202 | <p>I remember when I was developing in C++ or Java, the compiler usually complains for unused methods, functions or imports. In my Django project, I have a bunch of Python files which have gone through a number of iterations. Some of those files have a few lines of import statement at the top of the page and some of ... | 24 | 2010-03-29T18:12:06Z | 2,540,211 | <p>Use a tool like <a href="http://www.logilab.org/857">pylint</a> which will signal these code defects (among a lot of others).</p>
<p>Doing these kinds of 'pre-runtime' checks is hard in a language with dynamic typing, but pylint does a terrific job at catching these typos / leftovers from refactoring etc ...</p>
| 8 | 2010-03-29T18:13:33Z | [
"python"
] |
How can I check for unused import in many Python files? | 2,540,202 | <p>I remember when I was developing in C++ or Java, the compiler usually complains for unused methods, functions or imports. In my Django project, I have a bunch of Python files which have gone through a number of iterations. Some of those files have a few lines of import statement at the top of the page and some of ... | 24 | 2010-03-29T18:12:06Z | 2,540,221 | <p><a href="https://launchpad.net/pyflakes">PyFlakes</a> (similar to lint) will give you this information.</p>
| 22 | 2010-03-29T18:15:18Z | [
"python"
] |
How can I check for unused import in many Python files? | 2,540,202 | <p>I remember when I was developing in C++ or Java, the compiler usually complains for unused methods, functions or imports. In my Django project, I have a bunch of Python files which have gone through a number of iterations. Some of those files have a few lines of import statement at the top of the page and some of ... | 24 | 2010-03-29T18:12:06Z | 2,540,224 | <p>Have a look at <a href="http://pychecker.sourceforge.net/">PyChecker</a>. It is a debugging tool and able to find unused variables and modules.</p>
| 5 | 2010-03-29T18:15:28Z | [
"python"
] |
How can I check for unused import in many Python files? | 2,540,202 | <p>I remember when I was developing in C++ or Java, the compiler usually complains for unused methods, functions or imports. In my Django project, I have a bunch of Python files which have gone through a number of iterations. Some of those files have a few lines of import statement at the top of the page and some of ... | 24 | 2010-03-29T18:12:06Z | 2,540,421 | <p>If you use the <a href="http://www.eclipse.org/" rel="nofollow">eclipse</a> IDE with <a href="http://pydev.org/" rel="nofollow">pydev</a> and <a href="http://www.eclipse.org/mylyn/" rel="nofollow">mylyn</a>, it provides automatic checking and highlighting for unused imports, among other things. It integrates with p... | 3 | 2010-03-29T18:48:37Z | [
"python"
] |
How can I check for unused import in many Python files? | 2,540,202 | <p>I remember when I was developing in C++ or Java, the compiler usually complains for unused methods, functions or imports. In my Django project, I have a bunch of Python files which have gone through a number of iterations. Some of those files have a few lines of import statement at the top of the page and some of ... | 24 | 2010-03-29T18:12:06Z | 37,313,676 | <p>I have been using <a href="https://pypi.python.org/pypi/pyflakes" rel="nofollow" title="pyflakes">pyflakes</a> successfully and wished to auto-remove the unused imports. </p>
<p>I recently found <a href="https://pypi.python.org/pypi/autoflake/" rel="nofollow" title="autoflake">autoflake</a>:</p>
<ul>
<li>Uses <a ... | 1 | 2016-05-19T03:53:05Z | [
"python"
] |
how to handle an asymptote/discontinuity with Matplotlib | 2,540,294 | <p>When plotting a graph with a discontinuity/asymptote/singularity/whatever, is there any automatic way to prevent Matplotlib from 'joining the dots' across the 'break'? (please see code/image below).<br>
I read that Sage has a [detect_poles] facility that looked good, but I really want it to work with Matplotlib.</p>... | 18 | 2010-03-29T18:27:09Z | 2,541,682 | <p>No, I think there is no built-in way to tell <code>matplotlib</code> to ignore these
points. After all, it just connects points and knows nothing about functions
or what happens in between the points.</p>
<p>However, you can use <code>sympy</code> to find the poles, and then patch the continuous pieces of your func... | 5 | 2010-03-29T22:31:09Z | [
"python",
"numpy",
"matplotlib",
"equation",
"sympy"
] |
how to handle an asymptote/discontinuity with Matplotlib | 2,540,294 | <p>When plotting a graph with a discontinuity/asymptote/singularity/whatever, is there any automatic way to prevent Matplotlib from 'joining the dots' across the 'break'? (please see code/image below).<br>
I read that Sage has a [detect_poles] facility that looked good, but I really want it to work with Matplotlib.</p>... | 18 | 2010-03-29T18:27:09Z | 2,542,065 | <p>This may not be the elegant solution you are looking for, but if just want results for most cases, you can "clip" large and small values of your plotted data to <code>+â</code> and <code>-â</code> respectively. Matplotlib does not plot these. Of course you have to be careful not to make your resolution too low... | 10 | 2010-03-30T00:05:24Z | [
"python",
"numpy",
"matplotlib",
"equation",
"sympy"
] |
how to handle an asymptote/discontinuity with Matplotlib | 2,540,294 | <p>When plotting a graph with a discontinuity/asymptote/singularity/whatever, is there any automatic way to prevent Matplotlib from 'joining the dots' across the 'break'? (please see code/image below).<br>
I read that Sage has a [detect_poles] facility that looked good, but I really want it to work with Matplotlib.</p>... | 18 | 2010-03-29T18:27:09Z | 2,543,391 | <p>By using <a href="http://docs.scipy.org/doc/numpy/reference/maskedarray.html" rel="nofollow">masked arrays</a> you can avoid plotting selected regions of a curve. </p>
<p>To remove the singularity at x=2:</p>
<pre><code>import matplotlib.numerix.ma as M # for older versions, prior to .98
#import numpy.ma as M ... | 17 | 2010-03-30T07:06:17Z | [
"python",
"numpy",
"matplotlib",
"equation",
"sympy"
] |
Timezones and the DateTimeField - Django | 2,540,298 | <p>I'm trying to implement a <strong>"time ago" feature</strong>, for the displaying of items on a site.
As I'm caching the pages I wish to use javascript in order to render the "time ago".</p>
<p>Javascript knows local time and problably the Timezone of the local machine so I could play with that, but that would requ... | 0 | 2010-03-29T18:27:29Z | 2,540,428 | <p>The python <code>datetime</code> objects has a method for outputting an ISO 8601 timestamp <a href="http://docs.python.org/library/datetime.html#datetime.datetime.isoformat" rel="nofollow">here</a>.</p>
<p>That page also has information on timezone manipulation. The <a href="http://docs.python.org/library/datetime.... | 2 | 2010-03-29T18:49:31Z | [
"javascript",
"python",
"django",
"timezone",
"iso8601"
] |
Timezones and the DateTimeField - Django | 2,540,298 | <p>I'm trying to implement a <strong>"time ago" feature</strong>, for the displaying of items on a site.
As I'm caching the pages I wish to use javascript in order to render the "time ago".</p>
<p>Javascript knows local time and problably the Timezone of the local machine so I could play with that, but that would requ... | 0 | 2010-03-29T18:27:29Z | 2,540,453 | <p>I wouldn't use javascript to do this personally. Yes it has their local time, but it also means that the user will then see the timestamps will change when the javascript finally renders on the page.</p>
<p>That is, assuming you're properly not executing your javascript until the page is loaded.</p>
| 0 | 2010-03-29T18:53:36Z | [
"javascript",
"python",
"django",
"timezone",
"iso8601"
] |
Problem with room/screen/menu controller in python game: old rooms are not removed from memory | 2,540,437 | <p>I'm literally banging my head against a wall here (as in, yes, physically, at my current location, I am damaging my cranium). Basically, I've got a Python/Pygame game with some typical game "rooms", or "screens." EG title screen, high scores screen, and the actual game room. Something bad is happening when I switch ... | 1 | 2010-03-29T18:50:45Z | 2,540,765 | <p>When you do something like this:</p>
<pre><code>return rooms.TitleScreen(self.screen, self.ev_manager)
</code></pre>
<p>I'm assuming that you're creating a new TitleScreen object.</p>
<p>If this is what you want to do then you probably want to delete the old room object when switching rooms.</p>
<pre><code>def ... | 1 | 2010-03-29T19:45:24Z | [
"python",
"performance",
"event-handling",
"pygame"
] |
Problem with room/screen/menu controller in python game: old rooms are not removed from memory | 2,540,437 | <p>I'm literally banging my head against a wall here (as in, yes, physically, at my current location, I am damaging my cranium). Basically, I've got a Python/Pygame game with some typical game "rooms", or "screens." EG title screen, high scores screen, and the actual game room. Something bad is happening when I switch ... | 1 | 2010-03-29T18:50:45Z | 2,541,027 | <p>I've also tried keeping track of the rooms, instead of throwing them and creating new ones each time a new room request comes around. Unfortunately, this code isn't working for me either: when I return to the title screen from the game room, the title screen renders, but nothing responds to anything... I'm not sure ... | 0 | 2010-03-29T20:26:07Z | [
"python",
"performance",
"event-handling",
"pygame"
] |
Problem with room/screen/menu controller in python game: old rooms are not removed from memory | 2,540,437 | <p>I'm literally banging my head against a wall here (as in, yes, physically, at my current location, I am damaging my cranium). Basically, I've got a Python/Pygame game with some typical game "rooms", or "screens." EG title screen, high scores screen, and the actual game room. Something bad is happening when I switch ... | 1 | 2010-03-29T18:50:45Z | 2,542,979 | <p>Well, temporarily "solved" this by adding a clear() function to my event manager, and calling that before every room switch, clearing out all listeners except for my three controllers:</p>
<pre><code>def clear(self):
for listener in list(self.listeners):
if not isinstance(listener, CPUSpinnerControl... | 0 | 2010-03-30T05:11:01Z | [
"python",
"performance",
"event-handling",
"pygame"
] |
Tell if a given login exists in Linux using Python | 2,540,460 | <p>In Python under Linux, what is the easiest way to check the existence of a user, given his/her login?</p>
<p>Anything better than issuing 'ls ~login-name' and checking the exit code?</p>
<p>And if running under Windows?</p>
| 8 | 2010-03-29T18:54:02Z | 2,540,487 | <p>To look up my userid (<code>bagnew</code>) under Unix:</p>
<pre><code>import pwd
pw = pwd.getpwnam("bagnew")
uid = pw.pw_uid
</code></pre>
<p>See the <a href="http://docs.python.org/library/pwd.html" rel="nofollow">pwd</a> module info for more.</p>
| 8 | 2010-03-29T18:57:47Z | [
"python",
"login"
] |
Tell if a given login exists in Linux using Python | 2,540,460 | <p>In Python under Linux, what is the easiest way to check the existence of a user, given his/her login?</p>
<p>Anything better than issuing 'ls ~login-name' and checking the exit code?</p>
<p>And if running under Windows?</p>
| 8 | 2010-03-29T18:54:02Z | 2,540,756 | <p>I would parse /etc/passwd for the username in question. Users may not necessarily have homedir's.</p>
| 0 | 2010-03-29T19:43:21Z | [
"python",
"login"
] |
Tell if a given login exists in Linux using Python | 2,540,460 | <p>In Python under Linux, what is the easiest way to check the existence of a user, given his/her login?</p>
<p>Anything better than issuing 'ls ~login-name' and checking the exit code?</p>
<p>And if running under Windows?</p>
| 8 | 2010-03-29T18:54:02Z | 2,541,379 | <p>Using pwd you can get a listing of all available user entries using pwd.getpwall(). This can work if you do not like try:/except: blocks.</p>
<pre><code>import pwd
userid = "zomobiba"
if userid in [x[0] for x in pwd.getpwall()]:
print "Yay"
</code></pre>
| 2 | 2010-03-29T21:25:00Z | [
"python",
"login"
] |
Tell if a given login exists in Linux using Python | 2,540,460 | <p>In Python under Linux, what is the easiest way to check the existence of a user, given his/her login?</p>
<p>Anything better than issuing 'ls ~login-name' and checking the exit code?</p>
<p>And if running under Windows?</p>
| 8 | 2010-03-29T18:54:02Z | 15,168,560 | <p>This answer builds upon the <a href="http://stackoverflow.com/a/2540487/832230">answer by Brian</a>. It adds the necessary <code>try...except</code> block.</p>
<p>Check if a user exists:</p>
<pre><code>import pwd
try:
pwd.getpwnam('someusr')
except KeyError:
print('User someusr does not exist.')
</code></... | 11 | 2013-03-01T23:23:45Z | [
"python",
"login"
] |
Tell if a given login exists in Linux using Python | 2,540,460 | <p>In Python under Linux, what is the easiest way to check the existence of a user, given his/her login?</p>
<p>Anything better than issuing 'ls ~login-name' and checking the exit code?</p>
<p>And if running under Windows?</p>
| 8 | 2010-03-29T18:54:02Z | 15,169,016 | <p>Similar to <a href="http://stackoverflow.com/a/2541379/">this answer</a>, I would do this:</p>
<pre><code>>>> import pwd
>>> 'tshepang' in [entry.pw_name for entry in pwd.getpwall()]
True
</code></pre>
| 0 | 2013-03-02T00:08:25Z | [
"python",
"login"
] |
python on apache - getting 404 | 2,540,475 | <p><b>I edited this question after i found a solution... i need to understand why the solution worked instead of my method?</b></p>
<p>This is likely to be a silly question. I tried searching other questions that are related... but to no avail.</p>
<p><i>i am running Apache/2.2.11 (Ubuntu) DAV/2 SVN/1.5.4 PHP/5.2.6-3... | 3 | 2010-03-29T18:56:14Z | 2,540,536 | <p>I think the mod_python's <a href="http://www.modpython.org/live/current/doc-html/tut-pub.html" rel="nofollow">Publisher Handler</a> is expecting to find <code>index</code> function in test.py.</p>
<p>You can call any function inside test.py by putting it in the end of URL, e.g. <code>http://localhost/test.py/any_fu... | 4 | 2010-03-29T19:05:22Z | [
"python",
"apache2"
] |
python on apache - getting 404 | 2,540,475 | <p><b>I edited this question after i found a solution... i need to understand why the solution worked instead of my method?</b></p>
<p>This is likely to be a silly question. I tried searching other questions that are related... but to no avail.</p>
<p><i>i am running Apache/2.2.11 (Ubuntu) DAV/2 SVN/1.5.4 PHP/5.2.6-3... | 3 | 2010-03-29T18:56:14Z | 20,202,367 | <p>If you want to have your code working as is, you can also configure your web server to handle .pl as cgi script instead of using mod_python.publisher</p>
<p>on apache config:</p>
<pre><code>AddHandler cgi-script .py
</code></pre>
<p>and if you don't want an error 403, edit:</p>
<pre><code><Directory /path/to/... | 0 | 2013-11-25T20:14:07Z | [
"python",
"apache2"
] |
What is the Python equivalent of Perl's FindBin? | 2,540,481 | <p>In Perl, the <a href="http://perldoc.perl.org/FindBin.html" rel="nofollow"><code>FindBin</code></a> module is used to locate the directory of the original script. What's the canonical way to get this directory in Python?</p>
<p>Some of the options I've seen: </p>
<ul>
<li><code>os.path.dirname(os.path.realpath(... | 6 | 2010-03-29T18:57:09Z | 2,540,533 | <p>I don't use Python very often so I do not know if there is package like <a href="http://perldoc.perl.org/FindBin.html">FindBin</a> but </p>
<pre><code>import os
import sys
bindir = os.path.abspath(os.path.dirname(sys.argv[0]))
</code></pre>
<p>should work.</p>
| 6 | 2010-03-29T19:04:39Z | [
"python",
"perl",
"path"
] |
What is the Python equivalent of Perl's FindBin? | 2,540,481 | <p>In Perl, the <a href="http://perldoc.perl.org/FindBin.html" rel="nofollow"><code>FindBin</code></a> module is used to locate the directory of the original script. What's the canonical way to get this directory in Python?</p>
<p>Some of the options I've seen: </p>
<ul>
<li><code>os.path.dirname(os.path.realpath(... | 6 | 2010-03-29T18:57:09Z | 2,540,559 | <p>You can try this:</p>
<pre><code>import os
bindir = os.path.abspath(os.path.dirname(__file__))
</code></pre>
<p>That will give you the absolute path of the current file's directory.</p>
| 12 | 2010-03-29T19:08:41Z | [
"python",
"perl",
"path"
] |
Is there a Python equivalent to Perl's Data::Dumper? | 2,540,567 | <p>Is there a Python module that can be used in the same way as Perl's <a href="http://search.cpan.org/~smueller/Data-Dumper-2.125/Dumper.pm"><code>Data::Dumper</code></a> module?</p>
<p><strong>Edit:</strong> Sorry, I should have been clearer. I was mainly after a module for inspecting data rather than persisting.</p... | 25 | 2010-03-29T19:09:48Z | 2,540,637 | <p>Possibly a couple of alternatives: <a href="http://docs.python.org/library/pickle.html" rel="nofollow">pickle</a>, <a href="http://docs.python.org/library/marshal.html" rel="nofollow">marshal</a>, <a href="http://docs.python.org/library/shelve.html#module-shelve" rel="nofollow">shelve</a>.</p>
| 3 | 2010-03-29T19:21:29Z | [
"python",
"module",
"object-dumper"
] |
Is there a Python equivalent to Perl's Data::Dumper? | 2,540,567 | <p>Is there a Python module that can be used in the same way as Perl's <a href="http://search.cpan.org/~smueller/Data-Dumper-2.125/Dumper.pm"><code>Data::Dumper</code></a> module?</p>
<p><strong>Edit:</strong> Sorry, I should have been clearer. I was mainly after a module for inspecting data rather than persisting.</p... | 25 | 2010-03-29T19:09:48Z | 2,540,660 | <p>Data::Dumper has two main uses: data persistence and debugging/inspecting objects. As far as I know, there isn't anything that's going to work exactly the same as Data::Dumper.</p>
<p>I use <a href="http://docs.python.org/library/pickle.html">pickle</a> for data persistence.</p>
<p>I use <a href="http://docs.pyth... | 21 | 2010-03-29T19:26:23Z | [
"python",
"module",
"object-dumper"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.