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 |
|---|---|---|---|---|---|---|---|---|---|
Python: Using vars() to assign a string to a variable | 2,320,945 | <p>I find it very useful to be able to create new variables during runtime and create a dictionary of the results for processing later, i.e. writing to a file:</p>
<pre><code>myDict = {}
for i in range (1,10):
temp = "variable"+str(i)
vars()[temp] = myFunctionThatReturnsData() # variable1= data1, variable2 = ... | 17 | 2010-02-23T19:09:41Z | 2,321,633 | <p><strong>The pythonic way to create a sequence of variables</strong></p>
<p>If you want a sequence of variables, create a sequence. Instead of trying to create independent variables like:</p>
<pre><code>variable0
variable1
variable2
variable3
</code></pre>
<p>You should look at creating a <code>list</code>. This... | 27 | 2010-02-23T20:53:48Z | [
"python",
"string",
"dictionary",
"variables"
] |
Python: Using vars() to assign a string to a variable | 2,320,945 | <p>I find it very useful to be able to create new variables during runtime and create a dictionary of the results for processing later, i.e. writing to a file:</p>
<pre><code>myDict = {}
for i in range (1,10):
temp = "variable"+str(i)
vars()[temp] = myFunctionThatReturnsData() # variable1= data1, variable2 = ... | 17 | 2010-02-23T19:09:41Z | 22,119,964 | <p>Using vars / locals or globals in this way is (a) poor practice and (b) doesn't work in all cases. See <a href="http://stackoverflow.com/questions/8028708/dynamically-set-local-variable-in-Python">Dynamically set local variable in Python</a> for more details. Bottom line: just use dicts -- that's what they're for. <... | 1 | 2014-03-01T20:30:07Z | [
"python",
"string",
"dictionary",
"variables"
] |
Python: Using vars() to assign a string to a variable | 2,320,945 | <p>I find it very useful to be able to create new variables during runtime and create a dictionary of the results for processing later, i.e. writing to a file:</p>
<pre><code>myDict = {}
for i in range (1,10):
temp = "variable"+str(i)
vars()[temp] = myFunctionThatReturnsData() # variable1= data1, variable2 = ... | 17 | 2010-02-23T19:09:41Z | 22,989,589 | <p>jcdyer explains the concepts very well and Justin Peel clearly states what <code>vars()</code> and <code>locals()</code> do. But a small example always speeds up understanding.</p>
<pre><code>class Bull(object):
def __init__(self):
self.x = 1
self.y = "this"
def __repr__(self):
re... | 3 | 2014-04-10T13:33:55Z | [
"python",
"string",
"dictionary",
"variables"
] |
How do I render *parts* of a svg file? | 2,321,155 | <p>I want to render parts of a svg file by name but for the life of me I cannot figure out how to do so (using python + gtk).</p>
<p>Here's the svg file in question: <a href="http://david.bellot.free.fr/svg-cards/files/SVG-cards-2.0.1.tar.gz" rel="nofollow">http://david.bellot.free.fr/svg-cards/files/SVG-cards-2.0.1.t... | 7 | 2010-02-23T19:44:54Z | 2,321,288 | <p>I believe that what he means by 'through a DOM interface' is that since SVG is XML, you could load the SVG file in <em>minidom</em>, or some other Python XML parser, and extract the XML node with the specific name that you are looking for. That XML node should represent an item that can be rendered. </p>
| 2 | 2010-02-23T20:03:23Z | [
"python",
"gtk",
"svg",
"cairo"
] |
How do I render *parts* of a svg file? | 2,321,155 | <p>I want to render parts of a svg file by name but for the life of me I cannot figure out how to do so (using python + gtk).</p>
<p>Here's the svg file in question: <a href="http://david.bellot.free.fr/svg-cards/files/SVG-cards-2.0.1.tar.gz" rel="nofollow">http://david.bellot.free.fr/svg-cards/files/SVG-cards-2.0.1.t... | 7 | 2010-02-23T19:44:54Z | 2,321,364 | <p>You can do it by editing the tag. Edit width and height, set the viewBox attribute on the main svg element to the rectangle you want, render, repeat.</p>
<p>See <a href="http://stackoverflow.com/questions/1098317/svg-slicing">http://stackoverflow.com/questions/1098317/svg-slicing</a> and <a href="http://dingoskidn... | 0 | 2010-02-23T20:13:29Z | [
"python",
"gtk",
"svg",
"cairo"
] |
How do I render *parts* of a svg file? | 2,321,155 | <p>I want to render parts of a svg file by name but for the life of me I cannot figure out how to do so (using python + gtk).</p>
<p>Here's the svg file in question: <a href="http://david.bellot.free.fr/svg-cards/files/SVG-cards-2.0.1.tar.gz" rel="nofollow">http://david.bellot.free.fr/svg-cards/files/SVG-cards-2.0.1.t... | 7 | 2010-02-23T19:44:54Z | 2,321,909 | <p>The GTK library for rendering SVG is called RSVG. It has python bindings, but they are undocumented, and they don't wrap the <code>rsvg_handle_get_pixbuf_sub()</code> and <code>rsvg_handle_render_cairo_sub()</code> functions which you would normally use for that purpose in C. Here's what you have to do as far as I c... | 9 | 2010-02-23T21:34:57Z | [
"python",
"gtk",
"svg",
"cairo"
] |
How do I render *parts* of a svg file? | 2,321,155 | <p>I want to render parts of a svg file by name but for the life of me I cannot figure out how to do so (using python + gtk).</p>
<p>Here's the svg file in question: <a href="http://david.bellot.free.fr/svg-cards/files/SVG-cards-2.0.1.tar.gz" rel="nofollow">http://david.bellot.free.fr/svg-cards/files/SVG-cards-2.0.1.t... | 7 | 2010-02-23T19:44:54Z | 2,910,007 | <p>Here's my answer to the cropping blank space problem. It's a rough hack but it worked great. This would also serve as a good starting point to get cards for anyone making a card game in python.</p>
<pre><code>import gtk
import rsvg
svg = rsvg.Handle(file="/usr/share/gnome-games-common/cards/gnomangelo_bitmap.svg")
... | 1 | 2010-05-26T03:48:58Z | [
"python",
"gtk",
"svg",
"cairo"
] |
Detect mobile browser (not just iPhone) in python view | 2,321,172 | <p>I have a web application written in Django that has one specific page I'd like to implement a mobile version of the template (and slightly different logic) for. I'd like to be able to implement it ala this sudo code:</p>
<pre><code>def(myView)
do some stuff
if user-is-on-a-mobile-device:
do some stuff
... | 32 | 2010-02-23T19:47:03Z | 2,321,195 | <p>Update:</p>
<p>I just found: <a href="http://code.google.com/p/minidetector/">http://code.google.com/p/minidetector/</a></p>
<p>Which seems to do exactly what I want, I'm going to test now. Feel free to tell me i'm wrong!</p>
| 19 | 2010-02-23T19:50:17Z | [
"python",
"django",
"mobile",
"user-agent"
] |
Detect mobile browser (not just iPhone) in python view | 2,321,172 | <p>I have a web application written in Django that has one specific page I'd like to implement a mobile version of the template (and slightly different logic) for. I'd like to be able to implement it ala this sudo code:</p>
<pre><code>def(myView)
do some stuff
if user-is-on-a-mobile-device:
do some stuff
... | 32 | 2010-02-23T19:47:03Z | 4,152,306 | <p>best practice: use <a href="http://code.google.com/p/minidetector/">minidetector</a> to add the extra info to the request, then use django's built in request context to pass it to your templates like so.</p>
<pre><code>from django.shortcuts import render_to_response
from django.template import RequestContext
def m... | 15 | 2010-11-11T07:48:12Z | [
"python",
"django",
"mobile",
"user-agent"
] |
Detect mobile browser (not just iPhone) in python view | 2,321,172 | <p>I have a web application written in Django that has one specific page I'd like to implement a mobile version of the template (and slightly different logic) for. I'd like to be able to implement it ala this sudo code:</p>
<pre><code>def(myView)
do some stuff
if user-is-on-a-mobile-device:
do some stuff
... | 32 | 2010-02-23T19:47:03Z | 15,502,709 | <p>go for the fork of minidetecor called django-mobi, it includes documentation on how to use it. </p>
<p><a href="https://pypi.python.org/pypi/django-mobi">https://pypi.python.org/pypi/django-mobi</a></p>
| 7 | 2013-03-19T14:50:05Z | [
"python",
"django",
"mobile",
"user-agent"
] |
Best way to schedule a task to run in next iteration of a Twisted reactor loop | 2,321,453 | <p>I want to schedule a task to run in the next iteration of the reactor loop. What's the best way to do it?</p>
<p>reactor.callLater(0, ...)?</p>
| 3 | 2010-02-23T20:25:03Z | 2,321,464 | <p>You are correct:</p>
<pre><code>reactor.callLater(0, ...)
</code></pre>
| 1 | 2010-02-23T20:27:28Z | [
"python",
"twisted"
] |
Best way to schedule a task to run in next iteration of a Twisted reactor loop | 2,321,453 | <p>I want to schedule a task to run in the next iteration of the reactor loop. What's the best way to do it?</p>
<p>reactor.callLater(0, ...)?</p>
| 3 | 2010-02-23T20:25:03Z | 3,303,684 | <p>From <a href="http://twistedmatrix.com/documents/10.1.0/api/twisted.internet.interfaces.IReactorThreads.callFromThread.html" rel="nofollow">the docs</a>, the correct way seems to be as you said, <code>reactor.callLater(0, ...)</code>.</p>
| 0 | 2010-07-21T20:45:52Z | [
"python",
"twisted"
] |
Twisted connectionLost Event | 2,321,468 | <p>Hey there,
I use the twisted.words.protocols.jabber.client.XMPPClientFactory . Do you know how I can callback a function when the connection gets lost (for example WiFi-connection is down)?</p>
<p>thank you for your help!</p>
| 1 | 2010-02-23T20:28:22Z | 2,747,208 | <p>You can either add a bootstrap for xmlstream.STREAM_END_EVENT or set a defer to clientConnectionLost.</p>
<pre><code>from twisted.words.protocols.jabber import client
from twisted.words.protocols.jabber import jid
from twisted.words.protocols.jabber import xmlstream
j = jid.JID("name@example.org/bla")
p = "some pa... | 1 | 2010-04-30T19:45:03Z | [
"python",
"twisted",
"xmpp",
"twisted.words"
] |
How to override NULL value from aggregate query using MySQLdb module in python? | 2,321,518 | <p>I am selecting the maximum date value from a MySQL database table in python using the MySQLdb module. If the result comes back as null, I want to override it with a default value. I could do this in the MySQL using a sub-query, but would prefer to do it in python.</p>
<p>Any recommendations on a simple way to do th... | 2 | 2010-02-23T20:36:33Z | 2,321,530 | <p>Try this:</p>
<pre><code>min_date = cur.fetchone()[0]
min_date = min_date if min_date is not None else default_value
</code></pre>
| 1 | 2010-02-23T20:38:26Z | [
"python",
"mysql"
] |
How to override NULL value from aggregate query using MySQLdb module in python? | 2,321,518 | <p>I am selecting the maximum date value from a MySQL database table in python using the MySQLdb module. If the result comes back as null, I want to override it with a default value. I could do this in the MySQL using a sub-query, but would prefer to do it in python.</p>
<p>Any recommendations on a simple way to do th... | 2 | 2010-02-23T20:36:33Z | 2,321,535 | <blockquote>
<p>I could do this in the MySQL using a sub-query, but would prefer to do it in python.</p>
</blockquote>
<p>Why do you say you need a subquery? You can just use <a href="http://dev.mysql.com/doc/refman/5.0/en/comparison-operators.html#function_coalesce" rel="nofollow">COALESCE</a>:</p>
<pre><code>"sel... | 4 | 2010-02-23T20:39:20Z | [
"python",
"mysql"
] |
Feedparser newbie questions | 2,321,523 | <p>After a break from Python(and I knew very little then!) I'm coming back to it for a project(hopefully!). I want to do some parsing using Feedparser & need a few hints to start. Before anyone shouts, I have searched Google and read the docs, but I'm a bit too rusty unfortunately!(So please don't lmgtfy me!)</p>... | 0 | 2010-02-23T20:37:20Z | 2,321,575 | <pre><code>import feedparser
url = "http://..."
feed = feedparser.parse(url)
for post in feed.entries:
title = post.title
print(title)
</code></pre>
<p>If you'd like to extract just the third post, then you could use</p>
<pre><code>post=feed.entries[2]
</code></pre>
<p>(since python uses 0-based indexing). P... | 1 | 2010-02-23T20:46:00Z | [
"python",
"rss",
"feedparser"
] |
Why can't a Deferred be passed to a callback in Python Twisted? | 2,321,577 | <pre><code>d = Deferred()
d.callback(Deferred()) # Assertion error saying that a Deferred shouldn't be passed
</code></pre>
<p>Why is this? I looked through the code and commit messages / Trac and see no reason why this should be the case. The most obvious way to bypass this is to put the <code>Deferred</code> in a tu... | 2 | 2010-02-23T20:46:09Z | 2,338,651 | <p>There are two related reasons for this.</p>
<p>First, it helps catch what is likely a mistake early - near the place where the mistake is being made. A Deferred is called back with a result which is then passed to all of its callbacks. If you make the result itself a Deferred, then there's not much these callback... | 5 | 2010-02-26T00:22:06Z | [
"python",
"twisted",
"deferred-execution"
] |
Automatically prompt to update default site domain name when running Djangoâs ./manage.py syncdb? | 2,321,771 | <p>Regarding Django Sites module and manage.py syncdb</p>
<p>The Auth module can prompt to ask for default superuser for the admin site, during .\manage.py syncdb. I would like to see similar things happen for the default site domain name. Currently it is example.com, hardcoded unless I use admin web site to change it... | 3 | 2010-02-23T21:14:17Z | 2,322,165 | <p>You can do this yourself:</p>
<ol>
<li>Create a management command to prompt for your new site</li>
<li>connect it to the <code>post_syncdb</code> signal</li>
</ol>
<p>The command will let you set the site conveniently from the command line. Connecting it to the signal will mean you get prompted whenever the <code... | 4 | 2010-02-23T22:12:37Z | [
"python",
"django",
"django-sites"
] |
Automatically prompt to update default site domain name when running Djangoâs ./manage.py syncdb? | 2,321,771 | <p>Regarding Django Sites module and manage.py syncdb</p>
<p>The Auth module can prompt to ask for default superuser for the admin site, during .\manage.py syncdb. I would like to see similar things happen for the default site domain name. Currently it is example.com, hardcoded unless I use admin web site to change it... | 3 | 2010-02-23T21:14:17Z | 2,322,507 | <p>I made a small django app that can be plugged in and play. To plug it in:</p>
<ol>
<li>download it into project directory or into where your project can find.</li>
<li>add, in your settings.py INSTALLED_APPS, "site_default" (the app name) at the end or after "django.contrib.sites" that it depends on.</li>
<li>Run <... | 6 | 2010-02-23T23:12:03Z | [
"python",
"django",
"django-sites"
] |
Does setup.py's extras_require keyword support comma-separated extras? | 2,321,798 | <p>Setuptools lets you list requirements for optional features</p>
<pre><code># mypackage
'extras_require' : { 'PDF' : ['reportlab'], 'DOCX' : ['docxlib'] }
</code></pre>
<p>and another package can specify <code>'requires' : [ 'mypackage[PDF]' ]</code>.</p>
<p>If another package wants to require more than one extra ... | 1 | 2010-02-23T21:17:37Z | 2,876,301 | <p>from: <a href="http://peak.telecommunity.com/DevCenter/setuptools#declaring-dependencies" rel="nofollow">http://peak.telecommunity.com/DevCenter/setuptools#declaring-dependencies</a></p>
<p>setuptools and pkg_resources use a common syntax for specifying a project's required dependencies. This syntax consists of a p... | 4 | 2010-05-20T17:31:29Z | [
"python",
"setuptools",
"distutils"
] |
Is it possible to write dynamic web pages in Python with the Really Simple HTTP Server? | 2,321,813 | <p>I know that with the SimpleHTTPServer I can make my directories accessible by web-browsers via Internet. So, I run just one line of the code and, as a result, another person working on another computer can use his/her browser to see content of my directories.</p>
<p>But I wander if I can make more complicated thing... | 1 | 2010-02-23T21:19:46Z | 2,321,892 | <p>Yes, you can set your code up like <a href="http://www.blendedtechnologies.com/python-trick-really-little-http-server/220" rel="nofollow">this</a> and intercept the requests yourself. However, you will have to parse the URL's yourself. Not really a big deal if you do not have that many, but it is work...</p>
| 2 | 2010-02-23T21:31:30Z | [
"python",
"post",
"get",
"webserver",
"simplehttpserver"
] |
Is it possible to write dynamic web pages in Python with the Really Simple HTTP Server? | 2,321,813 | <p>I know that with the SimpleHTTPServer I can make my directories accessible by web-browsers via Internet. So, I run just one line of the code and, as a result, another person working on another computer can use his/her browser to see content of my directories.</p>
<p>But I wander if I can make more complicated thing... | 1 | 2010-02-23T21:19:46Z | 2,321,917 | <p>While it is possible, you have to do pretty much everything yourself (parsing request parameters, handle routing, etc).</p>
<p>If you are not looking to get experience in creating web-frameworks, but just want to create a small site you should probably use a minimalistic framework instead.</p>
<p>Try Bottle, a sim... | 4 | 2010-02-23T21:35:34Z | [
"python",
"post",
"get",
"webserver",
"simplehttpserver"
] |
Is it possible to write dynamic web pages in Python with the Really Simple HTTP Server? | 2,321,813 | <p>I know that with the SimpleHTTPServer I can make my directories accessible by web-browsers via Internet. So, I run just one line of the code and, as a result, another person working on another computer can use his/her browser to see content of my directories.</p>
<p>But I wander if I can make more complicated thing... | 1 | 2010-02-23T21:19:46Z | 2,322,009 | <p>Maybe the <a href="http://code.activestate.com/recipes/tags/_versematch_/" rel="nofollow">VerseMatch</a> project and related recipes over at ActiveState is something you would be interested in examining? It implements a small application using the standard library for dynamic running.</p>
| 0 | 2010-02-23T21:48:53Z | [
"python",
"post",
"get",
"webserver",
"simplehttpserver"
] |
Is it possible to write dynamic web pages in Python with the Really Simple HTTP Server? | 2,321,813 | <p>I know that with the SimpleHTTPServer I can make my directories accessible by web-browsers via Internet. So, I run just one line of the code and, as a result, another person working on another computer can use his/her browser to see content of my directories.</p>
<p>But I wander if I can make more complicated thing... | 1 | 2010-02-23T21:19:46Z | 8,673,542 | <p>have you considered using CGIHTTPServer instead of SimpleHTTPServer? Then you can toss your scripts in cgi-bin and they'll execute. You have to include content-type header and whatnot but if you're looking for quick and dirty it's real convenient</p>
| 0 | 2011-12-29T21:13:41Z | [
"python",
"post",
"get",
"webserver",
"simplehttpserver"
] |
Certain Python commands aren't caught in Stdout | 2,321,868 | <p>I've written a simple program that captures and executes command line Python scripts, but there is a problem. The text passed to a Python input function isn't written to my program despite my program capturing stdout.</p>
<p>For example:
The Python script:</p>
<pre><code>import sys
print("Hello, World!")
x = inp... | 1 | 2010-02-23T21:27:41Z | 2,322,030 | <p>Smells like the Python i/o is line buffered, i.e. waits for a CRLF then sends a whole line at once. You could try turning that off (<em>python -u myscript.py</em>, or set the <em>PYTHONUNBUFFERED</em> environment variable) or work around it with something like this:</p>
<pre><code>print("Hello, World!")
print("Plea... | 1 | 2010-02-23T21:52:08Z | [
"c#",
"python",
"input",
"stdout"
] |
Certain Python commands aren't caught in Stdout | 2,321,868 | <p>I've written a simple program that captures and executes command line Python scripts, but there is a problem. The text passed to a Python input function isn't written to my program despite my program capturing stdout.</p>
<p>For example:
The Python script:</p>
<pre><code>import sys
print("Hello, World!")
x = inp... | 1 | 2010-02-23T21:27:41Z | 2,322,230 | <p>It's difficult to tell because I'm using python 2.6 and you appear to be using 3.x, and I also have not programmed in c# for quite awhile but my guess is that this line:</p>
<pre><code>sw.WriteLine(txtInput.Text);
</code></pre>
<p>Is sending "3" plus a windows new line character.</p>
<p>Try:</p>
<pre><code>sw.Wr... | 1 | 2010-02-23T22:24:45Z | [
"c#",
"python",
"input",
"stdout"
] |
Problem using easy_install on Windows 7, 64 bit. (cannot find python.exe) | 2,321,872 | <p>I have just now installed Python 2.6 on my Windows 7 (64 bit) Lenovo t61p laptop. </p>
<p>I have downloaded <a href="http://sphinx.pocoo.org/">Sphinx</a> and <a href="http://somethingaboutorange.com/mrl/projects/nose/0.11.1/">nose</a> and apparently installed them correctly using</p>
<pre><code>python setup.py in... | 9 | 2010-02-23T21:27:55Z | 2,326,785 | <p>I don't know anything about these specific packages so I may not be much help. But for what it's worth I have run into the "can't find python executable" errors before with 64 bit python. It happened when the package I was trying to install didn't have a 64 bit version and it was looking for 32 bit python. I ende... | 6 | 2010-02-24T14:44:03Z | [
"python",
"windows-7",
"mongodb",
"easy-install"
] |
Problem using easy_install on Windows 7, 64 bit. (cannot find python.exe) | 2,321,872 | <p>I have just now installed Python 2.6 on my Windows 7 (64 bit) Lenovo t61p laptop. </p>
<p>I have downloaded <a href="http://sphinx.pocoo.org/">Sphinx</a> and <a href="http://somethingaboutorange.com/mrl/projects/nose/0.11.1/">nose</a> and apparently installed them correctly using</p>
<pre><code>python setup.py in... | 9 | 2010-02-23T21:27:55Z | 2,328,061 | <p>can't help much with easy_install - but python setup.py install should work w/ pymongo. what was the stack trace?</p>
| 0 | 2010-02-24T17:31:05Z | [
"python",
"windows-7",
"mongodb",
"easy-install"
] |
Problem using easy_install on Windows 7, 64 bit. (cannot find python.exe) | 2,321,872 | <p>I have just now installed Python 2.6 on my Windows 7 (64 bit) Lenovo t61p laptop. </p>
<p>I have downloaded <a href="http://sphinx.pocoo.org/">Sphinx</a> and <a href="http://somethingaboutorange.com/mrl/projects/nose/0.11.1/">nose</a> and apparently installed them correctly using</p>
<pre><code>python setup.py in... | 9 | 2010-02-23T21:27:55Z | 5,175,933 | <p>Install this 64-bit version of setuptools instead.</p>
<p><a href="http://www.lfd.uci.edu/~gohlke/pythonlibs/#setuptools" rel="nofollow">http://www.lfd.uci.edu/~gohlke/pythonlibs/#setuptools</a></p>
| 0 | 2011-03-03T02:17:55Z | [
"python",
"windows-7",
"mongodb",
"easy-install"
] |
assign output of print to a variable in python | 2,321,939 | <p>i want to know how to assign the output of print to a variable. </p>
<p>so if </p>
<pre><code>mystring = "a=\'12\'"
</code></pre>
<p>then </p>
<pre><code>print mystring
a=12
</code></pre>
<p>and i want to pass this like **kwargs,</p>
<pre><code>test(mystring)
</code></pre>
<p>how can i do this?</p>
<p>for... | 2 | 2010-02-23T21:39:18Z | 2,321,965 | <p>Redirect <code>stdout</code> and capture its output in an object?</p>
<pre><code>import sys
# a simple class with a write method
class WritableObject:
def __init__(self):
self.content = []
def write(self, string):
self.content.append(string)
# example with redirection of sys.stdout
foo = W... | 6 | 2010-02-23T21:42:33Z | [
"python"
] |
assign output of print to a variable in python | 2,321,939 | <p>i want to know how to assign the output of print to a variable. </p>
<p>so if </p>
<pre><code>mystring = "a=\'12\'"
</code></pre>
<p>then </p>
<pre><code>print mystring
a=12
</code></pre>
<p>and i want to pass this like **kwargs,</p>
<pre><code>test(mystring)
</code></pre>
<p>how can i do this?</p>
<p>for... | 2 | 2010-02-23T21:39:18Z | 2,321,997 | <p>I believe one of these two things will accomplish what you're looking for:</p>
<p>The Python exec statement: <a href="http://docs.python.org/reference/simple_stmts.html#exec" rel="nofollow">http://docs.python.org/reference/simple_stmts.html#exec</a>
or the Python eval function: <a href="http://docs.python.org/libra... | 0 | 2010-02-23T21:46:43Z | [
"python"
] |
assign output of print to a variable in python | 2,321,939 | <p>i want to know how to assign the output of print to a variable. </p>
<p>so if </p>
<pre><code>mystring = "a=\'12\'"
</code></pre>
<p>then </p>
<pre><code>print mystring
a=12
</code></pre>
<p>and i want to pass this like **kwargs,</p>
<pre><code>test(mystring)
</code></pre>
<p>how can i do this?</p>
<p>for... | 2 | 2010-02-23T21:39:18Z | 2,322,002 | <p>You can call <code>__str__</code> and <code>__repr__</code> on python objects to get their string representations (there's a tiny difference between them, so consult the docs). That's actually done by <code>print</code> internally.</p>
| 2 | 2010-02-23T21:47:24Z | [
"python"
] |
assign output of print to a variable in python | 2,321,939 | <p>i want to know how to assign the output of print to a variable. </p>
<p>so if </p>
<pre><code>mystring = "a=\'12\'"
</code></pre>
<p>then </p>
<pre><code>print mystring
a=12
</code></pre>
<p>and i want to pass this like **kwargs,</p>
<pre><code>test(mystring)
</code></pre>
<p>how can i do this?</p>
<p>for... | 2 | 2010-02-23T21:39:18Z | 2,322,132 | <p>for more of an explanation:
i have a list of strings i got from a a comment line of a data file.
it looks like this:</p>
<pre><code>"a='0.015in' lPrime='0.292' offX='45um' offY='75um' sPrime='0.393' twistLength='0'",
"a='0.015in' lPrime='0.292' offX='60um' offY='75um' sPrime='0.393' twistLength='0'",
"a='0.01... | 0 | 2010-02-23T22:06:49Z | [
"python"
] |
assign output of print to a variable in python | 2,321,939 | <p>i want to know how to assign the output of print to a variable. </p>
<p>so if </p>
<pre><code>mystring = "a=\'12\'"
</code></pre>
<p>then </p>
<pre><code>print mystring
a=12
</code></pre>
<p>and i want to pass this like **kwargs,</p>
<pre><code>test(mystring)
</code></pre>
<p>how can i do this?</p>
<p>for... | 2 | 2010-02-23T21:39:18Z | 2,322,157 | <p>If you have a string 'my_string' like this:</p>
<pre><code>a=123 b=456 c='hello'
</code></pre>
<p>Then you can pass it to a function 'my_fun' like this:</p>
<pre><code>my_fun(**eval('{' + my_string.replace(' ', ',') + '}'))
</code></pre>
<p>Depending on the precise formatting of my_string, you may have to vary t... | 0 | 2010-02-23T22:11:11Z | [
"python"
] |
assign output of print to a variable in python | 2,321,939 | <p>i want to know how to assign the output of print to a variable. </p>
<p>so if </p>
<pre><code>mystring = "a=\'12\'"
</code></pre>
<p>then </p>
<pre><code>print mystring
a=12
</code></pre>
<p>and i want to pass this like **kwargs,</p>
<pre><code>test(mystring)
</code></pre>
<p>how can i do this?</p>
<p>for... | 2 | 2010-02-23T21:39:18Z | 2,322,614 | <p>I wouldn't do it that way, personally. A far less hackish solution is to build a dictionary from your data first, and then pass it whole to a function as <code>**kwargs</code>. For example (this isn't the most elegant way to do it, but it is illustrative):</p>
<pre><code>import re
remove_non_digits = re.compile(r'... | 0 | 2010-02-23T23:35:05Z | [
"python"
] |
Python passing list as argument | 2,322,068 | <p>If i were to run this code:</p>
<pre><code>def function(y):
y.append('yes')
return y
example = list()
function(example)
print(example)
</code></pre>
<p>Why would it return ['yes'] even though i am not directly changing the variable 'example', and how could I modify the code so that 'example' is not effect... | 16 | 2010-02-23T21:58:02Z | 2,322,079 | <p>Everything is a reference in Python. If you wish to avoid that behavior you would have to create a new copy of the original with <code>list()</code>. If the list contains more references, you'd need to use <a href="http://docs.python.org/library/copy.html">deepcopy()</a></p>
<pre><code>def modify(l):
l.append('HI'... | 34 | 2010-02-23T21:59:56Z | [
"python",
"list",
"function",
"arguments"
] |
Python passing list as argument | 2,322,068 | <p>If i were to run this code:</p>
<pre><code>def function(y):
y.append('yes')
return y
example = list()
function(example)
print(example)
</code></pre>
<p>Why would it return ['yes'] even though i am not directly changing the variable 'example', and how could I modify the code so that 'example' is not effect... | 16 | 2010-02-23T21:58:02Z | 2,322,097 | <p><strong>"Why would it return <code>['yes']</code>"</strong></p>
<p>Because you modified the list, <code>example</code>.</p>
<p><strong>"even though i am not directly changing the variable 'example'."</strong></p>
<p>But you are, you provided the object named by the variable <code>example</code> to the function. ... | 5 | 2010-02-23T22:02:02Z | [
"python",
"list",
"function",
"arguments"
] |
Python passing list as argument | 2,322,068 | <p>If i were to run this code:</p>
<pre><code>def function(y):
y.append('yes')
return y
example = list()
function(example)
print(example)
</code></pre>
<p>Why would it return ['yes'] even though i am not directly changing the variable 'example', and how could I modify the code so that 'example' is not effect... | 16 | 2010-02-23T21:58:02Z | 17,684,311 | <p>The easiest way to modify the code will be add the [:] to the function call.</p>
<pre><code>def function(y):
y.append('yes')
return y
example = list()
function(example[:])
print(example)
</code></pre>
| 7 | 2013-07-16T18:30:01Z | [
"python",
"list",
"function",
"arguments"
] |
Python passing list as argument | 2,322,068 | <p>If i were to run this code:</p>
<pre><code>def function(y):
y.append('yes')
return y
example = list()
function(example)
print(example)
</code></pre>
<p>Why would it return ['yes'] even though i am not directly changing the variable 'example', and how could I modify the code so that 'example' is not effect... | 16 | 2010-02-23T21:58:02Z | 37,971,686 | <p>Its because you called the function before printing the list. If you print the list then call the function and then print the list again, you would get an empty list followed by the appended version. Its in the order of your code.</p>
| 0 | 2016-06-22T14:56:11Z | [
"python",
"list",
"function",
"arguments"
] |
Python template help | 2,322,069 | <p>I'm using App Engine's web-app templating system (similar if not identical to django)</p>
<p>Normally I render templates from my static directory /templates/ as
follows in my main handler: </p>
<pre><code>dirname = os.path.dirname(__file__)
template_file = os.path.join(dirname, os.path.join('templates', template... | 0 | 2010-02-23T21:58:20Z | 2,324,714 | <p>{% include 'dirname/helloworld.html' %}</p>
<p>should work!</p>
| 0 | 2010-02-24T08:58:44Z | [
"python",
"django",
"google-app-engine",
"django-templates"
] |
Python template help | 2,322,069 | <p>I'm using App Engine's web-app templating system (similar if not identical to django)</p>
<p>Normally I render templates from my static directory /templates/ as
follows in my main handler: </p>
<pre><code>dirname = os.path.dirname(__file__)
template_file = os.path.join(dirname, os.path.join('templates', template... | 0 | 2010-02-23T21:58:20Z | 2,326,864 | <p>The webapp framework uses Django 0.9.6 templates. If you're loading templates from a string as you describe above, you need to <a href="http://www.djangoproject.com/documentation/0.96/templates_python/#loader-types" rel="nofollow">configure the template loader</a> so it can find dependencies loaded from files. <a hr... | 3 | 2010-02-24T14:52:38Z | [
"python",
"django",
"google-app-engine",
"django-templates"
] |
How can I interactively explore why a test is failing? | 2,322,093 | <p>I have a test that is failing with: </p>
<pre><code>======================================================================
FAIL: test_register_should_create_UserProfile (APP.forum.tests.test_views.UserTestCAse)
----------------------------------------------------------------------
Traceback (most... | 0 | 2010-02-23T22:01:28Z | 2,322,118 | <p>This doesn't look right.</p>
<pre><code>user = User.objects.get('username'=='john')
</code></pre>
<p>If you want to query, you have to write queries in the style shown in the tutorial</p>
<p><a href="http://docs.djangoproject.com/en/1.1/topics/db/queries/#topics-db-queries" rel="nofollow">http://docs.djangoproj... | 3 | 2010-02-23T22:05:19Z | [
"python",
"django",
"django-testing"
] |
How can I interactively explore why a test is failing? | 2,322,093 | <p>I have a test that is failing with: </p>
<pre><code>======================================================================
FAIL: test_register_should_create_UserProfile (APP.forum.tests.test_views.UserTestCAse)
----------------------------------------------------------------------
Traceback (most... | 0 | 2010-02-23T22:01:28Z | 2,322,483 | <p>If you're getting an unexpected 404, the Django error page would show you the error (assuming DEBUG is True). In which case, you could just <code>print response.content</code> to show that traceback, and cut and paste that into a browser.</p>
<p>Also, don't forget you can break into a running test with the interact... | 2 | 2010-02-23T23:09:16Z | [
"python",
"django",
"django-testing"
] |
Module "duck typing" pitfalls? | 2,322,116 | <p>I just started experimenting with a new technique I name (for the moment at least) "module duck typing".</p>
<p>Example:</p>
<p><strong>Main Module</strong></p>
<pre><code>import somepackage.req ## module required by all others
import abc
import Xyz
</code></pre>
<p><strong>Module <code>abc</code></strong></p>
... | 2 | 2010-02-23T22:04:51Z | 2,322,194 | <p>There might be all kinds of modules imported that contain "req" and you don't know if it's the module you are actually looking for:</p>
<pre><code>>>> import urllib.request
>>> import tst
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "tst.py", line 12,... | 4 | 2010-02-23T22:18:01Z | [
"python",
"design-patterns",
"architecture",
"duck-typing"
] |
Module "duck typing" pitfalls? | 2,322,116 | <p>I just started experimenting with a new technique I name (for the moment at least) "module duck typing".</p>
<p>Example:</p>
<p><strong>Main Module</strong></p>
<pre><code>import somepackage.req ## module required by all others
import abc
import Xyz
</code></pre>
<p><strong>Module <code>abc</code></strong></p>
... | 2 | 2010-02-23T22:04:51Z | 2,322,241 | <p>This technique is dangerous and error prone. It could work with your tests until the day that someone imports a new <code>something.req</code> and gets a confusing, far-off error. (This is in the best case scenario; the current implementation would jump on many other modules.) If you restructure packages, it's easy ... | 1 | 2010-02-23T22:28:17Z | [
"python",
"design-patterns",
"architecture",
"duck-typing"
] |
Module "duck typing" pitfalls? | 2,322,116 | <p>I just started experimenting with a new technique I name (for the moment at least) "module duck typing".</p>
<p>Example:</p>
<p><strong>Main Module</strong></p>
<pre><code>import somepackage.req ## module required by all others
import abc
import Xyz
</code></pre>
<p><strong>Module <code>abc</code></strong></p>
... | 2 | 2010-02-23T22:04:51Z | 2,323,004 | <p>I think this is more like duck typing. I would also recommend using a more unique identifier than "Bus" </p>
<pre><code>def getBus():
""" Locates the Bus for this application """
for mod in sys.modules.values():
if hasattr(mod, 'Bus') and type(mod.Bus) is...: # check other stuff about mod.Bus
... | 0 | 2010-02-24T01:09:28Z | [
"python",
"design-patterns",
"architecture",
"duck-typing"
] |
What version of Python should I be using to develop web applications? | 2,322,176 | <p>Currently I have Python 3.1.1 installed on my system, same version on my server with WSGI 3.0 running on Apache 2.2.</p>
<p>I want to keep using Python 3.1, but I'm finding that lots of libraries/frameworks don't support it yet, namely Django, Pylons, MySQLdb, etc.</p>
<p>I also checked an account I have on a frie... | 3 | 2010-02-23T22:15:11Z | 2,322,212 | <p><strong>"2.6 would be better, but it seems like lots of libraries are still porting over to that"</strong></p>
<p>What? What libraries -- that you need -- are "still porting over to that"?</p>
<p><strong>"3.1 would be the best" "but I'm finding that lots of libraries/frameworks don't support"</strong></p>
<p>Cor... | 1 | 2010-02-23T22:21:34Z | [
"python",
"portability",
"forward-compatibility"
] |
What version of Python should I be using to develop web applications? | 2,322,176 | <p>Currently I have Python 3.1.1 installed on my system, same version on my server with WSGI 3.0 running on Apache 2.2.</p>
<p>I want to keep using Python 3.1, but I'm finding that lots of libraries/frameworks don't support it yet, namely Django, Pylons, MySQLdb, etc.</p>
<p>I also checked an account I have on a frie... | 3 | 2010-02-23T22:15:11Z | 2,322,228 | <p>Begin with Python 2.5 if you're not sure.</p>
<p>Have a look at Google App Engine (based on Django). It's using Python 2.5 and it's free.
However, you will not be able to call scipy (for example) or any libraries with "C" inside.</p>
<p>You will have the greatest amount of portability with Python2.5. Moreover, pyt... | 2 | 2010-02-23T22:24:20Z | [
"python",
"portability",
"forward-compatibility"
] |
What version of Python should I be using to develop web applications? | 2,322,176 | <p>Currently I have Python 3.1.1 installed on my system, same version on my server with WSGI 3.0 running on Apache 2.2.</p>
<p>I want to keep using Python 3.1, but I'm finding that lots of libraries/frameworks don't support it yet, namely Django, Pylons, MySQLdb, etc.</p>
<p>I also checked an account I have on a frie... | 3 | 2010-02-23T22:15:11Z | 2,322,329 | <p>For now, Python 3 is not widely deployed in production. Depends on what you use Python for. If it's just for one off scripts, it will be ok either way, if the idea is to use third party modules, C modules and or deploy painlessly, then settle for any of the 2.4+ versions. Many projects strive to keep 2.3 compativili... | 4 | 2010-02-23T22:44:32Z | [
"python",
"portability",
"forward-compatibility"
] |
What version of Python should I be using to develop web applications? | 2,322,176 | <p>Currently I have Python 3.1.1 installed on my system, same version on my server with WSGI 3.0 running on Apache 2.2.</p>
<p>I want to keep using Python 3.1, but I'm finding that lots of libraries/frameworks don't support it yet, namely Django, Pylons, MySQLdb, etc.</p>
<p>I also checked an account I have on a frie... | 3 | 2010-02-23T22:15:11Z | 6,686,801 | <p>For intranet web apps I had to install python 2.5 (due to combination of wiki, bug tracker, and httpd WSGI compatibility).
For custom web apps I standardized on python 3.2.
Thus I have both installed simultaneously. I write for 3.2 and bring specific libraries up to spec as needed. However large packages which I do... | 0 | 2011-07-13T23:15:39Z | [
"python",
"portability",
"forward-compatibility"
] |
Should a Python generator raise an exception when there are no more elements to yield? | 2,322,342 | <p>Should a Python generator raise an exception when there are no more elements to yield?</p>
<p>Which one?</p>
| 4 | 2010-02-23T22:47:12Z | 2,322,363 | <p>It doesn't have to, but it can raise a <a href="http://docs.python.org/library/exceptions.html#exceptions.StopIteration">StopIteration</a>.</p>
<p>The more normal way to end the iteration is to let the function end and return naturally, or to use a return statement. This will cause a StopIteration to be raised on y... | 8 | 2010-02-23T22:49:45Z | [
"python"
] |
Should a Python generator raise an exception when there are no more elements to yield? | 2,322,342 | <p>Should a Python generator raise an exception when there are no more elements to yield?</p>
<p>Which one?</p>
| 4 | 2010-02-23T22:47:12Z | 2,322,387 | <p>The only time I know that you have to manually raise StopIteration is when you are implementing a next() method on a class to signal that the iterator is terminated. For generators (functions with yield statements in them), the end of the function or a return statement will properly trigger the StopIteration for yo... | 7 | 2010-02-23T22:53:51Z | [
"python"
] |
How do I change permissions to a socket? | 2,322,349 | <p>I am trying to run a simple Python based web server given <a href="http://fragments.turtlemeat.com/pythonwebserver.php">here</a>.</p>
<p>And I get the following error message:</p>
<pre><code>Traceback (most recent call last):
File "webserver.py", line 63, in <module>
main()
File "webserver.py", line ... | 5 | 2010-02-23T22:48:09Z | 2,322,376 | <p>If you want to bind to port numbers < 1024, you need to be root. It's not a firewall
issue; it's enforced by the operating system. Here's <a href="http://www.w3.org/Daemon/User/Installation/PrivilegedPorts.html">a reference from w3.org</a>,
and a <a href="http://unixguide.net/network/socketfaq/4.8.shtml">FAQ entr... | 10 | 2010-02-23T22:51:18Z | [
"python",
"sockets",
"ubuntu",
"webserver",
"firewall"
] |
How do I change permissions to a socket? | 2,322,349 | <p>I am trying to run a simple Python based web server given <a href="http://fragments.turtlemeat.com/pythonwebserver.php">here</a>.</p>
<p>And I get the following error message:</p>
<pre><code>Traceback (most recent call last):
File "webserver.py", line 63, in <module>
main()
File "webserver.py", line ... | 5 | 2010-02-23T22:48:09Z | 2,322,857 | <p>If you want to run on a port under 1024, you'll need to be root. You can open the socket and drop root's permission for the rest of your program by switching to another user.</p>
<p>Most times it's easier to run a real webserver (say nginx) on port 80 and proxy the requests through to your program which you can run... | 1 | 2010-02-24T00:31:30Z | [
"python",
"sockets",
"ubuntu",
"webserver",
"firewall"
] |
SqlAlchemy optimizations for read-only object models | 2,322,437 | <p>I have a complex network of objects being spawned from a sqlite database using sqlalchemy ORM mappings. I have quite a few deeply nested:</p>
<pre><code>for parent in owner.collection:
for child in parent.collection:
for foo in child.collection:
do lots of calcs with foo.property
</code>... | 7 | 2010-02-23T23:01:10Z | 2,322,465 | <p>Try using a single query with JOINs instead of the python loops.</p>
| -1 | 2010-02-23T23:06:51Z | [
"python",
"performance",
"sqlalchemy",
"readonly"
] |
SqlAlchemy optimizations for read-only object models | 2,322,437 | <p>I have a complex network of objects being spawned from a sqlite database using sqlalchemy ORM mappings. I have quite a few deeply nested:</p>
<pre><code>for parent in owner.collection:
for child in parent.collection:
for foo in child.collection:
do lots of calcs with foo.property
</code>... | 7 | 2010-02-23T23:01:10Z | 2,323,106 | <p>You should be able to disable lazy loading on the relationships in question and sqlalchemy will fetch them all in a single query.</p>
| 0 | 2010-02-24T01:47:33Z | [
"python",
"performance",
"sqlalchemy",
"readonly"
] |
SqlAlchemy optimizations for read-only object models | 2,322,437 | <p>I have a complex network of objects being spawned from a sqlite database using sqlalchemy ORM mappings. I have quite a few deeply nested:</p>
<pre><code>for parent in owner.collection:
for child in parent.collection:
for foo in child.collection:
do lots of calcs with foo.property
</code>... | 7 | 2010-02-23T23:01:10Z | 2,323,267 | <p>If you reference a single attribute of a single instance lots of times, a simple trick is to store it in a local variable.</p>
<p>If you want a way to create cheap pure python clones, share the dict object with the original object:</p>
<pre><code>class CheapClone(object):
def __init__(self, original):
... | 7 | 2010-02-24T02:27:53Z | [
"python",
"performance",
"sqlalchemy",
"readonly"
] |
Index and Slice a Generator in Python | 2,322,642 | <p>Lets say I have a generator function that looks like this:</p>
<pre><code>def fib():
x,y = 1,1
while True:
x, y = y, x+y
yield x
</code></pre>
<p>Ideally, I could just use <em>fib()[10]</em> or <em>fib()[2:12:2]</em> to get indexes and slices, but currently I have to use itertools for these... | 26 | 2010-02-23T23:44:34Z | 2,322,711 | <pre><code>import itertools
class Indexable(object):
def __init__(self,it):
self.it = iter(it)
def __iter__(self):
return self.it
def __getitem__(self,index):
try:
return next(itertools.islice(self.it,index,index+1))
except TypeError:
return list(iter... | 30 | 2010-02-23T23:58:23Z | [
"python",
"generator"
] |
Index and Slice a Generator in Python | 2,322,642 | <p>Lets say I have a generator function that looks like this:</p>
<pre><code>def fib():
x,y = 1,1
while True:
x, y = y, x+y
yield x
</code></pre>
<p>Ideally, I could just use <em>fib()[10]</em> or <em>fib()[2:12:2]</em> to get indexes and slices, but currently I have to use itertools for these... | 26 | 2010-02-23T23:44:34Z | 2,322,812 | <p>So based off the code from ~unutbu and adding in a little itertools.tee:</p>
<pre><code>import itertools
class Indexable(object):
def __init__(self, it):
self.it = it
def __iter__(self):
self.it, cpy = itertools.tee(self.it)
return cpy
def __getitem__(self, index):
sel... | 0 | 2010-02-24T00:19:37Z | [
"python",
"generator"
] |
Index and Slice a Generator in Python | 2,322,642 | <p>Lets say I have a generator function that looks like this:</p>
<pre><code>def fib():
x,y = 1,1
while True:
x, y = y, x+y
yield x
</code></pre>
<p>Ideally, I could just use <em>fib()[10]</em> or <em>fib()[2:12:2]</em> to get indexes and slices, but currently I have to use itertools for these... | 26 | 2010-02-23T23:44:34Z | 2,322,890 | <p>If it's a 1-use slice than you could simply use the method written by ~unutbu. If you need to slice multiple times you would have to store all the intermediate values so you can "rewind" the iterator. Since iterators can iterate anything it would not have a rewind method by default.</p>
<p>Also, since a rewinding i... | 0 | 2010-02-24T00:41:18Z | [
"python",
"generator"
] |
Index and Slice a Generator in Python | 2,322,642 | <p>Lets say I have a generator function that looks like this:</p>
<pre><code>def fib():
x,y = 1,1
while True:
x, y = y, x+y
yield x
</code></pre>
<p>Ideally, I could just use <em>fib()[10]</em> or <em>fib()[2:12:2]</em> to get indexes and slices, but currently I have to use itertools for these... | 26 | 2010-02-23T23:44:34Z | 2,322,909 | <p>Here is ~unutbu's answer modified to subclass list. Obviously abuse such as <code>append</code>, <code>insert</code> etc. will produce weird results!</p>
<p>you do get <code>__str__</code> and <code>__repr__</code> methods for free though</p>
<pre><code>import itertools
class Indexable(list):
def __init__(self... | 0 | 2010-02-24T00:44:42Z | [
"python",
"generator"
] |
Django array or list output? | 2,322,739 | <p>I'm pulling a set of image urls and their respective titles. I've tried creating a hash or associative array, but the data seems to overwrite so I only end up with the last item in the array.</p>
<p>For example;</p>
<pre><code>thumbnail_list = []
for file in media:
thumbnail_list['url'] = file.url
thumbna... | 4 | 2010-02-24T00:02:44Z | 2,322,762 | <p>You want a <a href="http://docs.python.org/tutorial/datastructures.html#dictionaries" rel="nofollow">dict</a>, which is Python's associative data structure, whereas you are creating a list. </p>
<p>But I'm not sure I understand your problem. Why not just pass your <code>media</code> collection into the template a... | 4 | 2010-02-24T00:07:13Z | [
"python",
"django",
"hash",
"associative-array"
] |
How can I disable the webbrowser message in python? | 2,323,080 | <p>In my python program, when I send the user to create a gmail account by use of the webbrowser module, python displays:</p>
<p>"Please enter your Gmail username: Created new window in existing browser session."</p>
<p>Is there any way to get rid of "created new window in existing browser session", as it takes up th... | 9 | 2010-02-24T01:40:29Z | 2,323,563 | <p>As S.Lott hints in a comment, you should probably do the <code>raw_input</code> first; however, that, per se, doesn't suppress the message from <code>webbrowser</code>, as you ask -- it just postpones it.</p>
<p>To actually <em>suppress</em> the message, you can temporarily redirect standard-output or standard-erro... | 10 | 2010-02-24T03:53:04Z | [
"python",
"browser"
] |
How can I disable the webbrowser message in python? | 2,323,080 | <p>In my python program, when I send the user to create a gmail account by use of the webbrowser module, python displays:</p>
<p>"Please enter your Gmail username: Created new window in existing browser session."</p>
<p>Is there any way to get rid of "created new window in existing browser session", as it takes up th... | 9 | 2010-02-24T01:40:29Z | 19,199,794 | <p>There is an <a href="http://stackoverflow.com/a/1352392/1904815">answer to another question</a> that is relevant here.</p>
<p>You can use</p>
<pre><code>webbrowser.get().open('https://www.google.com/accounts/NewAccount?service=mail')
</code></pre>
<p>I have xdg-open installed (Linux), which led to a message <em>S... | 1 | 2013-10-05T16:08:33Z | [
"python",
"browser"
] |
Convert string in base64 to image and save on filesystem in Python | 2,323,128 | <p>I have a string in base64 format, which represents PNG image. Is there a way to save this image to the filesystem, as a PNG file?</p>
<hr>
<p>I encoded the image using flex. Actually this is what I get on server
(can't see any image after any of proposed methods :( )</p>
<pre><code>iVBORw0KGgoAAAANSUhEUgAABoIAAAa... | 34 | 2010-02-24T01:52:32Z | 2,323,134 | <p>You could probably use the <a href="http://packages.python.org/pypng/png.html" rel="nofollow">PyPNG package's <code>png.Reader</code> object</a> to do this - decode the base64 string into a regular string (via the <code>base64</code> standard library), and pass it to the constructor.</p>
| 0 | 2010-02-24T01:54:28Z | [
"python",
"image"
] |
Convert string in base64 to image and save on filesystem in Python | 2,323,128 | <p>I have a string in base64 format, which represents PNG image. Is there a way to save this image to the filesystem, as a PNG file?</p>
<hr>
<p>I encoded the image using flex. Actually this is what I get on server
(can't see any image after any of proposed methods :( )</p>
<pre><code>iVBORw0KGgoAAAANSUhEUgAABoIAAAa... | 34 | 2010-02-24T01:52:32Z | 2,323,212 | <p>If the imagestr was bitmap data (which we now know it isn't) you could use this</p>
<p><code>imagestr</code> is the base64 encoded string<br>
<code>width</code> is the width of the image<br>
<code>height</code> is the height of the image </p>
<pre><code>from PIL import Image
from base64 import decodestring
image... | 7 | 2010-02-24T02:11:23Z | [
"python",
"image"
] |
Convert string in base64 to image and save on filesystem in Python | 2,323,128 | <p>I have a string in base64 format, which represents PNG image. Is there a way to save this image to the filesystem, as a PNG file?</p>
<hr>
<p>I encoded the image using flex. Actually this is what I get on server
(can't see any image after any of proposed methods :( )</p>
<pre><code>iVBORw0KGgoAAAANSUhEUgAABoIAAAa... | 34 | 2010-02-24T01:52:32Z | 2,324,133 | <p>Starting with</p>
<pre><code>imgData = b'iVBORw0KGgoAAAANSUhEUgAABoIAAAaCCAYAAAABZu+EAAAqOElEQVR42uzBAQEAAACAkP6v7ggK\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA... | 84 | 2010-02-24T06:34:47Z | [
"python",
"image"
] |
Convert string in base64 to image and save on filesystem in Python | 2,323,128 | <p>I have a string in base64 format, which represents PNG image. Is there a way to save this image to the filesystem, as a PNG file?</p>
<hr>
<p>I encoded the image using flex. Actually this is what I get on server
(can't see any image after any of proposed methods :( )</p>
<pre><code>iVBORw0KGgoAAAANSUhEUgAABoIAAAa... | 34 | 2010-02-24T01:52:32Z | 24,223,036 | <p>You can also save it to a string buffer and then do as you wish with it, </p>
<pre><code>import cStringIO
data = json.loads(request.POST['imgData']) # Getting the object from the post request
image_output = cStringIO.StringIO()
image_output.write(data.decode('base64')) # Write decoded image to buffer
image_outpu... | 2 | 2014-06-14T18:37:36Z | [
"python",
"image"
] |
Is there a Python equivalent of Ruby's 'any?' function? | 2,323,147 | <p>In Ruby, you can call <a href="http://ruby-doc.org/core/classes/Enumerable.html#M003132">Enumerable#any?</a> on a enumerable object to see if any of its elements satisfies the predicate you pass in the block. Like so:</p>
<pre><code>lst.any?{|e| pred(e) }
</code></pre>
<p>In Python, there's an <code>any</code> fun... | 7 | 2010-02-24T01:58:11Z | 2,323,165 | <pre><code>any(pred(x) for x in lst)
</code></pre>
<p>alternatively</p>
<pre><code>from itertools import imap
any(imap(pred, lst))
</code></pre>
| 20 | 2010-02-24T02:02:18Z | [
"python",
"ruby",
"list"
] |
Floating Point Modulo Problem | 2,323,291 | <p>I've stumbled onto a very strange bug. Read the comments in the code to see what the bug is exactly, but essentially a variable modulo 1 is returning 1 (but it doesn't equal 1!). I'm assuming there is a display problem where the float is extremely close to one but not exactly. However, it should be moduloing to zero... | 1 | 2010-02-24T02:33:03Z | 2,323,298 | <p>Welcome to IEEE754, <a href="http://en.wikipedia.org/wiki/Floating_point#Accuracy_problems">enjoy your stay</a>.</p>
| 6 | 2010-02-24T02:35:05Z | [
"python",
"floating-point",
"floating-accuracy"
] |
Floating Point Modulo Problem | 2,323,291 | <p>I've stumbled onto a very strange bug. Read the comments in the code to see what the bug is exactly, but essentially a variable modulo 1 is returning 1 (but it doesn't equal 1!). I'm assuming there is a display problem where the float is extremely close to one but not exactly. However, it should be moduloing to zero... | 1 | 2010-02-24T02:33:03Z | 2,323,353 | <p>Print doesn't show the full precision of the number as stored, you can use <code>repr()</code> to do that</p>
<pre><code>>>> last=72.99999999999999
>>> print last, 1, type(last), last % 1, last - int(last)
73.0 1 <type 'float'> 1.0 1.0
>>> print last % 1 == 1
False
>>> prin... | 6 | 2010-02-24T02:53:34Z | [
"python",
"floating-point",
"floating-accuracy"
] |
Floating Point Modulo Problem | 2,323,291 | <p>I've stumbled onto a very strange bug. Read the comments in the code to see what the bug is exactly, but essentially a variable modulo 1 is returning 1 (but it doesn't equal 1!). I'm assuming there is a display problem where the float is extremely close to one but not exactly. However, it should be moduloing to zero... | 1 | 2010-02-24T02:33:03Z | 2,323,384 | <p>If you need arbitrary precision, there are some projects out there that do just that. <a href="http://gmpy.sourceforge.net/" rel="nofollow">gmpy</a> handles multi-precision integers, <a href="http://code.google.com/p/mpmath/" rel="nofollow">mpmath</a> which looks quite good and <a href="http://pypi.python.org/pypi/b... | 0 | 2010-02-24T03:02:53Z | [
"python",
"floating-point",
"floating-accuracy"
] |
Floating Point Modulo Problem | 2,323,291 | <p>I've stumbled onto a very strange bug. Read the comments in the code to see what the bug is exactly, but essentially a variable modulo 1 is returning 1 (but it doesn't equal 1!). I'm assuming there is a display problem where the float is extremely close to one but not exactly. However, it should be moduloing to zero... | 1 | 2010-02-24T02:33:03Z | 2,324,601 | <p>You could try the <a href="http://docs.python.org/library/math.html#math.fmod" rel="nofollow">math.fmod</a> function instead of <code>last % 1</code>, maybe it is better suited for you problem.
Or you could reformulate you problem in integer space.</p>
<p>Anyway, it is not good practice to compare float values usin... | 1 | 2010-02-24T08:33:34Z | [
"python",
"floating-point",
"floating-accuracy"
] |
Floating Point Modulo Problem | 2,323,291 | <p>I've stumbled onto a very strange bug. Read the comments in the code to see what the bug is exactly, but essentially a variable modulo 1 is returning 1 (but it doesn't equal 1!). I'm assuming there is a display problem where the float is extremely close to one but not exactly. However, it should be moduloing to zero... | 1 | 2010-02-24T02:33:03Z | 2,326,042 | <p>You should use math.fmod(x, y). Here's an excerpt from <a href="http://docs.python.org/library/math.html" rel="nofollow">http://docs.python.org/library/math.html</a>:</p>
<p>"Note that the Python expression x % y may not return the same result. The intent of the C standard is that fmod(x, y) be exactly (mathematica... | 3 | 2010-02-24T12:47:00Z | [
"python",
"floating-point",
"floating-accuracy"
] |
How to calculate a value to a certain number of decimal places? | 2,323,332 | <p>Using numpy or python's standard library, either or. How can I take a value with several decimal places and truncate it to 4 decimal places? I only want to compare floating point numbers to their first 4 decimal points.</p>
| 1 | 2010-02-24T02:47:43Z | 2,323,342 | <p>you can use <a href="http://docs.python.org/library/decimal.html" rel="nofollow">decimal</a> module, especially the part on <code>getcontext().prec</code></p>
| 1 | 2010-02-24T02:50:16Z | [
"python",
"floating-accuracy"
] |
How to calculate a value to a certain number of decimal places? | 2,323,332 | <p>Using numpy or python's standard library, either or. How can I take a value with several decimal places and truncate it to 4 decimal places? I only want to compare floating point numbers to their first 4 decimal points.</p>
| 1 | 2010-02-24T02:47:43Z | 2,323,355 | <p>If you want to compare two floats, you can compare on <code>abs(a-b) < epsilon</code> where epsilon is your precision requirement.</p>
| 3 | 2010-02-24T02:54:48Z | [
"python",
"floating-accuracy"
] |
How to calculate a value to a certain number of decimal places? | 2,323,332 | <p>Using numpy or python's standard library, either or. How can I take a value with several decimal places and truncate it to 4 decimal places? I only want to compare floating point numbers to their first 4 decimal points.</p>
| 1 | 2010-02-24T02:47:43Z | 2,323,356 | <p>round(a_float, 4)</p>
<pre><code>>>> help(round)
Help on built-in function round in module __builtin__:
round(...)
round(number[, ndigits]) -> floating point number
Round a number to a given precision in decimal digits (default 0 digits).
This always returns a floating point number. Preci... | 6 | 2010-02-24T02:54:58Z | [
"python",
"floating-accuracy"
] |
How to calculate a value to a certain number of decimal places? | 2,323,332 | <p>Using numpy or python's standard library, either or. How can I take a value with several decimal places and truncate it to 4 decimal places? I only want to compare floating point numbers to their first 4 decimal points.</p>
| 1 | 2010-02-24T02:47:43Z | 2,323,359 | <pre><code>>>> round(1.2345678,4) == round(1.2345999,4)
True
</code></pre>
| 2 | 2010-02-24T02:55:47Z | [
"python",
"floating-accuracy"
] |
django+flex: Debugging strategies | 2,323,371 | <p>I love django, and I like flex. Django for it's cool debugging system (those yellow pages helps a lot to find bugs in my code), and flex for it possibilities.</p>
<p>Recently I come across a problem. If I create a form in flex and then communicate with the django server, I can't see any debugging info (when the exc... | 0 | 2010-02-24T02:59:35Z | 2,323,428 | <p>I've used firebug to debug the flex side of things. But I've been using json or XML for communication between the two. Since flash uses the browser to do the network stuff, the request should be visible in the net tab of firebug.</p>
<p>To debug the django side of things, you have a few options.</p>
<ol>
<li>If yo... | 1 | 2010-02-24T03:13:09Z | [
"python",
"django",
"actionscript-3"
] |
zip() alternative for iterating through two iterables | 2,323,394 | <p>I have two large (~100 GB) text files that must be iterated through simultaneously.</p>
<p>Zip works well for smaller files but I found out that it's actually making a list of lines from my two files. This means that every line gets stored in memory. I don't need to do anything with the lines more than once.</p>
... | 11 | 2010-02-24T03:04:45Z | 2,323,422 | <p><a href="http://docs.python.org/library/itertools.html"><code>itertools</code></a> has a function <a href="http://docs.python.org/library/itertools.html#itertools.izip"><code>izip</code></a> that does that</p>
<pre><code>from itertools import izip
for i, j in izip(handle1, handle2):
...
</code></pre>
<p>If the... | 19 | 2010-02-24T03:11:49Z | [
"python"
] |
zip() alternative for iterating through two iterables | 2,323,394 | <p>I have two large (~100 GB) text files that must be iterated through simultaneously.</p>
<p>Zip works well for smaller files but I found out that it's actually making a list of lines from my two files. This means that every line gets stored in memory. I don't need to do anything with the lines more than once.</p>
... | 11 | 2010-02-24T03:04:45Z | 2,323,432 | <p>Something like this? Wordy, but it seems to be what you're asking for.</p>
<p>It can be adjusted to do things like a proper merge to match keys between the two files, which is often more what's needed than the simplistic zip function. Also, this doesn't truncate, which is what the SQL OUTER JOIN algorithm does, a... | -1 | 2010-02-24T03:13:27Z | [
"python"
] |
zip() alternative for iterating through two iterables | 2,323,394 | <p>I have two large (~100 GB) text files that must be iterated through simultaneously.</p>
<p>Zip works well for smaller files but I found out that it's actually making a list of lines from my two files. This means that every line gets stored in memory. I don't need to do anything with the lines more than once.</p>
... | 11 | 2010-02-24T03:04:45Z | 2,323,447 | <p>If you want to truncate to the shortest file:</p>
<pre><code>handle1 = open('filea', 'r')
handle2 = open('fileb', 'r')
try:
while 1:
i = handle1.next()
j = handle2.next()
do something with i and j.
write to an output file.
except StopIteration:
pass
finally:
handle1.c... | 0 | 2010-02-24T03:15:14Z | [
"python"
] |
zip() alternative for iterating through two iterables | 2,323,394 | <p>I have two large (~100 GB) text files that must be iterated through simultaneously.</p>
<p>Zip works well for smaller files but I found out that it's actually making a list of lines from my two files. This means that every line gets stored in memory. I don't need to do anything with the lines more than once.</p>
... | 11 | 2010-02-24T03:04:45Z | 2,323,522 | <p>You can use <strong>izip_longest</strong> like this to pad the shorter file with empty lines</p>
<p>in <strong>python 2.6</strong></p>
<pre><code>from itertools import izip_longest
with handle1 as open('filea', 'r'):
with handle2 as open('fileb', 'r'):
for i, j in izip_longest(handle1, handle2, fillva... | 14 | 2010-02-24T03:38:16Z | [
"python"
] |
Problem originating SSH tunnels from python | 2,323,471 | <p>The object is to set up n number of ssh tunnels between satellite servers and a centralized registry database. I have already set up public key authentication between my servers so they just log right in without password prompts. Now what ? I've tried Paramiko. It seems decent but gets pretty complicated just to set... | 2 | 2010-02-24T03:24:05Z | 2,323,508 | <p>Is there a special reason not to just do it with <code>ssh</code>, the usual</p>
<pre><code>(ssh -L <localport>:localhost:<remoteport> <remotehost>)
</code></pre>
<p>minuet? Anyway, <a href="http://bazaar.launchpad.net/~robey/paramiko/trunk/annotate/head%3A/demos/forward.py" rel="nofollow">this ... | 2 | 2010-02-24T03:33:17Z | [
"python",
"ssh",
"tunnel",
"paramiko"
] |
Problem originating SSH tunnels from python | 2,323,471 | <p>The object is to set up n number of ssh tunnels between satellite servers and a centralized registry database. I have already set up public key authentication between my servers so they just log right in without password prompts. Now what ? I've tried Paramiko. It seems decent but gets pretty complicated just to set... | 2 | 2010-02-24T03:24:05Z | 2,324,512 | <p>Here is a cutdown version of the <a href="http://bazaar.launchpad.net/~robey/paramiko/trunk/annotate/head%3A/demos/forward.py">script</a> that Alex pointed you to.</p>
<p>It simply connects to <strong>192.168.0.8</strong> and forwards port <strong>3389</strong> from <strong>192.168.0.6</strong> to localhost</p>
<p... | 5 | 2010-02-24T08:15:54Z | [
"python",
"ssh",
"tunnel",
"paramiko"
] |
Python drawing on screen | 2,323,640 | <p>I'm coding an application that needs to select an area of the screen. I need to change the cursor to a cross and then draw a rectangle on the user selection. The first thing I searched for is how to manipulate the cursor and I came across wxPython. With wxPython I could easily do this on a Frame with a Panel, the th... | 6 | 2010-02-24T04:18:30Z | 2,323,743 | <p>You shouldn't be using wx.TRANSPARENT in window creation, that is mostly used for wxDC paint commands. To make a window transparent just call win.SetTransparent(amount), where amount is from 0-255, 255 means opaque, 0 means totally transparent. see <a href="http://www.wxpython.org/docs/api/wx.Window-class.html#SetTr... | 5 | 2010-02-24T04:50:18Z | [
"python",
"wxpython"
] |
Is there any difference between cpython and python | 2,324,208 | <p>I want to know the difference between CPython and Python because I have heard Python is developed in C - then what is the use of CPython?</p>
| 20 | 2010-02-24T06:51:54Z | 2,324,217 | <p>Python is a language.</p>
<p><a href="http://en.wikipedia.org/wiki/CPython">CPython</a> is the default byte-code interpreter of Python, which is written in C.</p>
<p>There is also other implementation of Python such as IronPython (for .NET), Jython (for Java), etc.</p>
| 25 | 2010-02-24T06:53:59Z | [
"python"
] |
Is there any difference between cpython and python | 2,324,208 | <p>I want to know the difference between CPython and Python because I have heard Python is developed in C - then what is the use of CPython?</p>
| 20 | 2010-02-24T06:51:54Z | 2,324,220 | <blockquote>
<p><a href="http://wiki.python.org/moin/CPython">CPython</a> is <strong>Guido van Rossum</strong>'s
reference version of the Python
computing language. It's most often
called simply "Python"; speakers say
"CPython" generally to distinguish it
explicitly from other implementations.</p>
</blockqu... | 11 | 2010-02-24T06:54:36Z | [
"python"
] |
Deploying Django with WSGI: App Import Error | 2,324,219 | <p>I am new in apache, linux and python world. I am trying to deploy django application on apache using WSGI (the recommended way). </p>
<h2>My django project directory structure is as follows...</h2>
<ul>
<li>/</li>
<li>/apache/django.wsgi</li>
<li>/apps/ #I put all my apps in this directory</li>
<li>/apps/providers... | 1 | 2010-02-24T06:54:32Z | 2,325,336 | <p>Try this:</p>
<pre><code>sys.path.insert(0, os.path.join(os.path.abspath(os.path.dirname(__file__)),'..'))
</code></pre>
<p>It puts your project folder at the first position and it uses os.path.join to go one directory up (which might be better on windows).</p>
<p>It might be the case that there is another "apps"... | 0 | 2010-02-24T10:48:11Z | [
"python",
"django",
"apache",
"wsgi"
] |
How to calculate the statistics "t-test" with numpy | 2,324,438 | <p>I'm looking to generate some statistics about a model I created in python. I'd like to generate the t-test on it, but was wondering if there was an easy way to do this with numpy/scipy. Are there any good explanations around?</p>
<p>For example, I have three related datasets that look like this: </p>
<pre><code>... | 18 | 2010-02-24T07:57:10Z | 2,324,487 | <p>In a <a href="http://docs.scipy.org/doc/scipy/reference/stats.html#module-scipy.stats">scipy.stats</a> package there are few <code>ttest_...</code> functions. See example from <a href="http://docs.scipy.org/doc/scipy/reference/tutorial/stats.html#t-test-and-ks-test">here</a>:</p>
<pre><code>>>> print 't-st... | 22 | 2010-02-24T08:10:17Z | [
"python",
"statistics",
"numpy",
"scipy"
] |
How to calculate the statistics "t-test" with numpy | 2,324,438 | <p>I'm looking to generate some statistics about a model I created in python. I'd like to generate the t-test on it, but was wondering if there was an easy way to do this with numpy/scipy. Are there any good explanations around?</p>
<p>For example, I have three related datasets that look like this: </p>
<pre><code>... | 18 | 2010-02-24T07:57:10Z | 14,227,297 | <p>Once you get your t-value, you may wonder how to interpret it as a probability -- I did. Here is a function I wrote to help with that.</p>
<p>It's based on info I gleaned from <a href="http://www.vassarstats.net/rsig.html" rel="nofollow">http://www.vassarstats.net/rsig.html</a> and <a href="http://en.wikipedia.org... | -5 | 2013-01-09T02:15:08Z | [
"python",
"statistics",
"numpy",
"scipy"
] |
What is the official name of this construct? | 2,324,453 | <p>In python:</p>
<pre><code>>>> a = b or {}
</code></pre>
| 5 | 2010-02-24T08:01:46Z | 2,324,470 | <p>That's not a special construct, at least to my somewhat tired eyes. It's saying to assign the result of </p>
<pre><code> (b or {})
</code></pre>
<p>to a.</p>
<p>So, if b is a False value, a gets {} (the empty dictionary literal), otherwise it gets the value of b.</p>
| 1 | 2010-02-24T08:05:15Z | [
"python"
] |
What is the official name of this construct? | 2,324,453 | <p>In python:</p>
<pre><code>>>> a = b or {}
</code></pre>
| 5 | 2010-02-24T08:01:46Z | 2,324,472 | <p>I don't think it has an official name, it's just a clever/lazy way to be concise. It's roughly equivalent to:</p>
<pre><code>a = b if b else {}
</code></pre>
<p>or:</p>
<pre><code>if b:
a = b
else:
a = {}
</code></pre>
<p>I wrote this as a comment but I think it's worth mentioning here:</p>
<p>You have ... | 10 | 2010-02-24T08:06:01Z | [
"python"
] |
What is the official name of this construct? | 2,324,453 | <p>In python:</p>
<pre><code>>>> a = b or {}
</code></pre>
| 5 | 2010-02-24T08:01:46Z | 2,324,482 | <p>May be <a href="http://docs.python.org/reference/expressions.html#boolean-operations" rel="nofollow"><code>The expression that return last evaluated argument</code></a>.</p>
| 1 | 2010-02-24T08:08:45Z | [
"python"
] |
What is the official name of this construct? | 2,324,453 | <p>In python:</p>
<pre><code>>>> a = b or {}
</code></pre>
| 5 | 2010-02-24T08:01:46Z | 2,324,524 | <p>Default Assignment Idiom</p>
| 1 | 2010-02-24T08:19:32Z | [
"python"
] |
What is the official name of this construct? | 2,324,453 | <p>In python:</p>
<pre><code>>>> a = b or {}
</code></pre>
| 5 | 2010-02-24T08:01:46Z | 2,324,660 | <p>The expression <code>b or {}</code> is just a simple <a href="http://docs.python.org/reference/expressions.html#boolean-operations" rel="nofollow">boolean OR expression</a>. The special about this is just that this expression does not need return a boolean value per definition like in other languages:</p>
<blockquo... | 2 | 2010-02-24T08:47:07Z | [
"python"
] |
Is line wrap comment possible in Python? | 2,324,483 | <p>I have a long string that I build with a bunch of calculated values. I then write this string to a file.
I have it formatted like:</p>
<pre><code>string = str(a/b)+\
'\t'+str(c)\
'\t'+str(d)\
...
'\n'
</code></pre>
<p>I would like to add comment to what each value represents bu... | 7 | 2010-02-24T08:08:52Z | 2,324,494 | <p>A simple solution is to use parenthesis instead:</p>
<pre><code>string = (str(a/b)+ #this value is something
'\t'+str(c)+ #this value is another thing
'\t'+str(d)+ #and this one too
...
'\n')
</code></pre>
| 7 | 2010-02-24T08:11:48Z | [
"python",
"comments"
] |
Is line wrap comment possible in Python? | 2,324,483 | <p>I have a long string that I build with a bunch of calculated values. I then write this string to a file.
I have it formatted like:</p>
<pre><code>string = str(a/b)+\
'\t'+str(c)\
'\t'+str(d)\
...
'\n'
</code></pre>
<p>I would like to add comment to what each value represents bu... | 7 | 2010-02-24T08:08:52Z | 2,324,598 | <p>How about</p>
<pre><code>string = '\t'.join(map(str,((a/b), #this value is something
c, #this value is another thing
d, #and this one too
)))+'\n'
</code></pre>
<p>Or if you prefer</p>
<pre><code>string = '\t'.joi... | 1 | 2010-02-24T08:32:56Z | [
"python",
"comments"
] |
Problem compiling mod_wsgi on Solaris 10 with Cool Stack 1.3.1 | 2,324,661 | <p>I try to compile mod_wsgi with <a href="http://hub.opensolaris.org/bin/view/Project+webstack/coolstack" rel="nofollow">Cool Stack</a> 1.3.1 on the <a href="http://en.wikipedia.org/wiki/Solaris_%28operating_system%29" rel="nofollow">Solaris</a> platform:</p>
<pre><code>export PATH=/usr/sbin:/usr/bin:/usr/local/bin:/... | 0 | 2010-02-24T08:47:43Z | 2,330,827 | <p>You don't have SUN C/C++ compiler installed. The Cool Stack packages appear to have been built with that compiler and not gcc and in the case of Apache apxs/libtool, that is probably hardwired into the tools. Thus, when those tools are used, they will fail as can't find that compiler.</p>
<p>Note that it is not eno... | 2 | 2010-02-25T00:50:35Z | [
"python",
"apache"
] |
Debugging python programs in emacs | 2,324,758 | <p>How to debug python programs in emacs? </p>
<p>I use python-mode.el</p>
<p>I get reference like
import pdb; pdb.set_trace();</p>
<p>but not sure how to use it.</p>
| 40 | 2010-02-24T09:04:45Z | 2,325,751 | <p>Type <code>M-x cd</code> to change directory to the location of the program you wish to debug.
Type <code>M-x pdb</code>. You'll be prompted with <code>Run pdb (like this): pdb</code>. Enter the name of the program (e.g. <code>test.py</code>). </p>
<p>At the <code>(Pdb)</code> prompt, type <code>help</code> to lear... | 38 | 2010-02-24T12:02:10Z | [
"python",
"debugging",
"emacs",
"pdb"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.