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 listlengths 1 5 |
|---|---|---|---|---|---|---|---|---|---|
How do I run "dot" as a command from Python? | 955,504 | <p>I am using Python on Mac OSX Leopard.</p>
<p>I am trying to run the program 'dot' (part of Graphviz) from Python:</p>
<pre><code># -*- coding: utf-8 -*-
import os
print os.environ['PATH']
print os.system("ls >> a.txt")
print os.system("dot -o9.png -Tpng ./6.dot")
</code></pre>
<p>The command "ls" is there ... | 4 | 2009-06-05T11:55:09Z | 955,616 | <p>Two suggestions</p>
<ol>
<li>Don't use PATH, instead use "which" to just find the executable instead</li>
<li>You don't use ";" (semi-colon) to separate paths, but ":" (colon). Once you change this it should be able to find your dot program.</li>
</ol>
<p>Change this</p>
<pre><code>os.environ['PATH'] += ";"+"/usr... | 2 | 2009-06-05T12:35:39Z | [
"python",
"osx",
"path",
"graphviz",
"dot"
] |
How do I run "dot" as a command from Python? | 955,504 | <p>I am using Python on Mac OSX Leopard.</p>
<p>I am trying to run the program 'dot' (part of Graphviz) from Python:</p>
<pre><code># -*- coding: utf-8 -*-
import os
print os.environ['PATH']
print os.system("ls >> a.txt")
print os.system("dot -o9.png -Tpng ./6.dot")
</code></pre>
<p>The command "ls" is there ... | 4 | 2009-06-05T11:55:09Z | 955,619 | <p>Instead of:</p>
<pre><code>print os.system("dot -o9.png -Tpng ./6.dot")
</code></pre>
<p>try this:</p>
<pre><code>from subprocess import check_call
print check_call("dot -o9.png -Tpng ./6.dot")
</code></pre>
<p>If exit status of dot program is 0, the status is printed. If dot returns non-zero status, it raises C... | 1 | 2009-06-05T12:38:09Z | [
"python",
"osx",
"path",
"graphviz",
"dot"
] |
How do I run "dot" as a command from Python? | 955,504 | <p>I am using Python on Mac OSX Leopard.</p>
<p>I am trying to run the program 'dot' (part of Graphviz) from Python:</p>
<pre><code># -*- coding: utf-8 -*-
import os
print os.environ['PATH']
print os.system("ls >> a.txt")
print os.system("dot -o9.png -Tpng ./6.dot")
</code></pre>
<p>The command "ls" is there ... | 4 | 2009-06-05T11:55:09Z | 955,730 | <p>If you also generate your Dot files in Python, <a href="http://code.google.com/p/pydot/" rel="nofollow">pydot</a> does what you want in a more Pythonic way:</p>
<pre><code>import pydot
dot = pydot.Dot()
n1, n2 = pydot.Node("a"), pydot.Node("b")
dot.add_node(n1)
dot.add_node(n2)
dot.add_edge(pydot.Edge(n1,n2))
dot.w... | 2 | 2009-06-05T13:04:49Z | [
"python",
"osx",
"path",
"graphviz",
"dot"
] |
How do I run "dot" as a command from Python? | 955,504 | <p>I am using Python on Mac OSX Leopard.</p>
<p>I am trying to run the program 'dot' (part of Graphviz) from Python:</p>
<pre><code># -*- coding: utf-8 -*-
import os
print os.environ['PATH']
print os.system("ls >> a.txt")
print os.system("dot -o9.png -Tpng ./6.dot")
</code></pre>
<p>The command "ls" is there ... | 4 | 2009-06-05T11:55:09Z | 955,756 | <p>Often the solution is in front of us,</p>
<pre><code>print os.system("/usr/local/bin/dot -o9.png -Tpng 6.dot")
</code></pre>
<p>Also you can try for all the dots in a specified folder</p>
<pre><code>import glob
for filedot in glob.glob('*.dot')
print os.system("/usr/local/bin/dot -o9.png -Tpng %(filedot)s"%lo... | 2 | 2009-06-05T13:07:52Z | [
"python",
"osx",
"path",
"graphviz",
"dot"
] |
How do I run "dot" as a command from Python? | 955,504 | <p>I am using Python on Mac OSX Leopard.</p>
<p>I am trying to run the program 'dot' (part of Graphviz) from Python:</p>
<pre><code># -*- coding: utf-8 -*-
import os
print os.environ['PATH']
print os.system("ls >> a.txt")
print os.system("dot -o9.png -Tpng ./6.dot")
</code></pre>
<p>The command "ls" is there ... | 4 | 2009-06-05T11:55:09Z | 955,759 | <p>You should change the PATH line so it includes the directory which contains <code>dot</code>. That directory is <code>/usr/local/bin</code>, without <code>/dot</code>.</p>
| 2 | 2009-06-05T13:07:56Z | [
"python",
"osx",
"path",
"graphviz",
"dot"
] |
How do I run "dot" as a command from Python? | 955,504 | <p>I am using Python on Mac OSX Leopard.</p>
<p>I am trying to run the program 'dot' (part of Graphviz) from Python:</p>
<pre><code># -*- coding: utf-8 -*-
import os
print os.environ['PATH']
print os.system("ls >> a.txt")
print os.system("dot -o9.png -Tpng ./6.dot")
</code></pre>
<p>The command "ls" is there ... | 4 | 2009-06-05T11:55:09Z | 955,961 | <p><code>check_call</code> does not use the same syntax as <code>os.system</code>, so you should try changing the corresponding line this way:</p>
<pre><code>print check_call(["dot", "-o9.png", "-Tpng", "./6.dot"])
</code></pre>
<p>The executable name is the first item in the array, and each parameter must be in anot... | 1 | 2009-06-05T13:52:01Z | [
"python",
"osx",
"path",
"graphviz",
"dot"
] |
How do I run "dot" as a command from Python? | 955,504 | <p>I am using Python on Mac OSX Leopard.</p>
<p>I am trying to run the program 'dot' (part of Graphviz) from Python:</p>
<pre><code># -*- coding: utf-8 -*-
import os
print os.environ['PATH']
print os.system("ls >> a.txt")
print os.system("dot -o9.png -Tpng ./6.dot")
</code></pre>
<p>The command "ls" is there ... | 4 | 2009-06-05T11:55:09Z | 956,154 | <p>One problem is in this line:</p>
<pre><code>os.environ['PATH'] += ":"+"/usr/local/bin/dot"
</code></pre>
<p>You don't put the name of the executable in the path, but the directory containing the executable. So that should be:</p>
<pre><code>os.environ['PATH'] += ":"+"/usr/local/bin"
</code></pre>
<p>And as poin... | 1 | 2009-06-05T14:28:02Z | [
"python",
"osx",
"path",
"graphviz",
"dot"
] |
How do I run "dot" as a command from Python? | 955,504 | <p>I am using Python on Mac OSX Leopard.</p>
<p>I am trying to run the program 'dot' (part of Graphviz) from Python:</p>
<pre><code># -*- coding: utf-8 -*-
import os
print os.environ['PATH']
print os.system("ls >> a.txt")
print os.system("dot -o9.png -Tpng ./6.dot")
</code></pre>
<p>The command "ls" is there ... | 4 | 2009-06-05T11:55:09Z | 956,429 | <p>Try this: </p>
<pre><code># -*- coding: utf-8 -*-
import os
import sys
print os.environ['PATH']
os.environ['PATH'] += ":"+"/usr/local/bin"
print os.environ['PATH']
print os.getcwd()
from subprocess import check_call
print check_call(["dot", "-o9.png", "-Tpng", "./6.dot"])
</code></pre>
<p>Taken from the questi... | 3 | 2009-06-05T15:15:33Z | [
"python",
"osx",
"path",
"graphviz",
"dot"
] |
How do I run "dot" as a command from Python? | 955,504 | <p>I am using Python on Mac OSX Leopard.</p>
<p>I am trying to run the program 'dot' (part of Graphviz) from Python:</p>
<pre><code># -*- coding: utf-8 -*-
import os
print os.environ['PATH']
print os.system("ls >> a.txt")
print os.system("dot -o9.png -Tpng ./6.dot")
</code></pre>
<p>The command "ls" is there ... | 4 | 2009-06-05T11:55:09Z | 37,060,175 | <p>If you are using a GUI such as <code>Spyder</code> then you can simply add the correct bin path into the <code>PYTHONPATH manager</code> options menu.</p>
<p>Search for the script location by doing this in the terminal:</p>
<pre><code>which programname
</code></pre>
<p>then take that location (wherever it is), su... | 0 | 2016-05-05T20:59:57Z | [
"python",
"osx",
"path",
"graphviz",
"dot"
] |
Finding out which functions are available from a class instance in python? | 955,533 | <p>How do you dynamically find out which functions have been defined from an instance of a class?</p>
<p>For example:</p>
<pre><code>class A(object):
def methodA(self, intA=1):
pass
def methodB(self, strB):
pass
a = A()
</code></pre>
<p>Ideally I want to find out that the instance 'a' has m... | 1 | 2009-06-05T12:03:20Z | 955,539 | <p>Have a look at the <code>inspect</code> module.</p>
<pre><code>>>> import inspect
>>> inspect.getmembers(a)
[('__class__', <class '__main__.A'>),
('__delattr__', <method-wrapper '__delattr__' of A object at 0xb77d48ac>),
('__dict__', {}),
('__doc__', None),
('__getattribute__',
&... | 11 | 2009-06-05T12:04:51Z | [
"python",
"introspection"
] |
python web framework focusing on json-oriented web applications | 955,751 | <p>I'm looking for a python equivalent of ruby's <a href="http://halcyon.rubyforge.org/" rel="nofollow">halcyon</a> - a framework focused on "web service"-type applications rather than html-page-oriented ones. Google brings up a lot of example code and experiments, but I couldn't find anything that people were using in... | 2 | 2009-06-05T13:07:25Z | 955,828 | <p>Why not use django? You can return a json with it, so it's not a problem. At the same time, you get good, well-tested framework... </p>
| 3 | 2009-06-05T13:22:58Z | [
"python",
"web-services",
"json",
"web-applications"
] |
python web framework focusing on json-oriented web applications | 955,751 | <p>I'm looking for a python equivalent of ruby's <a href="http://halcyon.rubyforge.org/" rel="nofollow">halcyon</a> - a framework focused on "web service"-type applications rather than html-page-oriented ones. Google brings up a lot of example code and experiments, but I couldn't find anything that people were using in... | 2 | 2009-06-05T13:07:25Z | 957,453 | <p>Based on you comment, it sounds like one of the <a href="http://fewagainstmany.com/blog/python-micro-frameworks-are-all-the-rage" rel="nofollow">microframeworks</a> may be what you're looking for.</p>
| 4 | 2009-06-05T18:45:25Z | [
"python",
"web-services",
"json",
"web-applications"
] |
Django models: how to return a default value in case of a non-existing foreign-key relationship? | 955,815 | <p>I am developing a vocabulary training program with Django (German-Swedish). </p>
<p>The app's vocabulary data consists of a large number of "vocabulary cards", each of which contains one or more German words or terms that correspond to one or more Swedish terms.</p>
<p>Training is only available for registered use... | 3 | 2009-06-05T13:19:51Z | 956,533 | <p>This is what methods (and perhaps properties) are for.</p>
<pre><code>class OptionalFKWithDefault( models.Model ):
another = models.ForeignKey( AnotherModel, blank=True, null=True )
@property
def another_score( self ):
if self.another is None:
return 0
else:
retur... | 2 | 2009-06-05T15:32:12Z | [
"python",
"django-models",
"aggregation"
] |
Django models: how to return a default value in case of a non-existing foreign-key relationship? | 955,815 | <p>I am developing a vocabulary training program with Django (German-Swedish). </p>
<p>The app's vocabulary data consists of a large number of "vocabulary cards", each of which contains one or more German words or terms that correspond to one or more Swedish terms.</p>
<p>Training is only available for registered use... | 3 | 2009-06-05T13:19:51Z | 964,393 | <p>This may not be entirely related to your question, but it looks like <code>CardByUser</code> really should be a many-to-many relationship with an extra field. (see <a href="http://docs.djangoproject.com/en/dev/topics/db/models/#extra-fields-on-many-to-many-relationships" rel="nofollow">http://docs.djangoproject.com/... | 1 | 2009-06-08T11:08:48Z | [
"python",
"django-models",
"aggregation"
] |
How to identify whether a file is normal file or directory using python | 955,941 | <p>How do you check whether a file is a normal file or a directory using python?</p>
| 64 | 2009-06-05T13:47:31Z | 955,952 | <p><code>os.path.isdir()</code> and <code>os.path.isfile()</code> should give you what you want. See:
<a href="http://docs.python.org/library/os.path.html">http://docs.python.org/library/os.path.html</a></p>
| 93 | 2009-06-05T13:50:09Z | [
"python"
] |
How to identify whether a file is normal file or directory using python | 955,941 | <p>How do you check whether a file is a normal file or a directory using python?</p>
| 64 | 2009-06-05T13:47:31Z | 955,955 | <pre><code>import os
if os.path.isdir(d):
print "dir"
else:
print "file"
</code></pre>
| 5 | 2009-06-05T13:51:01Z | [
"python"
] |
How to identify whether a file is normal file or directory using python | 955,941 | <p>How do you check whether a file is a normal file or a directory using python?</p>
| 64 | 2009-06-05T13:47:31Z | 955,956 | <p><pre><code>os.path.isdir('string')
os.path.isfile('string')</pre></code></p>
| 2 | 2009-06-05T13:51:32Z | [
"python"
] |
How to identify whether a file is normal file or directory using python | 955,941 | <p>How do you check whether a file is a normal file or a directory using python?</p>
| 64 | 2009-06-05T13:47:31Z | 955,957 | <p>try this:</p>
<pre><code>import os.path
if os.path.isdir("path/to/your/file"):
print "it's a directory"
else:
print "it's a file"
</code></pre>
| 2 | 2009-06-05T13:51:39Z | [
"python"
] |
How to identify whether a file is normal file or directory using python | 955,941 | <p>How do you check whether a file is a normal file or a directory using python?</p>
| 64 | 2009-06-05T13:47:31Z | 956,092 | <p>As other answers have said, <code>os.path.isdir()</code> and <code>os.path.isfile()</code> are what you want. However, you need to keep in mind that these are not the only two cases. Use <code>os.path.islink()</code> for symlinks for instance. Furthermore, these all return <code>False</code> if the file does not ... | 27 | 2009-06-05T14:15:07Z | [
"python"
] |
How to identify whether a file is normal file or directory using python | 955,941 | <p>How do you check whether a file is a normal file or a directory using python?</p>
| 64 | 2009-06-05T13:47:31Z | 31,639,659 | <p>If you're just stepping through a set of directories you might be better just to try <code>os.chdir</code> and give an error/warning if it fails:</p>
<pre><code>import os,sys
for DirName in sys.argv[1:]:
SaveDir = os.getcwd()
try:
os.chdir(DirName)
print "Changed to "+DirName
# Do so... | 0 | 2015-07-26T17:06:16Z | [
"python"
] |
What is the correct way to set Python's locale on Windows? | 955,986 | <p>I'm attempting to sort a list of strings in a locale-aware manner. I've used the Babel library for other i18n-related tasks, but it doesn't support sorting. Python's <code>locale</code> module provides a <code>strcoll</code> function, but requires the locale of the process to be set to the one I want to work with.... | 50 | 2009-06-05T13:56:42Z | 956,084 | <p>It seems you're using Windows. The locale strings are different there. Take a more precise look at the doc:</p>
<pre><code>locale.setlocale(locale.LC_ALL, 'de_DE') # use German locale; name might vary with platform
</code></pre>
<p>On Windows, I think it would be something like:</p>
<pre><code>locale.setlocale(lo... | 62 | 2009-06-05T14:13:18Z | [
"python",
"localization",
"internationalization"
] |
What is the correct way to set Python's locale on Windows? | 955,986 | <p>I'm attempting to sort a list of strings in a locale-aware manner. I've used the Babel library for other i18n-related tasks, but it doesn't support sorting. Python's <code>locale</code> module provides a <code>strcoll</code> function, but requires the locale of the process to be set to the one I want to work with.... | 50 | 2009-06-05T13:56:42Z | 1,395,480 | <p>You should <strong>not pass an explicit locale</strong> to setlocale, it is wrong. Let it find out from the environment. You have to pass it an empty string</p>
<pre><code>import locale
locale.setlocale(locale.LC_ALL, '')
</code></pre>
| 0 | 2009-09-08T18:19:35Z | [
"python",
"localization",
"internationalization"
] |
What is the correct way to set Python's locale on Windows? | 955,986 | <p>I'm attempting to sort a list of strings in a locale-aware manner. I've used the Babel library for other i18n-related tasks, but it doesn't support sorting. Python's <code>locale</code> module provides a <code>strcoll</code> function, but requires the locale of the process to be set to the one I want to work with.... | 50 | 2009-06-05T13:56:42Z | 20,939,063 | <pre><code>def month_name(n):
import datetime, locale
locale.setlocale(locale.LC_ALL, '')
return datetime.datetime.strptime(str(n), "%m").strftime("%B")
</code></pre>
<p>(tested in python 3 and 2.7.6)</p>
| 0 | 2014-01-05T20:56:13Z | [
"python",
"localization",
"internationalization"
] |
What is the correct way to set Python's locale on Windows? | 955,986 | <p>I'm attempting to sort a list of strings in a locale-aware manner. I've used the Babel library for other i18n-related tasks, but it doesn't support sorting. Python's <code>locale</code> module provides a <code>strcoll</code> function, but requires the locale of the process to be set to the one I want to work with.... | 50 | 2009-06-05T13:56:42Z | 23,304,594 | <p>From locale.setlocale docs:</p>
<pre><code>locale.setlocale(category, locale=None):
"""
Set the locale for the given category. The locale can be
a string, an iterable of two strings (language code and encoding),
or None.
""""
</code></pre>
<p>Under Linux (especially Ubuntu) you can either use ... | 5 | 2014-04-25T23:16:46Z | [
"python",
"localization",
"internationalization"
] |
What is the correct way to set Python's locale on Windows? | 955,986 | <p>I'm attempting to sort a list of strings in a locale-aware manner. I've used the Babel library for other i18n-related tasks, but it doesn't support sorting. Python's <code>locale</code> module provides a <code>strcoll</code> function, but requires the locale of the process to be set to the one I want to work with.... | 50 | 2009-06-05T13:56:42Z | 24,485,432 | <p>On Ubuntu you may have this problem because you don't have that local installed on your system.</p>
<p>From shell try a:</p>
<pre><code>$> locale -a
</code></pre>
<p>and check if you find the locale you are interested in. Otherwise you have to install it:</p>
<pre><code>$> sudo apt-get install language-pac... | 10 | 2014-06-30T07:59:59Z | [
"python",
"localization",
"internationalization"
] |
Getting column info in cx_oracle when table is empty? | 956,085 | <p>I am working on an a handler for the python logging module. That essentially logs to an oracle database. </p>
<p>I am using cx_oracle, and something i don't know how to get is the column values when the table is empty.</p>
<pre><code>cursor.execute('select * from FOO')
for row in cursor:
# this is never execut... | 6 | 2009-06-05T14:13:18Z | 957,599 | <p>I think the <a href="http://cx-oracle.readthedocs.org/en/latest/cursor.html#Cursor.description" rel="nofollow"><code>description</code></a> attribute may be what you are looking for. This returns a list of tuples that describe the columns of the data returned. It works quite happily if there are no rows returned, ... | 12 | 2009-06-05T19:11:16Z | [
"python",
"cx-oracle"
] |
python: attributes on a generator object | 956,585 | <p>Is it possible to create an attribute on a generator object?</p>
<p>Here's a very simple example:</p>
<pre><code>def filter(x):
for line in myContent:
if line == x:
yield x
</code></pre>
<p>Now say I have a lot of these filter generator objects floating around... maybe some of them are ano... | 5 | 2009-06-05T15:39:54Z | 956,600 | <p>Yes.</p>
<pre><code>class Filter( object ):
def __init__( self, content ):
self.content = content
def __call__( self, someParam ):
self.someParam = someParam
for line in self.content:
if line == someParam:
yield line
</code></pre>
| 13 | 2009-06-05T15:42:21Z | [
"python"
] |
python: attributes on a generator object | 956,585 | <p>Is it possible to create an attribute on a generator object?</p>
<p>Here's a very simple example:</p>
<pre><code>def filter(x):
for line in myContent:
if line == x:
yield x
</code></pre>
<p>Now say I have a lot of these filter generator objects floating around... maybe some of them are ano... | 5 | 2009-06-05T15:39:54Z | 956,634 | <p>Unfortunately, generator objects (the results returned from calling a generator function) do not support adding arbitrary attributes. You can work around it to some extent by using an external dict indexed by the generator objects, since such objects <em>are</em> usable as keys into a dict. So where you'd <em>like</... | 6 | 2009-06-05T15:48:56Z | [
"python"
] |
python: attributes on a generator object | 956,585 | <p>Is it possible to create an attribute on a generator object?</p>
<p>Here's a very simple example:</p>
<pre><code>def filter(x):
for line in myContent:
if line == x:
yield x
</code></pre>
<p>Now say I have a lot of these filter generator objects floating around... maybe some of them are ano... | 5 | 2009-06-05T15:39:54Z | 956,667 | <p>No. You can't set arbitrary attributes on generators.</p>
<p>As S. Lott points out, you can have a object that <em>looks</em> like a generator, and <em>acts</em> like a generator. And if it looks like a duck, and acts like a duck, you've got yourself the very definition of duck typing, right there.</p>
<p>It won... | 1 | 2009-06-05T15:55:20Z | [
"python"
] |
python: attributes on a generator object | 956,585 | <p>Is it possible to create an attribute on a generator object?</p>
<p>Here's a very simple example:</p>
<pre><code>def filter(x):
for line in myContent:
if line == x:
yield x
</code></pre>
<p>Now say I have a lot of these filter generator objects floating around... maybe some of them are ano... | 5 | 2009-06-05T15:39:54Z | 956,847 | <p>Thinking about the problem, there <em>is</em> a way of having generators carry around a set of attributes. It's a little crazy--I'd strongly recommend Alex Martelli's suggestion instead of this--but it might be useful in some situations.</p>
<pre><code>my_content = ['cat', 'dog days', 'catfish', 'dog', 'catalog']
... | 0 | 2009-06-05T16:28:48Z | [
"python"
] |
python: attributes on a generator object | 956,585 | <p>Is it possible to create an attribute on a generator object?</p>
<p>Here's a very simple example:</p>
<pre><code>def filter(x):
for line in myContent:
if line == x:
yield x
</code></pre>
<p>Now say I have a lot of these filter generator objects floating around... maybe some of them are ano... | 5 | 2009-06-05T15:39:54Z | 956,952 | <p>If you want to interrogate them for debugging purposes, then the following function will help:</p>
<pre><code>import inspect
def inspect_generator(g):
sourcecode = open(g.gi_code.co_filename).readlines()
gline = g.gi_code.co_firstlineno
generator_code = inspect.getblock(sourcecode[gline-1:])
outpu... | 2 | 2009-06-05T16:53:07Z | [
"python"
] |
python: attributes on a generator object | 956,585 | <p>Is it possible to create an attribute on a generator object?</p>
<p>Here's a very simple example:</p>
<pre><code>def filter(x):
for line in myContent:
if line == x:
yield x
</code></pre>
<p>Now say I have a lot of these filter generator objects floating around... maybe some of them are ano... | 5 | 2009-06-05T15:39:54Z | 2,293,527 | <p>I just wrote a decorator to do this here:
<a href="http://code.activestate.com/recipes/577057-generator-attributes/" rel="nofollow">http://code.activestate.com/recipes/577057-generator-attributes/</a></p>
| 0 | 2010-02-19T01:32:30Z | [
"python"
] |
python: attributes on a generator object | 956,585 | <p>Is it possible to create an attribute on a generator object?</p>
<p>Here's a very simple example:</p>
<pre><code>def filter(x):
for line in myContent:
if line == x:
yield x
</code></pre>
<p>Now say I have a lot of these filter generator objects floating around... maybe some of them are ano... | 5 | 2009-06-05T15:39:54Z | 28,105,921 | <p>I realize this is a very belated answer, but...</p>
<p>Instead of storing and later reading some additional attribute, your code could later just inspect the generator's variable(s), using:</p>
<p>filter.gi_frame.f_locals</p>
<p>I guess Ants Aasma hinted at that.</p>
| 0 | 2015-01-23T08:37:45Z | [
"python"
] |
Am I missing step in building/installing VTK-5.4 with Python2.6 bindings on Ubuntu 9.04? | 956,716 | <p>I successfully built and installed VTK-5.4 with Python bindings from source. Yet, when I try to import VTK in python it gives the following Traceback error</p>
<blockquote>
<p>File "", line 1, in </p>
<p>File "/usr/local/lib/python2.6/dist-packages/VTK-5.4.2-py2.6.egg/vtk/<strong>init</strong>.py",
... | 3 | 2009-06-05T16:05:04Z | 956,889 | <p>Test if adding <code>/usr/local/lib</code> to your <code>$LD_LIBRARY_PATH</code> helps:</p>
<p>In a shell:</p>
<pre><code>export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
</code></pre>
<p>If it works, make it permanent by (adding <code>/usr/local/lib</code> to <code>/etc/ld.so.conf</code>) _ (running '<code... | 5 | 2009-06-05T16:36:42Z | [
"python",
"3d",
"vtk"
] |
Python open raw audio data file | 956,720 | <p>I have these files with the extension ".adc". They are simply raw data files. I can open them with Audacity using File->Import->Raw data with encoding "Signed 16 bit" and sample rate "16000 Khz". </p>
<p>I would like to do the same with python. I think that audioop module is what I need, but I can't seem to find ex... | 5 | 2009-06-05T16:05:51Z | 956,755 | <p>For opening the file, you just need <code>file()</code>.
For finding a location, you don't need audioop: you just need to convert seconds to bytes and get the required bytes of the file. For instance, if your file is 16 kHz 16bit mono, each second is 32,000 bytes of data. So the 10th second is 320kB into the file. J... | 7 | 2009-06-05T16:10:57Z | [
"python",
"audio"
] |
Python open raw audio data file | 956,720 | <p>I have these files with the extension ".adc". They are simply raw data files. I can open them with Audacity using File->Import->Raw data with encoding "Signed 16 bit" and sample rate "16000 Khz". </p>
<p>I would like to do the same with python. I think that audioop module is what I need, but I can't seem to find ex... | 5 | 2009-06-05T16:05:51Z | 957,235 | <p>Thanx a lot I was able to do the following:</p>
<pre><code>def play_data(filename, first_sec, second_sec):
import ao
from ao import AudioDevice
dev = AudioDevice(2, bits=16, rate=16000,channels=1)
f = open(filename, 'r')
data_len = (second_sec-first_sec)*32000
f.seek(32000*first_sec)
data = f.read(da... | 4 | 2009-06-05T17:58:49Z | [
"python",
"audio"
] |
Python open raw audio data file | 956,720 | <p>I have these files with the extension ".adc". They are simply raw data files. I can open them with Audacity using File->Import->Raw data with encoding "Signed 16 bit" and sample rate "16000 Khz". </p>
<p>I would like to do the same with python. I think that audioop module is what I need, but I can't seem to find ex... | 5 | 2009-06-05T16:05:51Z | 32,605,284 | <p>You can use <a href="http://pysoundfile.readthedocs.org/" rel="nofollow">PySoundFile</a> to open the file as a NumPy array and play it with <a href="http://python-sounddevice.readthedocs.org/" rel="nofollow">python-sounddevice</a>.</p>
<pre><code>import soundfile as sf
import sounddevice as sd
sig, fs = sf.read('m... | 0 | 2015-09-16T09:54:01Z | [
"python",
"audio"
] |
Iterating through large lists with potential conditions in Python | 956,820 | <p>I have large chunks of data, normally at around 2000+ entries, but in this report we have the ability to look as far as we want so it could be up to 10,000 records</p>
<p>The report is split up into: Two categories and then within each Category, we split by Currency so we have several sub categories within the list... | 1 | 2009-06-05T16:24:17Z | 956,852 | <p>You could define a little inline function:</p>
<pre><code>def EntryMatches(e):
if use_currency and not (e.currency == currency):
return False
if use_category and not (e.category == category):
return False
return True
</code></pre>
<p>then</p>
<pre><code>totals['quantity'] = sum([e.quantity for e in ... | 6 | 2009-06-05T16:29:48Z | [
"python",
"django",
"list"
] |
How to get string objects instead of Unicode ones from JSON in Python? | 956,867 | <p>I'm using <strong>Python 2</strong> to parse JSON from (<strong>ASCII encoded</strong>) text files. When loading these files with either <a href="https://docs.python.org/2/library/json.html"><code>json</code></a> or <a href="https://pypi.python.org/pypi/simplejson/"><code>simplejson</code></a>, all my string values... | 176 | 2009-06-05T16:32:17Z | 956,927 | <p>That's because json has no difference between string objects and unicode objects. They're all strings in javascript.</p>
<p>I think <strong>JSON is right to return unicode objects</strong>. In fact, I wouldn't accept anything less, since javascript strings <strong>are in fact <code>unicode</code> objects</strong> (... | 31 | 2009-06-05T16:44:45Z | [
"python",
"json",
"serialization",
"unicode",
"yaml"
] |
How to get string objects instead of Unicode ones from JSON in Python? | 956,867 | <p>I'm using <strong>Python 2</strong> to parse JSON from (<strong>ASCII encoded</strong>) text files. When loading these files with either <a href="https://docs.python.org/2/library/json.html"><code>json</code></a> or <a href="https://pypi.python.org/pypi/simplejson/"><code>simplejson</code></a>, all my string values... | 176 | 2009-06-05T16:32:17Z | 957,274 | <p>I'm afraid there's no way to achieve this automatically within the simplejson library.</p>
<p>The scanner and decoder in simplejson are designed to produce unicode text. To do this, the library uses a function called <code>c_scanstring</code> (if it's available, for speed), or <code>py_scanstring</code> if the C ve... | 9 | 2009-06-05T18:10:03Z | [
"python",
"json",
"serialization",
"unicode",
"yaml"
] |
How to get string objects instead of Unicode ones from JSON in Python? | 956,867 | <p>I'm using <strong>Python 2</strong> to parse JSON from (<strong>ASCII encoded</strong>) text files. When loading these files with either <a href="https://docs.python.org/2/library/json.html"><code>json</code></a> or <a href="https://pypi.python.org/pypi/simplejson/"><code>simplejson</code></a>, all my string values... | 176 | 2009-06-05T16:32:17Z | 1,641,528 | <p>This is late to the game, but I built this recursive caster. It works for my needs and I think it's relatively complete. It may help you.</p>
<pre><code>def _parseJSON(self, obj):
newobj = {}
for key, value in obj.iteritems():
key = str(key)
if isinstance(value, dict):
newobj[key] = self._parseJSON(value... | 0 | 2009-10-29T03:53:43Z | [
"python",
"json",
"serialization",
"unicode",
"yaml"
] |
How to get string objects instead of Unicode ones from JSON in Python? | 956,867 | <p>I'm using <strong>Python 2</strong> to parse JSON from (<strong>ASCII encoded</strong>) text files. When loading these files with either <a href="https://docs.python.org/2/library/json.html"><code>json</code></a> or <a href="https://pypi.python.org/pypi/simplejson/"><code>simplejson</code></a>, all my string values... | 176 | 2009-06-05T16:32:17Z | 3,181,455 | <p>So, I've run into the same problem. Guess what was the first Google result.</p>
<p>Because I need to pass all data to PyGTK, unicode strings aren't very useful to me either. So I have another recursive conversion method. It's actually also needed for typesafe JSON conversion - json.dump() would bail on any non-lite... | 1 | 2010-07-05T18:22:51Z | [
"python",
"json",
"serialization",
"unicode",
"yaml"
] |
How to get string objects instead of Unicode ones from JSON in Python? | 956,867 | <p>I'm using <strong>Python 2</strong> to parse JSON from (<strong>ASCII encoded</strong>) text files. When loading these files with either <a href="https://docs.python.org/2/library/json.html"><code>json</code></a> or <a href="https://pypi.python.org/pypi/simplejson/"><code>simplejson</code></a>, all my string values... | 176 | 2009-06-05T16:32:17Z | 3,972,139 | <p>The gotcha is that <code>simplejson</code> and <code>json</code> are two different modules, at least in the manner they deal with unicode. You have <code>json</code> in py 2.6+, and this gives you unicode values, whereas <code>simplejson</code> returns string objects. Just try easy_install-ing simplejson in your env... | 3 | 2010-10-19T19:48:34Z | [
"python",
"json",
"serialization",
"unicode",
"yaml"
] |
How to get string objects instead of Unicode ones from JSON in Python? | 956,867 | <p>I'm using <strong>Python 2</strong> to parse JSON from (<strong>ASCII encoded</strong>) text files. When loading these files with either <a href="https://docs.python.org/2/library/json.html"><code>json</code></a> or <a href="https://pypi.python.org/pypi/simplejson/"><code>simplejson</code></a>, all my string values... | 176 | 2009-06-05T16:32:17Z | 6,406,105 | <p>I ran into this problem too, and having to deal with JSON, I came up with a small loop that converts the unicode keys to strings. (<code>simplejson</code> on GAE does not return string keys.)</p>
<p><code>obj</code> is the object decoded from JSON:</p>
<pre class="lang-py prettyprint-override"><code>if NAME_CLASS... | -1 | 2011-06-20T01:20:36Z | [
"python",
"json",
"serialization",
"unicode",
"yaml"
] |
How to get string objects instead of Unicode ones from JSON in Python? | 956,867 | <p>I'm using <strong>Python 2</strong> to parse JSON from (<strong>ASCII encoded</strong>) text files. When loading these files with either <a href="https://docs.python.org/2/library/json.html"><code>json</code></a> or <a href="https://pypi.python.org/pypi/simplejson/"><code>simplejson</code></a>, all my string values... | 176 | 2009-06-05T16:32:17Z | 6,633,651 | <p>You can use the <code>object_hook</code> parameter for <a href="http://docs.python.org/library/json.html#json.loads"><code>json.loads</code></a> to pass in a converter. You don't have to do the conversion after the fact. The <a href="http://docs.python.org/library/json.html"><code>json</code></a> module will always ... | 68 | 2011-07-09T08:25:41Z | [
"python",
"json",
"serialization",
"unicode",
"yaml"
] |
How to get string objects instead of Unicode ones from JSON in Python? | 956,867 | <p>I'm using <strong>Python 2</strong> to parse JSON from (<strong>ASCII encoded</strong>) text files. When loading these files with either <a href="https://docs.python.org/2/library/json.html"><code>json</code></a> or <a href="https://pypi.python.org/pypi/simplejson/"><code>simplejson</code></a>, all my string values... | 176 | 2009-06-05T16:32:17Z | 13,105,359 | <p>There's no built-in option to make the json module functions return byte strings instead of unicode strings. However, this short and simple recursive function will convert any decoded JSON object from using unicode strings to UTF-8-encoded byte strings:</p>
<pre><code>def byteify(input):
if isinstance(input, di... | 112 | 2012-10-28T00:27:17Z | [
"python",
"json",
"serialization",
"unicode",
"yaml"
] |
How to get string objects instead of Unicode ones from JSON in Python? | 956,867 | <p>I'm using <strong>Python 2</strong> to parse JSON from (<strong>ASCII encoded</strong>) text files. When loading these files with either <a href="https://docs.python.org/2/library/json.html"><code>json</code></a> or <a href="https://pypi.python.org/pypi/simplejson/"><code>simplejson</code></a>, all my string values... | 176 | 2009-06-05T16:32:17Z | 16,373,377 | <p>While there are some good answers here, I ended up using <a href="http://pyyaml.org/">PyYAML</a> to parse my JSON files, since it gives the keys and values as <code>str</code> type strings instead of <code>unicode</code> type. Because JSON is a subset of YAML it works nicely:</p>
<pre><code>>>> import json... | 121 | 2013-05-04T10:37:24Z | [
"python",
"json",
"serialization",
"unicode",
"yaml"
] |
How to get string objects instead of Unicode ones from JSON in Python? | 956,867 | <p>I'm using <strong>Python 2</strong> to parse JSON from (<strong>ASCII encoded</strong>) text files. When loading these files with either <a href="https://docs.python.org/2/library/json.html"><code>json</code></a> or <a href="https://pypi.python.org/pypi/simplejson/"><code>simplejson</code></a>, all my string values... | 176 | 2009-06-05T16:32:17Z | 16,976,651 | <p>I rewrote Wells's _parse_json() to handle cases where the json object itself is an array (my use case).</p>
<pre><code>def _parseJSON(self, obj):
if isinstance(obj, dict):
newobj = {}
for key, value in obj.iteritems():
key = str(key)
newobj[key] = self._parseJSON(value)
... | 0 | 2013-06-07T05:12:22Z | [
"python",
"json",
"serialization",
"unicode",
"yaml"
] |
How to get string objects instead of Unicode ones from JSON in Python? | 956,867 | <p>I'm using <strong>Python 2</strong> to parse JSON from (<strong>ASCII encoded</strong>) text files. When loading these files with either <a href="https://docs.python.org/2/library/json.html"><code>json</code></a> or <a href="https://pypi.python.org/pypi/simplejson/"><code>simplejson</code></a>, all my string values... | 176 | 2009-06-05T16:32:17Z | 19,826,039 | <p>There exists an easy work-around.</p>
<p>TL;DR - Use <code>ast.literal_eval()</code> instead of <code>json.loads()</code>. Both <code>ast</code> and <code>json</code> are in the standard library.</p>
<p>While not a 'perfect' answer, it gets one pretty far if your plan is to ignore Unicode altogether. In Python 2... | 11 | 2013-11-07T01:01:43Z | [
"python",
"json",
"serialization",
"unicode",
"yaml"
] |
How to get string objects instead of Unicode ones from JSON in Python? | 956,867 | <p>I'm using <strong>Python 2</strong> to parse JSON from (<strong>ASCII encoded</strong>) text files. When loading these files with either <a href="https://docs.python.org/2/library/json.html"><code>json</code></a> or <a href="https://pypi.python.org/pypi/simplejson/"><code>simplejson</code></a>, all my string values... | 176 | 2009-06-05T16:32:17Z | 23,328,454 | <p>Just use pickle instead of json for dump and load, like so:</p>
<pre><code> import json
import pickle
d = { 'field1': 'value1', 'field2': 2, }
json.dump(d,open("testjson.txt","w"))
print json.load(open("testjson.txt","r"))
pickle.dump(d,open("testpickle.txt","w"))
print pickle.load(o... | 0 | 2014-04-27T20:15:01Z | [
"python",
"json",
"serialization",
"unicode",
"yaml"
] |
How to get string objects instead of Unicode ones from JSON in Python? | 956,867 | <p>I'm using <strong>Python 2</strong> to parse JSON from (<strong>ASCII encoded</strong>) text files. When loading these files with either <a href="https://docs.python.org/2/library/json.html"><code>json</code></a> or <a href="https://pypi.python.org/pypi/simplejson/"><code>simplejson</code></a>, all my string values... | 176 | 2009-06-05T16:32:17Z | 28,233,545 | <p>I had a json dict as a string. The keys and values where unicode objects like in the following example:</p>
<p>myStringDict = "{u'key':u'value'}"</p>
<p>I could use the byteify function suggested above by previously converting the string to a dict object using ast.literal_eval(myStringDict).</p>
| -1 | 2015-01-30T10:12:14Z | [
"python",
"json",
"serialization",
"unicode",
"yaml"
] |
How to get string objects instead of Unicode ones from JSON in Python? | 956,867 | <p>I'm using <strong>Python 2</strong> to parse JSON from (<strong>ASCII encoded</strong>) text files. When loading these files with either <a href="https://docs.python.org/2/library/json.html"><code>json</code></a> or <a href="https://pypi.python.org/pypi/simplejson/"><code>simplejson</code></a>, all my string values... | 176 | 2009-06-05T16:32:17Z | 29,633,899 | <p>As Mark (Amery) correctly notes: Using <strong>PyYaml</strong>'s deserializer on a json dump works only if you have ASCII only. At least out of the box. </p>
<p>Two quick comments on the PyYaml approach:</p>
<ol>
<li><p><a href="https://t.co/BaFO5CPyIF">NEVER</a> use yaml.load on data from the field. Its a feature... | 3 | 2015-04-14T17:36:25Z | [
"python",
"json",
"serialization",
"unicode",
"yaml"
] |
How to get string objects instead of Unicode ones from JSON in Python? | 956,867 | <p>I'm using <strong>Python 2</strong> to parse JSON from (<strong>ASCII encoded</strong>) text files. When loading these files with either <a href="https://docs.python.org/2/library/json.html"><code>json</code></a> or <a href="https://pypi.python.org/pypi/simplejson/"><code>simplejson</code></a>, all my string values... | 176 | 2009-06-05T16:32:17Z | 30,030,529 | <p>here is a recursive encoder written in C:
<a href="https://github.com/axiros/nested_encode" rel="nofollow">https://github.com/axiros/nested_encode</a></p>
<p>Performance overhead for "average" structures around 10% compared to json.loads.</p>
<pre><code>python speed.py ... | 0 | 2015-05-04T12:44:46Z | [
"python",
"json",
"serialization",
"unicode",
"yaml"
] |
How to get string objects instead of Unicode ones from JSON in Python? | 956,867 | <p>I'm using <strong>Python 2</strong> to parse JSON from (<strong>ASCII encoded</strong>) text files. When loading these files with either <a href="https://docs.python.org/2/library/json.html"><code>json</code></a> or <a href="https://pypi.python.org/pypi/simplejson/"><code>simplejson</code></a>, all my string values... | 176 | 2009-06-05T16:32:17Z | 31,005,819 | <p>I've adapted the code from the <a href="https://stackoverflow.com/a/13105359/611007">answer</a> of <a href="https://stackoverflow.com/users/1709587/mark-amery">Mark Amery</a>, particularly in order to get rid of <code>isinstance</code> for the pros of duck-typing.</p>
<p>The encoding is done manually and <code>ensu... | -1 | 2015-06-23T14:36:54Z | [
"python",
"json",
"serialization",
"unicode",
"yaml"
] |
How to get string objects instead of Unicode ones from JSON in Python? | 956,867 | <p>I'm using <strong>Python 2</strong> to parse JSON from (<strong>ASCII encoded</strong>) text files. When loading these files with either <a href="https://docs.python.org/2/library/json.html"><code>json</code></a> or <a href="https://pypi.python.org/pypi/simplejson/"><code>simplejson</code></a>, all my string values... | 176 | 2009-06-05T16:32:17Z | 33,571,117 | <h3>A solution with <code>object_hook</code></h3>
<pre><code>import json
def json_load_byteified(file_handle):
return _byteify(
json.load(file_handle, object_hook=_byteify),
ignore_dicts=True
)
def json_loads_byteified(json_text):
return _byteify(
json.loads(json_text, object_hook... | 23 | 2015-11-06T16:18:59Z | [
"python",
"json",
"serialization",
"unicode",
"yaml"
] |
How to get string objects instead of Unicode ones from JSON in Python? | 956,867 | <p>I'm using <strong>Python 2</strong> to parse JSON from (<strong>ASCII encoded</strong>) text files. When loading these files with either <a href="https://docs.python.org/2/library/json.html"><code>json</code></a> or <a href="https://pypi.python.org/pypi/simplejson/"><code>simplejson</code></a>, all my string values... | 176 | 2009-06-05T16:32:17Z | 34,796,078 | <p><a href="http://stackoverflow.com/a/6633651/1517753">Mike Brennan's answer</a> is close, but there is no reason to re-traverse the entire structure. If you use the <a href="https://docs.python.org/2/library/json.html#json.load" rel="nofollow"><code>object_hook_pairs</code></a> (Python 2.7+) parameter:</p>
<blockquo... | 5 | 2016-01-14T17:34:06Z | [
"python",
"json",
"serialization",
"unicode",
"yaml"
] |
mounting an s3 bucket in ec2 and using transparently as a mnt point | 956,904 | <p>I have a webapp (call it myapp.com) that allows users to upload files. The webapp will be deployed on Amazon EC2 instance. I would like to serve these files back out to the webapp consumers via an s3 bucket based domain (i.e. uploads.myapp.com). </p>
<p>When the user uploads the files, I can easily drop them in ... | 4 | 2009-06-05T16:39:25Z | 957,033 | <p>For uploads, your users can <a href="http://stackoverflow.com/questions/117810/upload-files-directly-to-amazon-s3-from-asp-net-application">upload directly to S3</a>, as described <a href="http://docs.amazonwebservices.com/AmazonS3/2006-03-01/index.html?UsingHTTPPOST.html" rel="nofollow">here</a>.</p>
<p>This way y... | 2 | 2009-06-05T17:12:12Z | [
"python",
"django",
"amazon-s3",
"amazon-ec2"
] |
mounting an s3 bucket in ec2 and using transparently as a mnt point | 956,904 | <p>I have a webapp (call it myapp.com) that allows users to upload files. The webapp will be deployed on Amazon EC2 instance. I would like to serve these files back out to the webapp consumers via an s3 bucket based domain (i.e. uploads.myapp.com). </p>
<p>When the user uploads the files, I can easily drop them in ... | 4 | 2009-06-05T16:39:25Z | 983,308 | <p>I'm not using EC2, but I do have my S3 bucket permanently mounted on my Linux server. The way I did it is with Jungledisk. It isn't a non-commercial solution, but it's very inexpensive.</p>
<p>First I setup the jungledisk as normal. Then I make sure fuse is installed. Mostly you just need to create the configuratio... | 5 | 2009-06-11T20:02:10Z | [
"python",
"django",
"amazon-s3",
"amazon-ec2"
] |
mounting an s3 bucket in ec2 and using transparently as a mnt point | 956,904 | <p>I have a webapp (call it myapp.com) that allows users to upload files. The webapp will be deployed on Amazon EC2 instance. I would like to serve these files back out to the webapp consumers via an s3 bucket based domain (i.e. uploads.myapp.com). </p>
<p>When the user uploads the files, I can easily drop them in ... | 4 | 2009-06-05T16:39:25Z | 989,280 | <p>I use s3fs, but there are no readily available distributions. I've got my build here for anyone who wants it easier.</p>
<p>Configuration documentation wasn't available, so I winged it until I got this in my fstab:</p>
<p>s3fs#{{ bucket name }} {{ /path/to/mount/point }} fuse allow_other,accessKeyId={{ key }},secr... | 2 | 2009-06-12T22:07:01Z | [
"python",
"django",
"amazon-s3",
"amazon-ec2"
] |
mounting an s3 bucket in ec2 and using transparently as a mnt point | 956,904 | <p>I have a webapp (call it myapp.com) that allows users to upload files. The webapp will be deployed on Amazon EC2 instance. I would like to serve these files back out to the webapp consumers via an s3 bucket based domain (i.e. uploads.myapp.com). </p>
<p>When the user uploads the files, I can easily drop them in ... | 4 | 2009-06-05T16:39:25Z | 4,327,061 | <p>This is a little snipped that I use for an Ubuntu system and I have not tested it on so it will obviously need to be adapted for a M$ system. You'll also need to install <a href="http://code.google.com/p/s3-simple-fuse/" rel="nofollow">s3-simple-fuse</a>. If you wind up eventually putting your job to the clound, I... | 2 | 2010-12-01T17:19:38Z | [
"python",
"django",
"amazon-s3",
"amazon-ec2"
] |
mounting an s3 bucket in ec2 and using transparently as a mnt point | 956,904 | <p>I have a webapp (call it myapp.com) that allows users to upload files. The webapp will be deployed on Amazon EC2 instance. I would like to serve these files back out to the webapp consumers via an s3 bucket based domain (i.e. uploads.myapp.com). </p>
<p>When the user uploads the files, I can easily drop them in ... | 4 | 2009-06-05T16:39:25Z | 6,308,720 | <p>I'd suggest using a separately-mounted EBS volume. I tried doing the same thing for some movie files. Access to S3 was slow, and S3 has some limitations like not being able to rename files, no real directory structure, etc.</p>
<p>You can set up EBS volumes in a RAID5 configuration and add space as you need it.</p>... | 0 | 2011-06-10T15:39:22Z | [
"python",
"django",
"amazon-s3",
"amazon-ec2"
] |
How to access the parent class during initialisation in python? | 956,994 | <p>How do I find out which class I am initialising a decorator in? It makes sense that I wouldn't be able to find this out as the decorator is not yet bound to the class, but is there a way of getting round this?</p>
<pre><code>class A(object):
def dec(f):
# I am in class 'A'
def func(cls):
... | 2 | 2009-06-05T17:03:40Z | 957,245 | <p>I don't think this is possible. At the very moment when you define test, the class doesn't exist yet.</p>
<p>When Python encounters</p>
<pre><code>class A(object):
</code></pre>
<p>it creates a new namespace in which it runs all code that it finds in the class definition (including the definition of test() and th... | 3 | 2009-06-05T18:01:20Z | [
"python",
"decorator",
"introspection"
] |
How to access the parent class during initialisation in python? | 956,994 | <p>How do I find out which class I am initialising a decorator in? It makes sense that I wouldn't be able to find this out as the decorator is not yet bound to the class, but is there a way of getting round this?</p>
<pre><code>class A(object):
def dec(f):
# I am in class 'A'
def func(cls):
... | 2 | 2009-06-05T17:03:40Z | 957,312 | <p>I don't get the question.</p>
<pre><code>>>> class A(object):
def dec(f):
def func(cls):
print cls
return func
@dec
def test(self):
pass
>>> a=A()
>>> a.test()
<__main__.A object at 0x00C56330>
>>>
</code></pre>
<p>The argu... | 0 | 2009-06-05T18:17:42Z | [
"python",
"decorator",
"introspection"
] |
How to access the parent class during initialisation in python? | 956,994 | <p>How do I find out which class I am initialising a decorator in? It makes sense that I wouldn't be able to find this out as the decorator is not yet bound to the class, but is there a way of getting round this?</p>
<pre><code>class A(object):
def dec(f):
# I am in class 'A'
def func(cls):
... | 2 | 2009-06-05T17:03:40Z | 959,504 | <p>As Nadia pointed out you will need to be more specific. Python does not allow this kind of things, which means that what you are trying to do is probably something wrong.</p>
<p>In the meantime, here is my contribution: a little story about a sailor and a frog. (use a constructor <em>after</em> the class initializa... | 0 | 2009-06-06T11:30:38Z | [
"python",
"decorator",
"introspection"
] |
What robot (web) libraries are available for python? | 957,661 | <p>Specifically, are there any libraries that do not use sockets?
I will be running this code in Google App Engine, which does not allow the use of sockets.</p>
<p>Google app engine does allow the use of urllib2 to make web requests.</p>
<p>I've been trying to get mechanize to work, since that what I've used before, ... | 1 | 2009-06-05T19:20:23Z | 967,176 | <p>To answer your question, <a href="http://twill.idyll.org/" rel="nofollow">twill</a> and <a href="http://webunit.sourceforge.net/" rel="nofollow">webunit</a> are some other Python programmatic web browsing libraries. However, I'd be surprised if any of them worked off the bat with Google App Engine given the restrict... | 0 | 2009-06-08T21:42:47Z | [
"python",
"google-app-engine",
"robot"
] |
What robot (web) libraries are available for python? | 957,661 | <p>Specifically, are there any libraries that do not use sockets?
I will be running this code in Google App Engine, which does not allow the use of sockets.</p>
<p>Google app engine does allow the use of urllib2 to make web requests.</p>
<p>I've been trying to get mechanize to work, since that what I've used before, ... | 1 | 2009-06-05T19:20:23Z | 1,151,688 | <p><a href="http://code.google.com/appengine/docs/python/urlfetch/" rel="nofollow">urlfetch</a> seems to do the same thing that you are looking for.</p>
| 1 | 2009-07-20T04:19:41Z | [
"python",
"google-app-engine",
"robot"
] |
Is mod_wsgi/Python optimizing things out? | 957,685 | <p>I have been trying to track down weird problems with my mod_wsgi/Python web application. I have the application handler which creates an object and calls a method:</p>
<pre><code>def my_method(self, file):
self.sapi.write("In my method for %d time"%self.mmcount)
self.mmcount += 1
# ... open file (absol... | 2 | 2009-06-05T19:25:33Z | 957,758 | <p>"Does mod_wsgi/Python include internal optimizations that would stop complete execution? Does it guess the output is deterministic and cache?"</p>
<p>No.</p>
<p>The problem is (generally) that you have a global variable somewhere in your program that is not getting reset the way you hoped it would.</p>
<p>Sometim... | 1 | 2009-06-05T19:39:29Z | [
"python",
"debugging",
"caching",
"mod-wsgi"
] |
Is mod_wsgi/Python optimizing things out? | 957,685 | <p>I have been trying to track down weird problems with my mod_wsgi/Python web application. I have the application handler which creates an object and calls a method:</p>
<pre><code>def my_method(self, file):
self.sapi.write("In my method for %d time"%self.mmcount)
self.mmcount += 1
# ... open file (absol... | 2 | 2009-06-05T19:25:33Z | 957,932 | <p>It seems the Python/mod_wsgi installation must be broken. I have never seen such weird bugs.
Traces next to returns:</p>
<pre><code>self.sapi.write("Returning at line 22 for call %d"%self.times_called)
return someval
</code></pre>
<p>Appear to happen numerous time:</p>
<blockquote>
<p>Returning at line 22 for c... | 1 | 2009-06-05T20:18:33Z | [
"python",
"debugging",
"caching",
"mod-wsgi"
] |
Is mod_wsgi/Python optimizing things out? | 957,685 | <p>I have been trying to track down weird problems with my mod_wsgi/Python web application. I have the application handler which creates an object and calls a method:</p>
<pre><code>def my_method(self, file):
self.sapi.write("In my method for %d time"%self.mmcount)
self.mmcount += 1
# ... open file (absol... | 2 | 2009-06-05T19:25:33Z | 1,038,152 | <p>That Apache/mod_wsgi may run in both multi process/multi threaded configurations can trip up code which is written with the assumption that it is run in a single process, with that process possibly being single threaded. For a discussion of different configuration possibilities and what that all means for shared dat... | 3 | 2009-06-24T12:47:20Z | [
"python",
"debugging",
"caching",
"mod-wsgi"
] |
How can I determine if one PGArray is included in another using SQLAlchemy sessions? | 957,762 | <p>I have an SqlAlchemy table like so:</p>
<pre><code>table = sql.Table('treeItems', META,
sql.Column('id', sql.Integer(), primary_key=True),
sql.Column('type', sql.String, nullable=False),
sql.Column('parentId', sql.Integer, sql.ForeignKey('treeItems.id')),
sql.Column('lineage', PGArray(sql.Integer)),... | 1 | 2009-06-05T19:40:14Z | 958,314 | <p>SQLAlchemy's clause elements have an .op() method for custom operators. What isn't available is a special clause for array literals. You can specify the array literal with literal_column:</p>
<pre><code>print sql.literal_column('ARRAY[2]').op('<@')(table.c.lineage)
# ARRAY[2] <@ "treeItems".lineage
</code></p... | 4 | 2009-06-05T21:53:39Z | [
"python",
"arrays",
"postgresql",
"sqlalchemy"
] |
How can I determine if one PGArray is included in another using SQLAlchemy sessions? | 957,762 | <p>I have an SqlAlchemy table like so:</p>
<pre><code>table = sql.Table('treeItems', META,
sql.Column('id', sql.Integer(), primary_key=True),
sql.Column('type', sql.String, nullable=False),
sql.Column('parentId', sql.Integer, sql.ForeignKey('treeItems.id')),
sql.Column('lineage', PGArray(sql.Integer)),... | 1 | 2009-06-05T19:40:14Z | 959,094 | <p>In this particular case I noticed that the quoting in the SQL was due to the fact I was using a table name that was mixed case. Converting the table name from 'treeItems' to 'tree_items' resolved the quoting issue and I was able to get my text expression to work:</p>
<pre><code>expr.text('%s <@ %s' % (arrayStr, ... | 0 | 2009-06-06T05:52:33Z | [
"python",
"arrays",
"postgresql",
"sqlalchemy"
] |
Is storm Python 3 compatible? | 957,773 | <p>I haven't found any information on that topic and its <a href="http://storm.canonical.com" rel="nofollow">homepage</a> doesn't mention it.</p>
| 3 | 2009-06-05T19:42:33Z | 957,843 | <p>Even though planned, at the moment there is no support for Python 3, you can check it out more details about that reading this thread from the storm ml:</p>
<p><a href="https://lists.ubuntu.com/archives/storm/2009-January/000839.html" rel="nofollow">https://lists.ubuntu.com/archives/storm/2009-January/000839.html</... | 3 | 2009-06-05T19:57:03Z | [
"python",
"python-3.x",
"storm-orm"
] |
Python disable/redirect keyboard input | 958,491 | <p>I'm writing a macro generator/ keyboard remapper in python, for xubuntu.</p>
<p>I've figured out how to intercept and record keystrokes, and send keystrokes I want to record, but I haven't figured out how to block keystrokes. I need to disable keyboard input to remap a key. For example, if I wanted to send 'a' when... | 3 | 2009-06-05T22:51:06Z | 981,709 | <p>I think it's going to depend heavily on the environment: curses & the activestate recipe are good for command line, but if you want it to run in a DE, you'll need some hooks to that DE. You might look at Qt or GTK bindings for python, or there's a python-xlib library that might let you tie right into the X syste... | 1 | 2009-06-11T15:09:49Z | [
"python",
"keyboard"
] |
Python disable/redirect keyboard input | 958,491 | <p>I'm writing a macro generator/ keyboard remapper in python, for xubuntu.</p>
<p>I've figured out how to intercept and record keystrokes, and send keystrokes I want to record, but I haven't figured out how to block keystrokes. I need to disable keyboard input to remap a key. For example, if I wanted to send 'a' when... | 3 | 2009-06-05T22:51:06Z | 993,251 | <p>I've got a keyboard hook that detects X events. I'm looking for a way to globally prevent a single keyboard event from being sent to a window. Something that works by accessing the event queue and removing the keyboard event from it would be ideal. It looks like it should be possible using Python Xlib, but I can't f... | 0 | 2009-06-14T17:22:46Z | [
"python",
"keyboard"
] |
Find all possible factors in KenKen puzzle 'multiply' domain | 958,678 | <p>A KenKen puzzle is a Latin square divided into edge-connected domains: a single cell, two adjacent cells within the same row or column, three cells arranged in a row or in an ell, etc. Each domain has a label which gives a target number and a single arithmetic operation (+-*/) which is to be applied to the numbers ... | 3 | 2009-06-06T00:42:39Z | 959,135 | <p>Simplified goal: you need to enumerate all integer combinations that multiply together to form a certain product, where the number of integers is fixed.</p>
<p>To solve this, all you need is a prime factorization of your target number, and then use a combinatorial approach to form all possible sub-products from the... | 4 | 2009-06-06T06:35:33Z | [
"python",
"algorithm",
"partitioning",
"prime-factoring"
] |
Clean Python Regular Expressions | 958,853 | <p>Is there a cleaner way to write long regex patterns in python? I saw this approach somewhere but regex in python doesn't allow lists.</p>
<pre><code>patterns = [
re.compile(r'<!--([^->]|(-+[^->])|(-?>))*-{2,}>'),
re.compile(r'\n+|\s{2}')
]
</code></pre>
| 12 | 2009-06-06T02:21:57Z | 958,860 | <p>You can use verbose mode to write more readable regular expressions. In this mode:</p>
<ul>
<li>Whitespace within the pattern is ignored, except when in a character class or preceded by an unescaped backslash.</li>
<li>When a line contains a '#' neither in a character class or preceded by an unescaped backslash, al... | 22 | 2009-06-06T02:25:01Z | [
"python",
"regex",
"list"
] |
Clean Python Regular Expressions | 958,853 | <p>Is there a cleaner way to write long regex patterns in python? I saw this approach somewhere but regex in python doesn't allow lists.</p>
<pre><code>patterns = [
re.compile(r'<!--([^->]|(-+[^->])|(-?>))*-{2,}>'),
re.compile(r'\n+|\s{2}')
]
</code></pre>
| 12 | 2009-06-06T02:21:57Z | 958,861 | <p>You can use comments in regex's, which make them much more readable. Taking an example from <a href="http://gnosis.cx/publish/programming/regular_expressions.html" rel="nofollow">http://gnosis.cx/publish/programming/regular_expressions.html</a> :</p>
<pre><code>/ # identify URLs within a text file
... | 2 | 2009-06-06T02:25:18Z | [
"python",
"regex",
"list"
] |
Clean Python Regular Expressions | 958,853 | <p>Is there a cleaner way to write long regex patterns in python? I saw this approach somewhere but regex in python doesn't allow lists.</p>
<pre><code>patterns = [
re.compile(r'<!--([^->]|(-+[^->])|(-?>))*-{2,}>'),
re.compile(r'\n+|\s{2}')
]
</code></pre>
| 12 | 2009-06-06T02:21:57Z | 958,890 | <p>Though @Ayman's suggestion about <code>re.VERBOSE</code> is a better idea, if all you want is what you're showing, just do:</p>
<pre><code>patterns = re.compile(
r'<!--([^->]|(-+[^->])|(-?>))*-{2,}>'
r'\n+|\s{2}'
)
</code></pre>
<p>and Python's automatic concatenation of adjacent str... | 12 | 2009-06-06T02:58:07Z | [
"python",
"regex",
"list"
] |
Python function calls are bleeding scope, stateful, failing to initialize parameters? | 959,113 | <p>Before I have the audacity to file a bug report, I thought I'd check my assumptions among wiser Pythonistas here. I encountered a baffling case today, so I whittled it down to a toy example, shown below:</p>
<pre><code>#!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""
A little script to demonstrate that a function... | 4 | 2009-06-06T06:15:00Z | 959,118 | <p>In Python default parameter values only get initialized when the def call is parsed. In the case of an object (such as your lists), it gets reused between calls. Take a look at this article about it, which also provides the necessary workaround:</p>
<p><a href="http://effbot.org/zone/default-values.htm">http://effb... | 15 | 2009-06-06T06:20:01Z | [
"python",
"scope"
] |
Python function calls are bleeding scope, stateful, failing to initialize parameters? | 959,113 | <p>Before I have the audacity to file a bug report, I thought I'd check my assumptions among wiser Pythonistas here. I encountered a baffling case today, so I whittled it down to a toy example, shown below:</p>
<pre><code>#!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""
A little script to demonstrate that a function... | 4 | 2009-06-06T06:15:00Z | 959,121 | <p>This is your problem:</p>
<pre><code>def bleedscope(a=[], b=[]):
</code></pre>
<p>it should be</p>
<pre><code>def bleedscope(a=None, b=None):
if a is None: a = []
if b is None: b = []
</code></pre>
<p>The default parameters are only executed once when the function is parsed, thus using the same 2 lists e... | 8 | 2009-06-06T06:21:31Z | [
"python",
"scope"
] |
Python function calls are bleeding scope, stateful, failing to initialize parameters? | 959,113 | <p>Before I have the audacity to file a bug report, I thought I'd check my assumptions among wiser Pythonistas here. I encountered a baffling case today, so I whittled it down to a toy example, shown below:</p>
<pre><code>#!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""
A little script to demonstrate that a function... | 4 | 2009-06-06T06:15:00Z | 959,131 | <p>Funnily enough, your input and your output are quite similar, for totally accidental reasons.</p>
<p>Actually what happens with Python is that the default values for a and b in your method declaration are "static" values. They are instanciated once at the method definition. So your default "a" is pushed each time y... | 1 | 2009-06-06T06:33:59Z | [
"python",
"scope"
] |
Python function calls are bleeding scope, stateful, failing to initialize parameters? | 959,113 | <p>Before I have the audacity to file a bug report, I thought I'd check my assumptions among wiser Pythonistas here. I encountered a baffling case today, so I whittled it down to a toy example, shown below:</p>
<pre><code>#!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""
A little script to demonstrate that a function... | 4 | 2009-06-06T06:15:00Z | 961,780 | <p>It's a <a href="http://www.python.org/doc/faq/general/#why-are-default-values-shared-between-objects" rel="nofollow">FAQ</a>.</p>
| 4 | 2009-06-07T12:06:47Z | [
"python",
"scope"
] |
not able to start coding in python | 959,168 | <p>i want to code in python and i know the syntax well.. but i have got no idea how to compile and run it ..!! i mean i am from ruby , java , c , c++ background and there after saving it in a file we go to command prompt and type the command and the file name to compile and run it .
then what about python ?
why does py... | -1 | 2009-06-06T07:18:26Z | 959,172 | <p>what operating system are you using?... you dont need to compile python code its interprated. just invoke the command line interpreter followed by the name of your .py file </p>
| 1 | 2009-06-06T07:22:46Z | [
"python"
] |
not able to start coding in python | 959,168 | <p>i want to code in python and i know the syntax well.. but i have got no idea how to compile and run it ..!! i mean i am from ruby , java , c , c++ background and there after saving it in a file we go to command prompt and type the command and the file name to compile and run it .
then what about python ?
why does py... | -1 | 2009-06-06T07:18:26Z | 959,176 | <p>If you're using Windows, you'll need to add the path to your Python executable to the Path environment variable; on Linux, and I presume Mac, this should already be done.</p>
<p>Oh, and you don't compile python programs, they are interpreted at run time.</p>
| 4 | 2009-06-06T07:24:08Z | [
"python"
] |
not able to start coding in python | 959,168 | <p>i want to code in python and i know the syntax well.. but i have got no idea how to compile and run it ..!! i mean i am from ruby , java , c , c++ background and there after saving it in a file we go to command prompt and type the command and the file name to compile and run it .
then what about python ?
why does py... | -1 | 2009-06-06T07:18:26Z | 960,052 | <p>If you are from Ruby background, you should be able to handle another interpreted language, which is what python is too. </p>
<p>Good starter resource:</p>
<p><a href="http://www.diveintopython.net/" rel="nofollow">Dive into Python</a></p>
| 3 | 2009-06-06T16:20:26Z | [
"python"
] |
Removing starting spaces in Python? | 959,215 | <p>I have a text string that starts with a number of spaces, varying between 2 & 4. What's the easiest & simplest way to remove them ie. remove everything before a certain character?</p>
| 51 | 2009-06-06T07:55:12Z | 959,216 | <p>The <a href="http://docs.python.org/library/stdtypes.html#str.lstrip"><code>lstrip()</code></a> method will remove leading whitespaces, newline and tab characters on a string beginning:</p>
<pre><code>>>> ' hello world!'.lstrip()
'hello world!'
</code></pre>
<p><strong>Edit</strong></p>
<p>As balpha ... | 118 | 2009-06-06T07:57:22Z | [
"python",
"string",
"trim"
] |
Removing starting spaces in Python? | 959,215 | <p>I have a text string that starts with a number of spaces, varying between 2 & 4. What's the easiest & simplest way to remove them ie. remove everything before a certain character?</p>
| 51 | 2009-06-06T07:55:12Z | 959,218 | <p>The function <code>strip</code> will remove whitespace from the beginning and end of a string.</p>
<pre><code>my_str = " text "
my_str = my_str.strip()
</code></pre>
<p>will set <code>my_str</code> to <code>"text"</code>.</p>
| 24 | 2009-06-06T07:58:37Z | [
"python",
"string",
"trim"
] |
Removing starting spaces in Python? | 959,215 | <p>I have a text string that starts with a number of spaces, varying between 2 & 4. What's the easiest & simplest way to remove them ie. remove everything before a certain character?</p>
| 51 | 2009-06-06T07:55:12Z | 959,225 | <p>To remove everything before a certain character, use a regular expression:</p>
<pre><code>re.sub(r'^[^a]*', '')
</code></pre>
<p>to remove everything up to the first 'a'. <code>[^a]</code> can be replaced with any character class you like, such as word characters.</p>
| 5 | 2009-06-06T08:04:13Z | [
"python",
"string",
"trim"
] |
Removing starting spaces in Python? | 959,215 | <p>I have a text string that starts with a number of spaces, varying between 2 & 4. What's the easiest & simplest way to remove them ie. remove everything before a certain character?</p>
| 51 | 2009-06-06T07:55:12Z | 30,802,316 | <p>If you want to cut the whitespaces before and behind the word, but keep the middle ones. <br>
You could use: </p>
<pre><code>word = ' Hello World '
stripped = word.strip()
print(stripped)
</code></pre>
| 0 | 2015-06-12T11:47:39Z | [
"python",
"string",
"trim"
] |
Parsing numbers in Python | 959,412 | <p>i want to take inputs like this
10 12 </p>
<p>13 14</p>
<p>15 16</p>
<p>..</p>
<p>how to take this input , as two diffrent integers so that i can multiply them in python
after every 10 and 12 there is newline</p>
| 2 | 2009-06-06T10:15:20Z | 959,424 | <p>You could use regular expressions (<code>re</code>-module)</p>
<pre><code>import re
test = "10 11\n12 13" # Get this input from the files or the console
matches = re.findall(r"(\d+)\s*(\d+)", test)
products = [ int(a) * int(b) for a, b in matches ]
# Process data
print(products)
</code></pre>
| 0 | 2009-06-06T10:25:13Z | [
"python",
"parsing"
] |
Parsing numbers in Python | 959,412 | <p>i want to take inputs like this
10 12 </p>
<p>13 14</p>
<p>15 16</p>
<p>..</p>
<p>how to take this input , as two diffrent integers so that i can multiply them in python
after every 10 and 12 there is newline</p>
| 2 | 2009-06-06T10:15:20Z | 959,425 | <p>I'm not sure I understood your problem very well, it seems you want to parse two int separated from a space.</p>
<p>In python you do:</p>
<pre><code>s = raw_input('Insert 2 integers separated by a space: ')
a,b = [int(i) for i in s.split(' ')]
print a*b
</code></pre>
<p>Explanation:</p>
<pre><code>s = raw_input(... | 7 | 2009-06-06T10:25:34Z | [
"python",
"parsing"
] |
Parsing numbers in Python | 959,412 | <p>i want to take inputs like this
10 12 </p>
<p>13 14</p>
<p>15 16</p>
<p>..</p>
<p>how to take this input , as two diffrent integers so that i can multiply them in python
after every 10 and 12 there is newline</p>
| 2 | 2009-06-06T10:15:20Z | 959,426 | <pre><code>f = open('inputfile.txt')
for line in f.readlines():
# the next line is equivalent to:
# s1, s2 = line.split(' ')
# a = int(s1)
# b = int(s2)
a, b = map(int, line.split(' '))
print a*b
</code></pre>
| 2 | 2009-06-06T10:26:30Z | [
"python",
"parsing"
] |
I need a beginners guide to setting up windows for python development | 959,479 | <p>I currently work with .NET exclusively and would like to have a go at python. To this end I need to set up a python development environment. I guide to this would be handy. I guess I would be doing web development so will need a web server and probably a database. I also need pointers to popular ORM's, an MVC framew... | 9 | 2009-06-06T11:08:51Z | 959,492 | <ul>
<li><a href="http://docs.python.org/using/windows.html" rel="nofollow">Using Python on Windows</a></li>
<li><a href="http://stackoverflow.com/questions/207701/python-tutorial-for-total-beginners">SO: Python tutorial for total beginners?</a></li>
</ul>
| 2 | 2009-06-06T11:18:48Z | [
"python",
"windows",
"development-environment"
] |
I need a beginners guide to setting up windows for python development | 959,479 | <p>I currently work with .NET exclusively and would like to have a go at python. To this end I need to set up a python development environment. I guide to this would be handy. I guess I would be doing web development so will need a web server and probably a database. I also need pointers to popular ORM's, an MVC framew... | 9 | 2009-06-06T11:08:51Z | 959,494 | <p>Well, if you're thinking of setting up an Ubuntu VM anyway, you might as well make that your development environment. Then you can install Apache and MySQL or Postgres on that VM just via the standard packaging tools (apt-get install), and there's no danger of polluting your Windows environment.</p>
<p>You can eith... | 3 | 2009-06-06T11:20:26Z | [
"python",
"windows",
"development-environment"
] |
I need a beginners guide to setting up windows for python development | 959,479 | <p>I currently work with .NET exclusively and would like to have a go at python. To this end I need to set up a python development environment. I guide to this would be handy. I guess I would be doing web development so will need a web server and probably a database. I also need pointers to popular ORM's, an MVC framew... | 9 | 2009-06-06T11:08:51Z | 959,497 | <p>Install the pre-configured <a href="http://www.activestate.com/activepython/" rel="nofollow">ActivePython</a> release from activestate.
Among other features, it includes the PythonWin IDE (Windows only) which makes it easy to explore Python interactively.</p>
<p>The recommended reference is <a href="http://www.div... | 3 | 2009-06-06T11:21:45Z | [
"python",
"windows",
"development-environment"
] |
I need a beginners guide to setting up windows for python development | 959,479 | <p>I currently work with .NET exclusively and would like to have a go at python. To this end I need to set up a python development environment. I guide to this would be handy. I guess I would be doing web development so will need a web server and probably a database. I also need pointers to popular ORM's, an MVC framew... | 9 | 2009-06-06T11:08:51Z | 959,512 | <p>Take a look at <a href="http://pylonshq.com/" rel="nofollow">Pylons</a>, read about <a href="http://www.python.org/dev/peps/pep-0333/" rel="nofollow">WSGI</a> and <a href="http://pythonpaste.org/" rel="nofollow">Paste</a>.
There's nice introductory Google tech talk about them: <a href="http://www.youtube.com/watch?v... | 2 | 2009-06-06T11:37:16Z | [
"python",
"windows",
"development-environment"
] |
I need a beginners guide to setting up windows for python development | 959,479 | <p>I currently work with .NET exclusively and would like to have a go at python. To this end I need to set up a python development environment. I guide to this would be handy. I guess I would be doing web development so will need a web server and probably a database. I also need pointers to popular ORM's, an MVC framew... | 9 | 2009-06-06T11:08:51Z | 959,738 | <p>It's not that hard to set up a Python environment, and I've never had it muck up my .NET work. Basically, install Python --- I'd use 2.6 rather than 3.0, which is not yet broadly accepted --- and add it to your PATH, and you're ready to go with the language. I wouldn't recommend using a Ubuntu VM as your developme... | 5 | 2009-06-06T14:04:25Z | [
"python",
"windows",
"development-environment"
] |
I need a beginners guide to setting up windows for python development | 959,479 | <p>I currently work with .NET exclusively and would like to have a go at python. To this end I need to set up a python development environment. I guide to this would be handy. I guess I would be doing web development so will need a web server and probably a database. I also need pointers to popular ORM's, an MVC framew... | 9 | 2009-06-06T11:08:51Z | 959,808 | <p>You should install python 2.4, python 2.5, python 2.6 and python 3.0, and add to your path the one you use more often (Add c:\Pythonxx\ and c:\Pythonxx\Scripts).</p>
<p>For every python 2.x, install easy_install; Download <a href="http://peak.telecommunity.com/dist/ez%5Fsetup.py" rel="nofollow">ez_setup.py</a> and ... | 3 | 2009-06-06T14:34:09Z | [
"python",
"windows",
"development-environment"
] |
I need a beginners guide to setting up windows for python development | 959,479 | <p>I currently work with .NET exclusively and would like to have a go at python. To this end I need to set up a python development environment. I guide to this would be handy. I guess I would be doing web development so will need a web server and probably a database. I also need pointers to popular ORM's, an MVC framew... | 9 | 2009-06-06T11:08:51Z | 959,891 | <p>Python has build in SQL like database and web server, so you wouldn't need to install any third party apps. Remember Python comes with batteries included.</p>
| 0 | 2009-06-06T15:08:22Z | [
"python",
"windows",
"development-environment"
] |
I need a beginners guide to setting up windows for python development | 959,479 | <p>I currently work with .NET exclusively and would like to have a go at python. To this end I need to set up a python development environment. I guide to this would be handy. I guess I would be doing web development so will need a web server and probably a database. I also need pointers to popular ORM's, an MVC framew... | 9 | 2009-06-06T11:08:51Z | 959,988 | <p>Environment?</p>
<p>Here is the simplest solution:</p>
<ul>
<li><p>Install <a href="http://www.activestate.com/activepython/" rel="nofollow">Active Python 2.6</a>. Its the Python itself, but comes with some extra handy useful stuff, like DiveintoPython chm.</p></li>
<li><p>Use <a href="http://www.activestate.com/k... | 1 | 2009-06-06T15:48:43Z | [
"python",
"windows",
"development-environment"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.