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 to strip decorators from a function in python
1,166,118
<p>Let's say I have the following:</p> <pre><code>def with_connection(f): def decorated(*args, **kwargs): f(get_connection(...), *args, **kwargs) return decorated @with_connection def spam(connection): # Do something </code></pre> <p>I want to test the <code>spam</code> function without going thr...
34
2009-07-22T15:29:41Z
1,448,145
<p>Add a do-nothing decorator:</p> <pre><code>def do_nothing(f): return f </code></pre> <p>After defining or importing with_connection but before you get to the methods that use it as a decorator, add:</p> <pre><code>if TESTING: with_connection = do_nothing </code></pre> <p>Then if you set the global TESTIN...
0
2009-09-19T08:23:38Z
[ "python", "decorator" ]
How to strip decorators from a function in python
1,166,118
<p>Let's say I have the following:</p> <pre><code>def with_connection(f): def decorated(*args, **kwargs): f(get_connection(...), *args, **kwargs) return decorated @with_connection def spam(connection): # Do something </code></pre> <p>I want to test the <code>spam</code> function without going thr...
34
2009-07-22T15:29:41Z
33,024,739
<p>There's been a bit of an update for this question. If you're using Python 3, you can use <code>__wrapped__</code> property that returns wrapped function.</p> <p>Here's an example from <a href="https://www.safaribooksonline.com/library/view/python-cookbook-3rd/9781449357337/ch09s03.html" rel="nofollow">Python Cookbo...
4
2015-10-08T19:48:06Z
[ "python", "decorator" ]
How to strip decorators from a function in python
1,166,118
<p>Let's say I have the following:</p> <pre><code>def with_connection(f): def decorated(*args, **kwargs): f(get_connection(...), *args, **kwargs) return decorated @with_connection def spam(connection): # Do something </code></pre> <p>I want to test the <code>spam</code> function without going thr...
34
2009-07-22T15:29:41Z
35,418,639
<p>You can now use the <a href="https://pypi.python.org/pypi/undecorated" rel="nofollow">undecorated</a> package:</p> <pre><code>&gt;&gt;&gt; from undecorated import undecorated &gt;&gt;&gt; undecorated(spam) </code></pre> <p>It goes through the hassle of digging through all the layers of different decorators until i...
0
2016-02-15T20:38:56Z
[ "python", "decorator" ]
Python textwrap Library - How to Preserve Line Breaks?
1,166,317
<p>When using Python's textwrap library, how can I turn this:</p> <pre><code>short line, long line xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx </code></pre> <p>into this:</p> <pre><code>short line, long line xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxx...
8
2009-07-22T15:55:52Z
1,166,367
<p>try</p> <pre><code>w = textwrap.TextWrapper(width=90,break_long_words=False,replace_whitespace=False) </code></pre> <p>that seemed to fix the problem for me</p> <p>I worked that out from what I read <a href="http://docs.python.org/library/textwrap.html#textwrap.TextWrapper">here</a> (I've never used textwrap befo...
13
2009-07-22T16:05:14Z
[ "python", "newline", "textwrapping" ]
Python textwrap Library - How to Preserve Line Breaks?
1,166,317
<p>When using Python's textwrap library, how can I turn this:</p> <pre><code>short line, long line xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx </code></pre> <p>into this:</p> <pre><code>short line, long line xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxx...
8
2009-07-22T15:55:52Z
1,166,382
<p>How about wrap only lines longer then 90 characters?</p> <pre><code>new_body = "" lines = body.split("\n") for line in lines: if len(line) &gt; 90: w = textwrap.TextWrapper(width=90, break_long_words=False) line = '\n'.join(w.wrap(line)) new_body += line + "\n" </code></pre>
3
2009-07-22T16:08:01Z
[ "python", "newline", "textwrapping" ]
Python textwrap Library - How to Preserve Line Breaks?
1,166,317
<p>When using Python's textwrap library, how can I turn this:</p> <pre><code>short line, long line xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx </code></pre> <p>into this:</p> <pre><code>short line, long line xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxx...
8
2009-07-22T15:55:52Z
1,166,398
<p>It looks like it doesn't support that. This code will extend it to do what I need though:</p> <p><a href="http://code.activestate.com/recipes/358228/" rel="nofollow">http://code.activestate.com/recipes/358228/</a></p>
1
2009-07-22T16:09:25Z
[ "python", "newline", "textwrapping" ]
Python textwrap Library - How to Preserve Line Breaks?
1,166,317
<p>When using Python's textwrap library, how can I turn this:</p> <pre><code>short line, long line xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx </code></pre> <p>into this:</p> <pre><code>short line, long line xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxx...
8
2009-07-22T15:55:52Z
1,166,402
<pre><code>lines = text.split("\n") lists = (textwrap.TextWrapper(width=90,break_long_words=False).wrap(line) for line in lines) body = "\n".join("\n".join(list) for list in lists) </code></pre>
0
2009-07-22T16:09:41Z
[ "python", "newline", "textwrapping" ]
Python textwrap Library - How to Preserve Line Breaks?
1,166,317
<p>When using Python's textwrap library, how can I turn this:</p> <pre><code>short line, long line xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx </code></pre> <p>into this:</p> <pre><code>short line, long line xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxx...
8
2009-07-22T15:55:52Z
26,538,082
<pre><code>body = '\n'.join(['\n'.join(textwrap.wrap(line, 90, break_long_words=False, replace_whitespace=False)) for line in body.splitlines() if line.strip() != '']) </code></pre>
7
2014-10-23T21:51:52Z
[ "python", "newline", "textwrapping" ]
Python textwrap Library - How to Preserve Line Breaks?
1,166,317
<p>When using Python's textwrap library, how can I turn this:</p> <pre><code>short line, long line xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx </code></pre> <p>into this:</p> <pre><code>short line, long line xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxx...
8
2009-07-22T15:55:52Z
39,134,215
<p>I had to a similar problem formatting dynamically generated docstrings. I wanted to preserve the newlines put in place by hand <em>and</em> split any lines over a certain length. Reworking the answer by <a href="http://stackoverflow.com/users/2044053/far">@far</a> a bit, this solution worked for me. I only includ...
0
2016-08-24T22:54:57Z
[ "python", "newline", "textwrapping" ]
Running Python code in different processors
1,166,392
<p>In order to do quality assurance in a critical multicore (8) workstation, I want to run the same code in different processors but not in parallel or concurrently. </p> <p>I need to run it 8 times, one run for each processor. </p> <p>What I don't know is how to select the processor I want. </p> <p>How can this be ...
4
2009-07-22T16:08:50Z
1,166,531
<p>Which process goes on which core is normaly decided by your OS. On linux there is taskset from the schedutils package to explicitly run a program on a processor.</p> <p>Python 2.6 has a <a href="http://docs.python.org/library/multiprocessing.html" rel="nofollow">multiprocessing</a> module that takes python function...
3
2009-07-22T16:31:32Z
[ "python", "qa", "multicore" ]
Running Python code in different processors
1,166,392
<p>In order to do quality assurance in a critical multicore (8) workstation, I want to run the same code in different processors but not in parallel or concurrently. </p> <p>I need to run it 8 times, one run for each processor. </p> <p>What I don't know is how to select the processor I want. </p> <p>How can this be ...
4
2009-07-22T16:08:50Z
1,166,607
<p>In Linux with <a href="http://schedutils.sourceforge.net/" rel="nofollow">schedutils</a>, I believe you'd use <a href="http://linuxcommand.org/man%5Fpages/taskset1.html" rel="nofollow">taskset</a> <code>-c X python foo.py</code> to run that specific Python process on CPU <code>X</code> (exactly how you identify your...
3
2009-07-22T16:45:28Z
[ "python", "qa", "multicore" ]
python distutils win32 version question
1,166,503
<p>So you can use distutils to create a file, such as</p> <pre><code>PIL-1.1.6.win32-py2.5.exe </code></pre> <p>which you can run and use to easily install something. However, the installation requires user input to proceed (you have to click 'OK' three times). I want to create an easily installable windows version t...
3
2009-07-22T16:26:41Z
1,166,775
<p>You get the executable by running "setup.py bdist_wininst". You can have something simpler by running "setup.py bdist_dumb". This will produce a .zip file which, unzipped at the root of the drive where Python is installed, provided that it's installed in the same directory as the machine you've build it, will instal...
0
2009-07-22T17:10:23Z
[ "python", "installer", "installation", "windows-installer", "distutils" ]
python distutils win32 version question
1,166,503
<p>So you can use distutils to create a file, such as</p> <pre><code>PIL-1.1.6.win32-py2.5.exe </code></pre> <p>which you can run and use to easily install something. However, the installation requires user input to proceed (you have to click 'OK' three times). I want to create an easily installable windows version t...
3
2009-07-22T16:26:41Z
1,167,297
<p>I have done this before using a simple batch file to call setuptools' install script passing the egg file path as an argument to it. The only trouble is that you need to ensure that script is in the PATH, which it might not be.</p> <p>Assuming Python itself is in the PATH you can try something like this in a pytho...
0
2009-07-22T18:40:03Z
[ "python", "installer", "installation", "windows-installer", "distutils" ]
python distutils win32 version question
1,166,503
<p>So you can use distutils to create a file, such as</p> <pre><code>PIL-1.1.6.win32-py2.5.exe </code></pre> <p>which you can run and use to easily install something. However, the installation requires user input to proceed (you have to click 'OK' three times). I want to create an easily installable windows version t...
3
2009-07-22T16:26:41Z
1,178,338
<p>See <a href="http://mail.python.org/pipermail/distutils-sig/2007-July/007874.html" rel="nofollow">this post</a> which describes an idea to modify the stub installer like this:</p> <p>It also mentions another alternative: use <code>setup.py bdist_msi</code> instead, which will produce an msi package, that can be ins...
1
2009-07-24T15:16:46Z
[ "python", "installer", "installation", "windows-installer", "distutils" ]
How do I filter the choices in a ModelForm that has a CharField with the choices attribute (and hence a Select Field)
1,166,649
<p>I understand I am able to filter queryset of Foreignkey or Many2ManyFields, however, how do I do that for a simple CharField that is a Select Widget (Select Tag).</p> <p>For example:</p> <pre><code>PRODUCT_STATUS = ( ("unapproved", "Unapproved"), ("approved", "Listed"), ...
1
2009-07-22T16:52:44Z
1,166,711
<pre><code>class YourModelForm(forms.ModelForm): def __init__(self, *args, **kwargs): super(YourModelForm, self).__init__(*args, **kwargs) self.fields['your_field'].choices = (('a', 'A'), ('b', 'B')) class Meta: model = YourModel </code></pre> <p>I guess this ain't too different from o...
0
2009-07-22T17:03:34Z
[ "python", "django" ]
Installing usual libraries inside Google App Engine
1,166,685
<p>How should I install (or where should I put and organize) usual python libraries in Google App Engine.</p> <p>Some libraries require to be installed using setuptools. How can I install that libraries.</p>
2
2009-07-22T16:59:18Z
1,168,312
<p>Most of them can be installed using the <a href="http://pip.openplans.org/" rel="nofollow">pip</a>. </p> <p>Follow 3 first points from the <a href="http://code.google.com/p/appengine-monkey/wiki/Pylons" rel="nofollow">Google wiki</a>.</p>
3
2009-07-22T21:17:56Z
[ "python", "google-app-engine" ]
Installing usual libraries inside Google App Engine
1,166,685
<p>How should I install (or where should I put and organize) usual python libraries in Google App Engine.</p> <p>Some libraries require to be installed using setuptools. How can I install that libraries.</p>
2
2009-07-22T16:59:18Z
1,170,396
<p>You need to unpack the libraries into a subdirectory of your app, and add the library directory to the Python path in your request handler module. Any steps required by setup scripts, you'll have to execute manually, but there generally aren't any unless the library bundles a native module (which aren't supported on...
5
2009-07-23T08:21:25Z
[ "python", "google-app-engine" ]
Intercept slice operations in Python
1,166,839
<p>I want to imitate a normal python list, except whenever elements are added or removed via slicing, I want to 'save' the list. Is this possible? This was my attempt but it will never print 'saving'.</p> <pre><code>class InterceptedList(list): def addSave(func): def newfunc(self, *args): func...
10
2009-07-22T17:18:30Z
1,166,983
<p>From the <a href="http://docs.python.org/3.1/whatsnew/3.0.html#operators-and-special-methods">Python 3 docs</a>:</p> <pre><code>__getslice__(), __setslice__() and __delslice__() were killed. The syntax a[i:j] now translates to a.__getitem__(slice(i, j)) (or __setitem__() or __delitem__(), when used as an assignme...
5
2009-07-22T17:42:44Z
[ "python", "methods", "jython", "slice", "intercept" ]
Intercept slice operations in Python
1,166,839
<p>I want to imitate a normal python list, except whenever elements are added or removed via slicing, I want to 'save' the list. Is this possible? This was my attempt but it will never print 'saving'.</p> <pre><code>class InterceptedList(list): def addSave(func): def newfunc(self, *args): func...
10
2009-07-22T17:18:30Z
1,167,000
<p>"setslice" and "delslice" are deprecated, if you want to do the interception you need to work with python slice objects passed to "setitem" and "delitem". If you want to intecept both slices and ordinary accesses this code works perfectly in python 2.6.2.</p> <pre><code>class InterceptedList(list): def addSave(fun...
5
2009-07-22T17:44:57Z
[ "python", "methods", "jython", "slice", "intercept" ]
Intercept slice operations in Python
1,166,839
<p>I want to imitate a normal python list, except whenever elements are added or removed via slicing, I want to 'save' the list. Is this possible? This was my attempt but it will never print 'saving'.</p> <pre><code>class InterceptedList(list): def addSave(func): def newfunc(self, *args): func...
10
2009-07-22T17:18:30Z
1,167,311
<p>the circumstances where <code>__getslice__</code> and <code>__setslice__</code> are called are pretty narrow. Specifically, slicing only occurs when you use a regular slice, where the first and end elements are mentioned exactly once. for any other slice syntax, or no slices at all, <code>__getitem__</code> or <co...
4
2009-07-22T18:41:17Z
[ "python", "methods", "jython", "slice", "intercept" ]
Intercept slice operations in Python
1,166,839
<p>I want to imitate a normal python list, except whenever elements are added or removed via slicing, I want to 'save' the list. Is this possible? This was my attempt but it will never print 'saving'.</p> <pre><code>class InterceptedList(list): def addSave(func): def newfunc(self, *args): func...
10
2009-07-22T17:18:30Z
1,170,410
<p>That's enough speculation. Let's start using facts instead shall we? As far as I can tell, the bottom line is that you must override both set of methods. </p> <p>If you want to implement undo/redo you probably should try using undo stack and set of actions that can do()/undo() themselves. </p> <h2>Code</h2> <pre>...
5
2009-07-23T08:28:12Z
[ "python", "methods", "jython", "slice", "intercept" ]
Autocompletion not working with PyQT4 and PyKDE4 in most of the IDEs
1,167,065
<p>I am trying to develop a plasmoid using python. I have tried eclipse with pydev, vim with pythoncomplete, PIDA and also Komodo, but none of them could give me autocmpletion for method names or members for the classes belonging to PyQT4 or PyKDE4. I added the folders in /usr/share/pyshare in the PYTHONPATH list for ...
3
2009-07-22T17:56:15Z
1,167,292
<p>There is a number of ways to do it, PyQt4 provides enough information about method names for any object inspecting IDE:</p> <pre><code>&gt;&gt;&gt; from PyQt4 import QtGui &gt;&gt;&gt; dir(QtGui.QToolBox) ['Box', ... contextMenuPolicy', 'count', 'create', 'currentChanged'...] </code></pre> <p>All those functions ...
4
2009-07-22T18:38:20Z
[ "python", "pyqt4", "pykde", "plasmoid" ]
Autocompletion not working with PyQT4 and PyKDE4 in most of the IDEs
1,167,065
<p>I am trying to develop a plasmoid using python. I have tried eclipse with pydev, vim with pythoncomplete, PIDA and also Komodo, but none of them could give me autocmpletion for method names or members for the classes belonging to PyQT4 or PyKDE4. I added the folders in /usr/share/pyshare in the PYTHONPATH list for ...
3
2009-07-22T17:56:15Z
1,168,895
<p>What about <a href="http://www.wingware.com" rel="nofollow">WingIDE</a>, It's not free but it's <a href="http://www.wingware.com/wingide/features" rel="nofollow">Feature List</a> has "auto-completion for wxPython, PyGTK, and PyQt "</p>
0
2009-07-22T23:58:37Z
[ "python", "pyqt4", "pykde", "plasmoid" ]
Automatically determine the natural language of a website page given its URL
1,167,262
<p>I'm looking for a way to automatically determine the natural language used by a website page, given its URL.</p> <p>In Python, a function like:</p> <pre><code>def LanguageUsed (url): #stuff </code></pre> <p>Which returns a language specifier (e.g. 'en' for English, 'jp' for Japanese, etc...)</p> <p>Summary o...
9
2009-07-22T18:33:46Z
1,167,408
<p><a href="http://www.nltk.org/" rel="nofollow">nltk</a> might help (if you have to get down to dealing with the page's text, i.e. if the headers and the url itself don't determine the language sufficiently well for your purposes); I don't think NLTK directly offers a "tell me which language this text is in" function ...
1
2009-07-22T18:53:26Z
[ "python", "url", "website", "nlp" ]
Automatically determine the natural language of a website page given its URL
1,167,262
<p>I'm looking for a way to automatically determine the natural language used by a website page, given its URL.</p> <p>In Python, a function like:</p> <pre><code>def LanguageUsed (url): #stuff </code></pre> <p>Which returns a language specifier (e.g. 'en' for English, 'jp' for Japanese, etc...)</p> <p>Summary o...
9
2009-07-22T18:33:46Z
1,167,451
<p>There's no general method that will work solely on URLs. You can check the <a href="http://en.wikipedia.org/wiki/List%5Fof%5FInternet%5Ftop-level%5Fdomains" rel="nofollow">top-level domain</a> to get some idea, and look for portions of the URL that might be indicative of a language (like "en" or "es" between two sla...
0
2009-07-22T19:00:32Z
[ "python", "url", "website", "nlp" ]
Automatically determine the natural language of a website page given its URL
1,167,262
<p>I'm looking for a way to automatically determine the natural language used by a website page, given its URL.</p> <p>In Python, a function like:</p> <pre><code>def LanguageUsed (url): #stuff </code></pre> <p>Which returns a language specifier (e.g. 'en' for English, 'jp' for Japanese, etc...)</p> <p>Summary o...
9
2009-07-22T18:33:46Z
1,167,561
<p>Your best bet really is to use <a href="http://www.google.com/uds/samples/language/detect.html" rel="nofollow">Google's natural language detection</a> api. It returns an iso code for the page language, with a probability index. </p> <p>See <a href="http://code.google.com/apis/ajaxlanguage/documentation/" rel="nofol...
6
2009-07-22T19:19:06Z
[ "python", "url", "website", "nlp" ]
Automatically determine the natural language of a website page given its URL
1,167,262
<p>I'm looking for a way to automatically determine the natural language used by a website page, given its URL.</p> <p>In Python, a function like:</p> <pre><code>def LanguageUsed (url): #stuff </code></pre> <p>Which returns a language specifier (e.g. 'en' for English, 'jp' for Japanese, etc...)</p> <p>Summary o...
9
2009-07-22T18:33:46Z
1,167,571
<p>There is nothing about the URL itself that will indicate language.</p> <p>One option would be to use a <a href="http://www.nltk.org/" rel="nofollow">natural language toolkit</a> to try to identify the language based on the content, but even if you can get the NLP part of it working, it'll be pretty slow. Also, it m...
3
2009-07-22T19:20:11Z
[ "python", "url", "website", "nlp" ]
Automatically determine the natural language of a website page given its URL
1,167,262
<p>I'm looking for a way to automatically determine the natural language used by a website page, given its URL.</p> <p>In Python, a function like:</p> <pre><code>def LanguageUsed (url): #stuff </code></pre> <p>Which returns a language specifier (e.g. 'en' for English, 'jp' for Japanese, etc...)</p> <p>Summary o...
9
2009-07-22T18:33:46Z
1,167,633
<p>This is usually accomplished by using character n-gram models. You can find <a href="http://alias-i.com/lingpipe/demos/tutorial/langid/read-me.html">here</a> a state of the art language identifier for Java. If you need some help converting it to Python, just ask. Hope it helps.</p>
8
2009-07-22T19:28:33Z
[ "python", "url", "website", "nlp" ]
Automatically determine the natural language of a website page given its URL
1,167,262
<p>I'm looking for a way to automatically determine the natural language used by a website page, given its URL.</p> <p>In Python, a function like:</p> <pre><code>def LanguageUsed (url): #stuff </code></pre> <p>Which returns a language specifier (e.g. 'en' for English, 'jp' for Japanese, etc...)</p> <p>Summary o...
9
2009-07-22T18:33:46Z
1,167,708
<p>You might want to try ngram based detection.</p> <p><a href="http://www.let.rug.nl/~vannoord/TextCat/Demo/textcat%5Fsrc.html" rel="nofollow">TextCat <strong>DEMO</strong></a> (LGPL) seems to work pretty well (recognizes almost 70 languages). There is a python port provided by <a href="http://thomas.mangin.me.uk/" r...
3
2009-07-22T19:38:32Z
[ "python", "url", "website", "nlp" ]
Python: access class property from string
1,167,398
<p>I have a class like the following:</p> <pre><code>class User: def __init__(self): self.data = [] self.other_data = [] def doSomething(self, source): // if source = 'other_data' how to access self.other_data </code></pre> <p>I want to pass a string for the source variable in <code>d...
65
2009-07-22T18:52:14Z
1,167,419
<p><code>x = getattr(self, source)</code> will work just perfectly if <code>source</code> names ANY attribute of self, include the <code>other_data</code> in your example.</p>
110
2009-07-22T18:55:55Z
[ "python", "syntax" ]
Python: access class property from string
1,167,398
<p>I have a class like the following:</p> <pre><code>class User: def __init__(self): self.data = [] self.other_data = [] def doSomething(self, source): // if source = 'other_data' how to access self.other_data </code></pre> <p>I want to pass a string for the source variable in <code>d...
65
2009-07-22T18:52:14Z
1,167,797
<p>Extending Alex's answer slightly:</p> <pre><code>class User: def __init__(self): self.data = [1,2,3] self.other_data = [4,5,6] def doSomething(self, source): dataSource = getattr(self,source) return dataSource A = User() print A.doSomething("data") print A.doSomething("other...
2
2009-07-22T19:50:52Z
[ "python", "syntax" ]
Python: access class property from string
1,167,398
<p>I have a class like the following:</p> <pre><code>class User: def __init__(self): self.data = [] self.other_data = [] def doSomething(self, source): // if source = 'other_data' how to access self.other_data </code></pre> <p>I want to pass a string for the source variable in <code>d...
65
2009-07-22T18:52:14Z
1,168,132
<p>A picture's worth a thousand words:</p> <pre><code>&gt;&gt;&gt; class c: pass o = c() &gt;&gt;&gt; setattr(o, "foo", "bar") &gt;&gt;&gt; o.foo 'bar' &gt;&gt;&gt; getattr(o, "foo") 'bar' </code></pre>
79
2009-07-22T20:45:36Z
[ "python", "syntax" ]
Python: access class property from string
1,167,398
<p>I have a class like the following:</p> <pre><code>class User: def __init__(self): self.data = [] self.other_data = [] def doSomething(self, source): // if source = 'other_data' how to access self.other_data </code></pre> <p>I want to pass a string for the source variable in <code>d...
65
2009-07-22T18:52:14Z
39,951,135
<ul> <li><strong><code>getattr(x, 'y')</code></strong> is equivalent to <strong><code>x.y</code></strong></li> <li><strong><code>setattr(x, 'y', v)</code></strong> is equivalent to <strong><code>x.y = v</code></strong></li> <li><strong><code>delattr(x, 'y')</code></strong> is equivalent to <strong><code>del x.y</code><...
0
2016-10-10T04:01:30Z
[ "python", "syntax" ]
Executing code for a custom Django 404 page
1,167,434
<p>I am getting ready to deploy my first Django application and am hitting a bit of a roadblock. My base template relies on me passing in the session object so that it can read out the currently logged in user's name. This isn't a problem when I control the code that is calling a template.</p> <p>However, as part of...
5
2009-07-22T18:58:17Z
1,167,480
<p>You need to override the default view handler for the 404 error. Here is the documentation on how to create your own custom 404 view function:</p> <p><a href="http://docs.djangoproject.com/en/dev/topics/http/views/#customizing-error-views">http://docs.djangoproject.com/en/dev/topics/http/views/#customizing-error-vi...
11
2009-07-22T19:05:11Z
[ "python", "django" ]
Executing code for a custom Django 404 page
1,167,434
<p>I am getting ready to deploy my first Django application and am hitting a bit of a roadblock. My base template relies on me passing in the session object so that it can read out the currently logged in user's name. This isn't a problem when I control the code that is calling a template.</p> <p>However, as part of...
5
2009-07-22T18:58:17Z
1,167,496
<p>Define your own 404 handler. See <a href="http://docs.djangoproject.com/en/dev/topics/http/urls/" rel="nofollow">Django URLs</a>, specifically the part about <a href="http://docs.djangoproject.com/en/dev/topics/http/urls/#handler404" rel="nofollow">handler404</a>.</p>
3
2009-07-22T19:08:17Z
[ "python", "django" ]
In Python, how do I indicate I'm overriding a method?
1,167,617
<p>In Java, for example, the @Override annotation not only provides compile-time checking of an override but makes for excellent self-documenting code. I'm just looking for documentation (although if it's an indicator to some checker like pylint, that's a bonus). I can add a comment or docstring somewhere, but what is ...
61
2009-07-22T19:26:48Z
1,167,640
<p>As far as I know, there is no special way to indicate an override in Python. You just define the method and include a docstring, like always.</p>
3
2009-07-22T19:29:19Z
[ "python", "inheritance", "override", "self-documenting-code" ]
In Python, how do I indicate I'm overriding a method?
1,167,617
<p>In Java, for example, the @Override annotation not only provides compile-time checking of an override but makes for excellent self-documenting code. I'm just looking for documentation (although if it's an indicator to some checker like pylint, that's a bonus). I can add a comment or docstring somewhere, but what is ...
61
2009-07-22T19:26:48Z
1,167,664
<p>Python ain't Java. There's of course no such thing really as compile-time checking. </p> <p>I think a comment in the docstring is plenty. This allows any user of your method to type <code>help(obj.method)</code> and see that the method is an override. </p> <p>You can also explicitly extend an interface with <cod...
9
2009-07-22T19:32:09Z
[ "python", "inheritance", "override", "self-documenting-code" ]
In Python, how do I indicate I'm overriding a method?
1,167,617
<p>In Java, for example, the @Override annotation not only provides compile-time checking of an override but makes for excellent self-documenting code. I'm just looking for documentation (although if it's an indicator to some checker like pylint, that's a bonus). I can add a comment or docstring somewhere, but what is ...
61
2009-07-22T19:26:48Z
1,168,677
<p>If you want this for documentation purposes only, you can define your own override decorator:</p> <pre><code>def override(f): return f class MyClass (BaseClass): @override def method(self): pass </code></pre> <p>This is really nothing but eye-candy, unless you create override(f) in such a wa...
4
2009-07-22T22:33:35Z
[ "python", "inheritance", "override", "self-documenting-code" ]
In Python, how do I indicate I'm overriding a method?
1,167,617
<p>In Java, for example, the @Override annotation not only provides compile-time checking of an override but makes for excellent self-documenting code. I'm just looking for documentation (although if it's an indicator to some checker like pylint, that's a bonus). I can add a comment or docstring somewhere, but what is ...
61
2009-07-22T19:26:48Z
8,313,042
<p><strong>UPDATE (23.05.2015): Based on this and fwc:s answer I created a pip installable package <a href="https://github.com/mkorpela/overrides">https://github.com/mkorpela/overrides</a></strong></p> <p>From time to time I end up here looking at this question. Mainly this happens after (again) seeing the same bug in...
110
2011-11-29T15:07:19Z
[ "python", "inheritance", "override", "self-documenting-code" ]
In Python, how do I indicate I'm overriding a method?
1,167,617
<p>In Java, for example, the @Override annotation not only provides compile-time checking of an override but makes for excellent self-documenting code. I'm just looking for documentation (although if it's an indicator to some checker like pylint, that's a bonus). I can add a comment or docstring somewhere, but what is ...
61
2009-07-22T19:26:48Z
14,631,397
<p>Here's an implementation that doesn't require specification of the interface_class name.</p> <pre><code>import inspect import re def overrides(method): # actually can't do this because a method is really just a function while inside a class def'n #assert(inspect.ismethod(method)) stack = inspect.sta...
19
2013-01-31T17:13:53Z
[ "python", "inheritance", "override", "self-documenting-code" ]
In Python, how do I indicate I'm overriding a method?
1,167,617
<p>In Java, for example, the @Override annotation not only provides compile-time checking of an override but makes for excellent self-documenting code. I'm just looking for documentation (although if it's an indicator to some checker like pylint, that's a bonus). I can add a comment or docstring somewhere, but what is ...
61
2009-07-22T19:26:48Z
18,193,306
<p>Like others have said unlike Java there is not @Overide tag however above you can create your own using decorators however I would suggest using the getattrib() global method instead of using the internal dict so you get something like the following:</p> <pre><code>def Override(superClass): def method(func) ...
1
2013-08-12T17:43:44Z
[ "python", "inheritance", "override", "self-documenting-code" ]
In Python, how do I indicate I'm overriding a method?
1,167,617
<p>In Java, for example, the @Override annotation not only provides compile-time checking of an override but makes for excellent self-documenting code. I'm just looking for documentation (although if it's an indicator to some checker like pylint, that's a bonus). I can add a comment or docstring somewhere, but what is ...
61
2009-07-22T19:26:48Z
20,203,242
<p>Hear is simplest and working under Jython with Java classes:</p> <pre><code>class MyClass(SomeJavaClass): def __init__(self): setattr(self, "name_of_method_to_override", __method_override__) def __method_override__(self, some_args): some_thing_to_do() </code></pre>
0
2013-11-25T21:02:37Z
[ "python", "inheritance", "override", "self-documenting-code" ]
Middleware for both Django and Pylons
1,167,903
<p>It appears to me that Django and Pylons have different ideas on how middleware should work. I like that Pylons follows the standardized <a href="http://www.python.org/dev/peps/pep-0333/" rel="nofollow">PEP 333</a>, but Django seems to have more widespread adoption. Is it possible to write middleware to be used in bo...
3
2009-07-22T20:06:26Z
1,168,128
<p>Pylons uses standard WSGI middleware. If you deploy Django via WSGI, you can also use WSGI middleware at that point. You can't, however, currently use WSGI middleware via the standard Django MIDDLEWARE_CLASSES option in settings.py.</p> <p>That said, there is currently a Google Summer of Code project to enable the ...
3
2009-07-22T20:45:09Z
[ "python", "django", "pylons", "middleware" ]
Middleware for both Django and Pylons
1,167,903
<p>It appears to me that Django and Pylons have different ideas on how middleware should work. I like that Pylons follows the standardized <a href="http://www.python.org/dev/peps/pep-0333/" rel="nofollow">PEP 333</a>, but Django seems to have more widespread adoption. Is it possible to write middleware to be used in bo...
3
2009-07-22T20:06:26Z
1,168,130
<p>For Pylons the term middleware means WSGI (<a href="http://www.python.org/dev/peps/pep-0333/" rel="nofollow">PEP 333</a>) middleware, whereas Django means its own internal mechanism for middleware.</p> <p>However, if you run Django under apache+<a href="http://code.google.com/p/modwsgi/" rel="nofollow">mod_wsgi</a>...
0
2009-07-22T20:45:29Z
[ "python", "django", "pylons", "middleware" ]
How to return an alternate column element from the intersect command?
1,167,908
<p>I am currently using the following code to get the intersection date column of two sets of financial data. The arrays include date, o,h,l,cl</p> <pre><code>#find intersection of date strings def intersect(seq1, seq2): res = [] # start empty for x in seq1: # scan seq1 ...
1
2009-07-22T20:06:46Z
1,168,062
<p>Okay, here is a complete solution.</p> <p>Get a <a href="http://www.goldb.org/ystockquote.html" rel="nofollow">python library to download stocks quotes</a></p> <p>Get some quotes</p> <pre><code>start_date, end_date = '20090309', '20090720' ibm_data = get_historical_prices('IBM', start_date, end_date) msft_data = ...
0
2009-07-22T20:31:33Z
[ "python", "intersection" ]
How to return an alternate column element from the intersect command?
1,167,908
<p>I am currently using the following code to get the intersection date column of two sets of financial data. The arrays include date, o,h,l,cl</p> <pre><code>#find intersection of date strings def intersect(seq1, seq2): res = [] # start empty for x in seq1: # scan seq1 ...
1
2009-07-22T20:06:46Z
1,168,068
<p>How's that:</p> <pre><code>def intersect(seq1, seq2): if seq1[0] == seq2[0]: # compare the date columns return (seq1[4], seq2[4]) # return 2-tuple with the cls values </code></pre>
0
2009-07-22T20:33:36Z
[ "python", "intersection" ]
Python scripts in /usr/bin
1,168,042
<p>I'm writing a pretty basic application in python (it's only one file at the moment). My question is how do I get it so the python script is able to be run in /usr/bin without the .py extension?</p> <p>For example, instead of running</p> <pre><code>python htswap.py args </code></pre> <p>from the directory where it...
8
2009-07-22T20:27:38Z
1,168,048
<p>The first line of the file should be</p> <pre><code>#!/usr/bin/env python </code></pre> <p>You should remove the <code>.py</code> extension, and make the file executable, using</p> <pre><code>chmod ugo+x htswap </code></pre> <p><strong>EDIT:</strong> <a href="http://stackoverflow.com/users/14637/thomas">Thomas</...
12
2009-07-22T20:29:55Z
[ "python", "unix", "scripting" ]
Python scripts in /usr/bin
1,168,042
<p>I'm writing a pretty basic application in python (it's only one file at the moment). My question is how do I get it so the python script is able to be run in /usr/bin without the .py extension?</p> <p>For example, instead of running</p> <pre><code>python htswap.py args </code></pre> <p>from the directory where it...
8
2009-07-22T20:27:38Z
1,168,053
<p>Shebang?</p> <pre><code>#!/usr/bin/env python </code></pre> <p>Put that at the beginning of your file and you're set</p>
2
2009-07-22T20:30:36Z
[ "python", "unix", "scripting" ]
Python scripts in /usr/bin
1,168,042
<p>I'm writing a pretty basic application in python (it's only one file at the moment). My question is how do I get it so the python script is able to be run in /usr/bin without the .py extension?</p> <p>For example, instead of running</p> <pre><code>python htswap.py args </code></pre> <p>from the directory where it...
8
2009-07-22T20:27:38Z
1,168,057
<p>add <code>#!/usr/bin/env python</code> to the very top of <code>htswap.py</code> and rename <code>htswap.py</code> to <code>htswap</code> then do a command: <code>chmod +x htswap</code> to make htswap executable.</p>
1
2009-07-22T20:30:55Z
[ "python", "unix", "scripting" ]
Python scripts in /usr/bin
1,168,042
<p>I'm writing a pretty basic application in python (it's only one file at the moment). My question is how do I get it so the python script is able to be run in /usr/bin without the .py extension?</p> <p>For example, instead of running</p> <pre><code>python htswap.py args </code></pre> <p>from the directory where it...
8
2009-07-22T20:27:38Z
1,168,065
<p>Simply strip off the <code>.py</code> extension by renaming the file. Then, you have to put the following line at the top of your file:</p> <pre><code>#!/usr/bin/env python </code></pre> <p><code>env</code> is a little program that sets up the environment so that the right <code>python</code> interpreter is execut...
21
2009-07-22T20:32:43Z
[ "python", "unix", "scripting" ]
Python scripts in /usr/bin
1,168,042
<p>I'm writing a pretty basic application in python (it's only one file at the moment). My question is how do I get it so the python script is able to be run in /usr/bin without the .py extension?</p> <p>For example, instead of running</p> <pre><code>python htswap.py args </code></pre> <p>from the directory where it...
8
2009-07-22T20:27:38Z
1,168,351
<p>I see in the official Python tutorials, <a href="http://docs.python.org/tutorial/index.html" rel="nofollow">http://docs.python.org/tutorial/index.html</a>, that </p> <pre><code>#! /usr/bin/env python </code></pre> <p>is used just as the answers above suggest. Note that you can also use the following</p> <pre><cod...
-1
2009-07-22T21:26:28Z
[ "python", "unix", "scripting" ]
Boolean evaluation in a lambda
1,168,236
<p>Just tooling around for my own amusement, and I want to use a lambda, because I feel like it. Can I replace this function with a lambda?</p> <pre><code>def isodd(number): if (number%2 == 0): return False else: return True </code></pre> <p>Elementary, yes. But I'm interested to know...</p>
4
2009-07-22T21:03:36Z
1,168,249
<pre><code>lambda num: num % 2 != 0 </code></pre>
6
2009-07-22T21:06:53Z
[ "python", "lambda" ]
Boolean evaluation in a lambda
1,168,236
<p>Just tooling around for my own amusement, and I want to use a lambda, because I feel like it. Can I replace this function with a lambda?</p> <pre><code>def isodd(number): if (number%2 == 0): return False else: return True </code></pre> <p>Elementary, yes. But I'm interested to know...</p>
4
2009-07-22T21:03:36Z
1,168,251
<pre><code>isodd = lambda number: number %2 != 0 </code></pre>
4
2009-07-22T21:07:26Z
[ "python", "lambda" ]
Boolean evaluation in a lambda
1,168,236
<p>Just tooling around for my own amusement, and I want to use a lambda, because I feel like it. Can I replace this function with a lambda?</p> <pre><code>def isodd(number): if (number%2 == 0): return False else: return True </code></pre> <p>Elementary, yes. But I'm interested to know...</p>
4
2009-07-22T21:03:36Z
1,168,261
<p>Yes you can:</p> <pre><code>isodd = lambda x: x % 2 != 0 </code></pre>
6
2009-07-22T21:08:26Z
[ "python", "lambda" ]
Boolean evaluation in a lambda
1,168,236
<p>Just tooling around for my own amusement, and I want to use a lambda, because I feel like it. Can I replace this function with a lambda?</p> <pre><code>def isodd(number): if (number%2 == 0): return False else: return True </code></pre> <p>Elementary, yes. But I'm interested to know...</p>
4
2009-07-22T21:03:36Z
1,168,311
<p>And if you don't really need a function you can replace it even without a lambda. :)</p> <pre><code>(number % 2 != 0) </code></pre> <p>by itself is an expression that evaluates to True or False. Or even plainer,</p> <pre><code>bool(number % 2) </code></pre> <p>which you can simplify like so:</p> <pre><code>if n...
9
2009-07-22T21:17:27Z
[ "python", "lambda" ]
Boolean evaluation in a lambda
1,168,236
<p>Just tooling around for my own amusement, and I want to use a lambda, because I feel like it. Can I replace this function with a lambda?</p> <pre><code>def isodd(number): if (number%2 == 0): return False else: return True </code></pre> <p>Elementary, yes. But I'm interested to know...</p>
4
2009-07-22T21:03:36Z
1,168,394
<p>Others already gave you replies that cover your particular case. In general, however, when you actually <em>need</em> an <code>if</code>-statement, you can use the conditional expression. For example, if you'd have to return strings <code>"False"</code> and <code>"True"</code> rather than boolean values, you could d...
5
2009-07-22T21:34:59Z
[ "python", "lambda" ]
Boolean evaluation in a lambda
1,168,236
<p>Just tooling around for my own amusement, and I want to use a lambda, because I feel like it. Can I replace this function with a lambda?</p> <pre><code>def isodd(number): if (number%2 == 0): return False else: return True </code></pre> <p>Elementary, yes. But I'm interested to know...</p>
4
2009-07-22T21:03:36Z
1,168,497
<p>And also don't forget that you can emulate complex conditional sentences with simple short-circuit logic, taking advantage that "and" and "or" return some of their ellements (the last one evaluated)... for example, in this case, supposing you'd want to return something different than True or False</p> <pre><code>la...
3
2009-07-22T21:49:45Z
[ "python", "lambda" ]
Boolean evaluation in a lambda
1,168,236
<p>Just tooling around for my own amusement, and I want to use a lambda, because I feel like it. Can I replace this function with a lambda?</p> <pre><code>def isodd(number): if (number%2 == 0): return False else: return True </code></pre> <p>Elementary, yes. But I'm interested to know...</p>
4
2009-07-22T21:03:36Z
1,168,917
<p><code>isodd = lambda number: (False, True)[number &amp; 1]</code></p>
1
2009-07-23T00:06:49Z
[ "python", "lambda" ]
Boolean evaluation in a lambda
1,168,236
<p>Just tooling around for my own amusement, and I want to use a lambda, because I feel like it. Can I replace this function with a lambda?</p> <pre><code>def isodd(number): if (number%2 == 0): return False else: return True </code></pre> <p>Elementary, yes. But I'm interested to know...</p>
4
2009-07-22T21:03:36Z
1,169,093
<p>Any time you see yourself writing:</p> <pre><code>if (some condition): return True else: return False </code></pre> <p>you should replace it with a single line:</p> <pre><code>return (some condition) </code></pre> <p>Your function then becomes:</p> <pre><code>def isodd(number): return number % 2 != ...
0
2009-07-23T01:15:11Z
[ "python", "lambda" ]
To build a similar reputation tracker as Jon's by Python
1,168,452
<p>Jon Skeet has the following <a href="http://csharpindepth.com/StackOverflow/ReputationTracker.aspx" rel="nofollow">reputation tracker</a> which is built by C#.</p> <p>I am interested in building a similar app by Python such that at least the following modules are used</p> <ul> <li>beautiful soup</li> <li>defaultdi...
0
2009-07-22T21:43:23Z
1,169,864
<p>The screenscraping is easy, if I understand the SO HTML format correctly, e.g., to get my rep (as I'm user 95810):</p> <pre><code>import urllib import BeautifulSoup page = urllib.urlopen('http://stackoverflow.com/users/95810') soup = BeautifulSoup.BeautifulSoup(page) therep = str(soup.find(text='Reputation').parent...
3
2009-07-23T06:00:56Z
[ "python" ]
Using map() to get number of times list elements exist in a string in Python
1,168,517
<p>I'm trying to get the number of times each item in a list is in a string in Python:</p> <pre><code>paragraph = "I eat bananas and a banana" def tester(x): return len(re.findall(x,paragraph)) map(tester, ['banana', 'loganberry', 'passion fruit']) </code></pre> <p>Returns [2, 0, 0] </p> <p>What I'd like to do how...
1
2009-07-22T21:53:13Z
1,168,527
<p>A closure would be a quick solution:</p> <pre><code>paragraph = "I eat bananas and a banana" def tester(s): def f(x): return len(re.findall(x,s)) return f print map(tester(paragraph), ['banana', 'loganberry', 'passion fruit']) </code></pre>
8
2009-07-22T21:57:41Z
[ "python", "regex", "mapreduce" ]
Using map() to get number of times list elements exist in a string in Python
1,168,517
<p>I'm trying to get the number of times each item in a list is in a string in Python:</p> <pre><code>paragraph = "I eat bananas and a banana" def tester(x): return len(re.findall(x,paragraph)) map(tester, ['banana', 'loganberry', 'passion fruit']) </code></pre> <p>Returns [2, 0, 0] </p> <p>What I'd like to do how...
1
2009-07-22T21:53:13Z
1,168,679
<p>I know you didn't ask for list comprehension, but here it is anyway:</p> <pre><code>paragraph = "I eat bananas and a banana" words = ['banana', 'loganberry', 'passion fruit'] [len(re.findall(word, paragraph)) for word in words] </code></pre> <p>This returns [2, 0, 0] as well.</p>
2
2009-07-22T22:34:55Z
[ "python", "regex", "mapreduce" ]
Using map() to get number of times list elements exist in a string in Python
1,168,517
<p>I'm trying to get the number of times each item in a list is in a string in Python:</p> <pre><code>paragraph = "I eat bananas and a banana" def tester(x): return len(re.findall(x,paragraph)) map(tester, ['banana', 'loganberry', 'passion fruit']) </code></pre> <p>Returns [2, 0, 0] </p> <p>What I'd like to do how...
1
2009-07-22T21:53:13Z
1,168,777
<pre><code>targets = ['banana', 'loganberry', 'passion fruit'] paragraph = "I eat bananas and a banana" print [paragraph.count(target) for target in targets] </code></pre> <p>No idea why you would use map() here.</p>
3
2009-07-22T23:06:47Z
[ "python", "regex", "mapreduce" ]
Using map() to get number of times list elements exist in a string in Python
1,168,517
<p>I'm trying to get the number of times each item in a list is in a string in Python:</p> <pre><code>paragraph = "I eat bananas and a banana" def tester(x): return len(re.findall(x,paragraph)) map(tester, ['banana', 'loganberry', 'passion fruit']) </code></pre> <p>Returns [2, 0, 0] </p> <p>What I'd like to do how...
1
2009-07-22T21:53:13Z
1,168,795
<p>Here's my version. </p> <pre><code>paragraph = "I eat bananas and a banana" def tester(paragraph, x): return len(re.findall(x,paragraph)) print lambda paragraph: map( lambda x: tester(paragraph, x) , ['banana', 'loganberry', 'passion fruit'] )(paragraph) </code></pre>
0
2009-07-22T23:16:55Z
[ "python", "regex", "mapreduce" ]
Using map() to get number of times list elements exist in a string in Python
1,168,517
<p>I'm trying to get the number of times each item in a list is in a string in Python:</p> <pre><code>paragraph = "I eat bananas and a banana" def tester(x): return len(re.findall(x,paragraph)) map(tester, ['banana', 'loganberry', 'passion fruit']) </code></pre> <p>Returns [2, 0, 0] </p> <p>What I'd like to do how...
1
2009-07-22T21:53:13Z
1,168,801
<p>This is basically just going out of your way to avoid a list comprehension, but if you like functional style programming, then you'll like <a href="http://docs.python.org/library/functools.html#functools.partial" rel="nofollow">functools.partial</a>.</p> <pre><code>&gt;&gt;&gt; from functools import partial &gt;&gt...
2
2009-07-22T23:19:36Z
[ "python", "regex", "mapreduce" ]
Using map() to get number of times list elements exist in a string in Python
1,168,517
<p>I'm trying to get the number of times each item in a list is in a string in Python:</p> <pre><code>paragraph = "I eat bananas and a banana" def tester(x): return len(re.findall(x,paragraph)) map(tester, ['banana', 'loganberry', 'passion fruit']) </code></pre> <p>Returns [2, 0, 0] </p> <p>What I'd like to do how...
1
2009-07-22T21:53:13Z
1,172,778
<p>For Q query words of average length L bytes on large texts of size T bytes, you need something that's NOT O(QLT). You need a DFA-style approach which can give you O(T) ... after setup costs. If your query set is rather static, then the setup cost can be ignored.</p> <p>E.g. <code>http://en.wikipedia.org/wiki/Aho-Co...
1
2009-07-23T15:58:19Z
[ "python", "regex", "mapreduce" ]
Using map() to get number of times list elements exist in a string in Python
1,168,517
<p>I'm trying to get the number of times each item in a list is in a string in Python:</p> <pre><code>paragraph = "I eat bananas and a banana" def tester(x): return len(re.findall(x,paragraph)) map(tester, ['banana', 'loganberry', 'passion fruit']) </code></pre> <p>Returns [2, 0, 0] </p> <p>What I'd like to do how...
1
2009-07-22T21:53:13Z
1,175,599
<p>Here's a response to the movement of the goalposts ("I probably need the regex because I'll need word delimiters in the near future"):</p> <p>This method parses the text once to obtain a list of all the "words". Each word is looked up in a dictionary of the target words, and if it is a target word it is counted. Th...
1
2009-07-24T03:21:15Z
[ "python", "regex", "mapreduce" ]
Recommended ways to split some functionality into functions, modules and packages?
1,168,565
<p>There comes a point where, in a relatively large sized project, one need to think about splitting the functionality into various functions, and then various modules, and then various packages. Sometimes across different source distributions (eg: extracting a common utility, such as optparser, into a separate project...
6
2009-07-22T22:05:47Z
1,168,597
<p>IMHO this should probably one of the things you do earlier in the development process. I have never worked on a large-scale project, but it would make sense that you make a roadmap of what's going to be done and where. (Not trying to rib you for asking about it like you made a mistake :D )</p> <p>Modules are genera...
1
2009-07-22T22:12:49Z
[ "python", "module", "package" ]
Recommended ways to split some functionality into functions, modules and packages?
1,168,565
<p>There comes a point where, in a relatively large sized project, one need to think about splitting the functionality into various functions, and then various modules, and then various packages. Sometimes across different source distributions (eg: extracting a common utility, such as optparser, into a separate project...
6
2009-07-22T22:05:47Z
1,168,598
<p>Take out a pen and piece of paper. Try to draw how your software interacts on a high level. Draw the different layers of the software etc. Group items by functionality and purpose, maybe even by what sort of technology they use. If your software has multiple abstraction layers, I would say to group them by that....
3
2009-07-22T22:13:07Z
[ "python", "module", "package" ]
Recommended ways to split some functionality into functions, modules and packages?
1,168,565
<p>There comes a point where, in a relatively large sized project, one need to think about splitting the functionality into various functions, and then various modules, and then various packages. Sometimes across different source distributions (eg: extracting a common utility, such as optparser, into a separate project...
6
2009-07-22T22:05:47Z
1,168,613
<p>Actually it varies for each project you create but here is an example:</p> <ol> <li><code>core</code> package contains modules that are your project cant live without. this may contain the main functionality of your application.</li> <li><code>ui</code> package contains modules that deals with the user interface. t...
0
2009-07-22T22:16:23Z
[ "python", "module", "package" ]
Recommended ways to split some functionality into functions, modules and packages?
1,168,565
<p>There comes a point where, in a relatively large sized project, one need to think about splitting the functionality into various functions, and then various modules, and then various packages. Sometimes across different source distributions (eg: extracting a common utility, such as optparser, into a separate project...
6
2009-07-22T22:05:47Z
1,168,652
<p>There's a classic paper by David Parnas called "On the criteria to be used in decomposing systems into modules". It's a classic (and has a certain age, so can be a little outdated).</p> <p>Maybe you can start from there, a PDF is available here</p> <p><a href="http://www.cs.umd.edu/class/spring2003/cmsc838p/Design...
6
2009-07-22T22:27:58Z
[ "python", "module", "package" ]
Recommended ways to split some functionality into functions, modules and packages?
1,168,565
<p>There comes a point where, in a relatively large sized project, one need to think about splitting the functionality into various functions, and then various modules, and then various packages. Sometimes across different source distributions (eg: extracting a common utility, such as optparser, into a separate project...
6
2009-07-22T22:05:47Z
1,169,182
<p>See <a href="http://stackoverflow.com/questions/106896/how-many-python-classes-should-i-put-in-one-file">http://stackoverflow.com/questions/106896/how-many-python-classes-should-i-put-in-one-file</a></p> <p>Sketch your overall set of class definitions.</p> <p>Partition these class definitions into "modules".</p> ...
2
2009-07-23T01:52:10Z
[ "python", "module", "package" ]
Recommended ways to split some functionality into functions, modules and packages?
1,168,565
<p>There comes a point where, in a relatively large sized project, one need to think about splitting the functionality into various functions, and then various modules, and then various packages. Sometimes across different source distributions (eg: extracting a common utility, such as optparser, into a separate project...
6
2009-07-22T22:05:47Z
2,360,690
<p>I sympathize with you. You are suffering from self-doubt. Don't worry. If you can speak any language, including your mother tongue, you are qualified to do modularization on your own. For evidence, you may read "The Language Instinct," or "The Math Instinct."</p> <p>Look around, but not too much. You can learn a lo...
1
2010-03-02T03:18:55Z
[ "python", "module", "package" ]
To make a plan for my first MySQL project
1,168,701
<p>I need to complete the plan of a <a href="http://translate.google.com/translate?hl=en&amp;sl=fi&amp;tl=en&amp;u=http%3A%2F%2Fwww.cs.helsinki.fi%2Fu%2Flaine%2Finfoht%2Faiheet%2Fis97je1.html">ask-a-question site for my uni.</a> in a few days. I need to have the first version of the code ready for the next Tuesday, whi...
3
2009-07-22T22:41:51Z
1,168,750
<p>First, this is all a lot to work with in a week. But here it goes.</p> <p>Tools for the backend:</p> <ol> <li>SQLAlchemy - This is an ORM toolkit that is plenty powerful for most smaller tasks when using a MySQL database built with Python. To my knowledge, it is the best for this job. <a href="http://www.sqlalche...
4
2009-07-22T23:00:16Z
[ "python", "mysql" ]
To make a plan for my first MySQL project
1,168,701
<p>I need to complete the plan of a <a href="http://translate.google.com/translate?hl=en&amp;sl=fi&amp;tl=en&amp;u=http%3A%2F%2Fwww.cs.helsinki.fi%2Fu%2Flaine%2Finfoht%2Faiheet%2Fis97je1.html">ask-a-question site for my uni.</a> in a few days. I need to have the first version of the code ready for the next Tuesday, whi...
3
2009-07-22T22:41:51Z
1,168,831
<p>I'm guessing that you wouldn't be allowed to use an ORM, since you call this a "MySQL project".</p> <p>If this is an incorrect assumption, I'd agree with N Arnold's recommendation of using Django. Rather than using SQLAlchemy, I think you'd find that Django's ORM is good enough (especially if you use v1.1rc or trun...
1
2009-07-22T23:35:03Z
[ "python", "mysql" ]
To make a plan for my first MySQL project
1,168,701
<p>I need to complete the plan of a <a href="http://translate.google.com/translate?hl=en&amp;sl=fi&amp;tl=en&amp;u=http%3A%2F%2Fwww.cs.helsinki.fi%2Fu%2Flaine%2Finfoht%2Faiheet%2Fis97je1.html">ask-a-question site for my uni.</a> in a few days. I need to have the first version of the code ready for the next Tuesday, whi...
3
2009-07-22T22:41:51Z
1,168,872
<p>Use the django Model to create the Object-Relational Mapping (ORM) that injects and retrieve your data. </p> <p>For login/logout, django has an AuthenticationMiddleware feature you can probably use, although I am not sure if you can solve your problem with it.</p> <p>In any case, your project, with the given deadl...
2
2009-07-22T23:48:27Z
[ "python", "mysql" ]
To make a plan for my first MySQL project
1,168,701
<p>I need to complete the plan of a <a href="http://translate.google.com/translate?hl=en&amp;sl=fi&amp;tl=en&amp;u=http%3A%2F%2Fwww.cs.helsinki.fi%2Fu%2Flaine%2Finfoht%2Faiheet%2Fis97je1.html">ask-a-question site for my uni.</a> in a few days. I need to have the first version of the code ready for the next Tuesday, whi...
3
2009-07-22T22:41:51Z
1,170,069
<p>You can build your database with MySQL, go read the <a href="http://dev.mysql.com/doc/" rel="nofollow">official docs</a>. It really doesn't matter what language you use to program a front-end whether it be a website, command line interface, gui interface, most languages handle this pretty well but it seems you're se...
1
2009-07-23T06:58:39Z
[ "python", "mysql" ]
To make a plan for my first MySQL project
1,168,701
<p>I need to complete the plan of a <a href="http://translate.google.com/translate?hl=en&amp;sl=fi&amp;tl=en&amp;u=http%3A%2F%2Fwww.cs.helsinki.fi%2Fu%2Flaine%2Finfoht%2Faiheet%2Fis97je1.html">ask-a-question site for my uni.</a> in a few days. I need to have the first version of the code ready for the next Tuesday, whi...
3
2009-07-22T22:41:51Z
1,170,964
<p><strong>About Moderators and Users</strong></p> <p>What is the difference between moderators and users? Moderators can modify text, but how? Are they planning you to practise permissions, fs or some open-source system to differentiate users from moderators? </p> <p>Very odd that they do not allow Google products, ...
0
2009-07-23T10:48:47Z
[ "python", "mysql" ]
To make a plan for my first MySQL project
1,168,701
<p>I need to complete the plan of a <a href="http://translate.google.com/translate?hl=en&amp;sl=fi&amp;tl=en&amp;u=http%3A%2F%2Fwww.cs.helsinki.fi%2Fu%2Flaine%2Finfoht%2Faiheet%2Fis97je1.html">ask-a-question site for my uni.</a> in a few days. I need to have the first version of the code ready for the next Tuesday, whi...
3
2009-07-22T22:41:51Z
1,171,064
<p>Django can use many different database backends one of which is MySQL, to help support this it provides an ORM (Object Relational Mapping) layer which abstracts away the SQL code and storage medium and allows you to write Models containing storage fields and logic as necessary without worrying about how they are sto...
1
2009-07-23T11:11:06Z
[ "python", "mysql" ]
To make a plan for my first MySQL project
1,168,701
<p>I need to complete the plan of a <a href="http://translate.google.com/translate?hl=en&amp;sl=fi&amp;tl=en&amp;u=http%3A%2F%2Fwww.cs.helsinki.fi%2Fu%2Flaine%2Finfoht%2Faiheet%2Fis97je1.html">ask-a-question site for my uni.</a> in a few days. I need to have the first version of the code ready for the next Tuesday, whi...
3
2009-07-22T22:41:51Z
1,171,353
<p>They give us only <a href="http://db.cs.helsinki.fi/~laine/php/lahja2.txt" rel="nofollow">this example</a> of the <a href="http://db.cs.helsinki.fi/~laine/php/lahjax.php" rel="nofollow">web app</a>. The code is not useful for me, since the code is in Finnish and it is written in PHP. It is also not open-source such ...
0
2009-07-23T12:15:06Z
[ "python", "mysql" ]
To make a plan for my first MySQL project
1,168,701
<p>I need to complete the plan of a <a href="http://translate.google.com/translate?hl=en&amp;sl=fi&amp;tl=en&amp;u=http%3A%2F%2Fwww.cs.helsinki.fi%2Fu%2Flaine%2Finfoht%2Faiheet%2Fis97je1.html">ask-a-question site for my uni.</a> in a few days. I need to have the first version of the code ready for the next Tuesday, whi...
3
2009-07-22T22:41:51Z
1,184,936
<p>I think this can all be accomplished in django. See the <a href="http://docs.djangoproject.com/en/dev/intro/tutorial01/" rel="nofollow">official tutorial</a>.</p>
2
2009-07-26T16:11:37Z
[ "python", "mysql" ]
To make a plan for my first MySQL project
1,168,701
<p>I need to complete the plan of a <a href="http://translate.google.com/translate?hl=en&amp;sl=fi&amp;tl=en&amp;u=http%3A%2F%2Fwww.cs.helsinki.fi%2Fu%2Flaine%2Finfoht%2Faiheet%2Fis97je1.html">ask-a-question site for my uni.</a> in a few days. I need to have the first version of the code ready for the next Tuesday, whi...
3
2009-07-22T22:41:51Z
1,184,941
<p>Ehh, what is the purpose of this development? To build a real production-ready system, or to pass an exam by building a mini-project that will never see real use?</p> <p>If your purpose is to pass an exam, then build what your teachers like to see. Take you cues from the material they have been using in classes, an...
1
2009-07-26T16:15:36Z
[ "python", "mysql" ]
Why does this Python script only read the last RSS post into the file?
1,168,844
<p>Im trying to fix a Python script which takes the posts from a specific RSS feed and strips them down and inputs them into a text file. As you can see beneath, there are two main print functions. One prints only to the shell once run, but it shows <em>all</em> of the posts, which is what I want it to do. Now, the sec...
0
2009-07-22T23:40:00Z
1,168,865
<p>Your <code>print &gt;&gt;f</code> are after the <code>for</code> loop, so they are run once, and operate on the data that you last saved to <code>title</code>, <code>description</code>, and <code>str</code>.</p> <p>You should open the file before the <code>for</code> loop and then put the <code>print &gt;&gt;f</cod...
2
2009-07-22T23:45:46Z
[ "python", "xml", "rss" ]
Why does this Python script only read the last RSS post into the file?
1,168,844
<p>Im trying to fix a Python script which takes the posts from a specific RSS feed and strips them down and inputs them into a text file. As you can see beneath, there are two main print functions. One prints only to the shell once run, but it shows <em>all</em> of the posts, which is what I want it to do. Now, the sec...
0
2009-07-22T23:40:00Z
1,168,866
<p>You iterate over all posts, assign their attributes to the variables and print to terminal.</p> <p>Then you print the variables (which happen to hold the results of the last assignment) to file. So you get a single post here.</p> <p>Need to iterate too if you want more than one.</p>
1
2009-07-22T23:45:55Z
[ "python", "xml", "rss" ]
Python Unicode Regular Expression
1,168,894
<p>I am using python 2.4 and I am having some problems with unicode regular expressions. I have tried to put together a very clear and concise example of my problem. It looks as though there is some problem with how Python is recognizing the different character encodings, or a problem with my understanding. Thank you v...
0
2009-07-22T23:57:26Z
1,168,904
<p>this might help: <a href="http://www.daa.com.au/pipermail/pygtk/2009-July/017299.html" rel="nofollow">http://www.daa.com.au/pipermail/pygtk/2009-July/017299.html</a></p>
0
2009-07-23T00:02:25Z
[ "python", "regex", "character-encoding" ]
Python Unicode Regular Expression
1,168,894
<p>I am using python 2.4 and I am having some problems with unicode regular expressions. I have tried to put together a very clear and concise example of my problem. It looks as though there is some problem with how Python is recognizing the different character encodings, or a problem with my understanding. Thank you v...
0
2009-07-22T23:57:26Z
1,168,943
<p>You probably want to either enable the DOTALL flag or you want to use the <code>search</code> method instead of the <code>match</code> method. ie:</p> <pre><code># DOTALL makes . match newlines re_UNSUB_amsterdam = re.compile(".*UNSUBSCRIBE.*", re.UNICODE | re.DOTALL) </code></pre> <p>or:</p> <pre><code># search...
2
2009-07-23T00:14:40Z
[ "python", "regex", "character-encoding" ]
Python Unicode Regular Expression
1,168,894
<p>I am using python 2.4 and I am having some problems with unicode regular expressions. I have tried to put together a very clear and concise example of my problem. It looks as though there is some problem with how Python is recognizing the different character encodings, or a problem with my understanding. Thank you v...
0
2009-07-22T23:57:26Z
1,169,218
<p>With default flag settings, .* doesn't match newlines. UNSUBSCRIBE appears only once, after the first newline. Adobe occurs before the first newline. You could fix that by using re.DOTALL. </p> <p>HOWEVER you haven't inspected what you got with the Adobe match: it's 1478 bytes wide! Turn on re.DOTALL and it (and th...
0
2009-07-23T02:11:17Z
[ "python", "regex", "character-encoding" ]
Python Unicode Regular Expression
1,168,894
<p>I am using python 2.4 and I am having some problems with unicode regular expressions. I have tried to put together a very clear and concise example of my problem. It looks as though there is some problem with how Python is recognizing the different character encodings, or a problem with my understanding. Thank you v...
0
2009-07-22T23:57:26Z
1,169,542
<p>Your question is about regular expressions, but your problem can possibly be solved without them; instead use the standard string <code>replace</code> method.</p> <pre><code>import urllib raw = urllib.urlopen('http://www.cs.unm.edu/~brian.stinar/legal.html').read() decoded = raw.decode('iso-8859-2') type(decoded) ...
0
2009-07-23T04:01:02Z
[ "python", "regex", "character-encoding" ]
IronPython vs. Python .NET
1,168,914
<p>I want to access some .NET assemblies written in C# from Python code. </p> <p>A little research showed I have two choices:</p> <ul> <li><a href="http://www.codeplex.com/IronPython">IronPython</a> with .NET interface capability/support built-in</li> <li>Python with the <a href="http://pythonnet.sourceforge.net/">Py...
56
2009-07-23T00:06:00Z
1,168,933
<p>If you want to mainly base your code on the .NET framework, I'd highly recommend IronPython vs Python.NET. IronPython is pretty much native .NET - so it just works great when integrating with other .NET langauges. </p> <p>Python.NET is good if you want to just integrate one or two components from .NET into a stan...
49
2009-07-23T00:12:09Z
[ ".net", "python", "ironpython", "python.net" ]
IronPython vs. Python .NET
1,168,914
<p>I want to access some .NET assemblies written in C# from Python code. </p> <p>A little research showed I have two choices:</p> <ul> <li><a href="http://www.codeplex.com/IronPython">IronPython</a> with .NET interface capability/support built-in</li> <li>Python with the <a href="http://pythonnet.sourceforge.net/">Py...
56
2009-07-23T00:06:00Z
1,168,935
<p>IronPython is ".NET-native" -- so it will be preferable if you want to fully integrate your Python code with .NET all the way; Python.NET works with Classic Python, so it lets you keep your Python code's "arm's length" away from .NET proper. (Note that with <a href="http://www.voidspace.org.uk/ironpython/cpython%5F...
7
2009-07-23T00:12:16Z
[ ".net", "python", "ironpython", "python.net" ]
IronPython vs. Python .NET
1,168,914
<p>I want to access some .NET assemblies written in C# from Python code. </p> <p>A little research showed I have two choices:</p> <ul> <li><a href="http://www.codeplex.com/IronPython">IronPython</a> with .NET interface capability/support built-in</li> <li>Python with the <a href="http://pythonnet.sourceforge.net/">Py...
56
2009-07-23T00:06:00Z
1,168,939
<p>IronPython comes from Microsoft, so I would go with my gut and use that one first since you have to assume it will play nicer with other MSFT technologies. </p>
6
2009-07-23T00:13:49Z
[ ".net", "python", "ironpython", "python.net" ]
IronPython vs. Python .NET
1,168,914
<p>I want to access some .NET assemblies written in C# from Python code. </p> <p>A little research showed I have two choices:</p> <ul> <li><a href="http://www.codeplex.com/IronPython">IronPython</a> with .NET interface capability/support built-in</li> <li>Python with the <a href="http://pythonnet.sourceforge.net/">Py...
56
2009-07-23T00:06:00Z
1,168,957
<p>While agreeing with the answers given by Reed Copsey and Alex Martelli, I'd like to point out one further difference - the Global Interpreter Lock (GIL). While IronPython doesn't have the limitations of the GIL, CPython does - so it would appear that for those applications where the GIL is a bottleneck, say in certa...
23
2009-07-23T00:20:06Z
[ ".net", "python", "ironpython", "python.net" ]
IronPython vs. Python .NET
1,168,914
<p>I want to access some .NET assemblies written in C# from Python code. </p> <p>A little research showed I have two choices:</p> <ul> <li><a href="http://www.codeplex.com/IronPython">IronPython</a> with .NET interface capability/support built-in</li> <li>Python with the <a href="http://pythonnet.sourceforge.net/">Py...
56
2009-07-23T00:06:00Z
8,981,895
<ol> <li><p>Ironpython is like C# in turn it relies on static prebuilt libraries while unlike C# is a dynamic language.</p></li> <li><p>Cpython is like C++ like Ironpython is a dynamic language and has access to dynamic libraries which in turn translates to being forced to write everything.</p></li> <li><p>Ironpython i...
0
2012-01-24T04:09:19Z
[ ".net", "python", "ironpython", "python.net" ]
IronPython vs. Python .NET
1,168,914
<p>I want to access some .NET assemblies written in C# from Python code. </p> <p>A little research showed I have two choices:</p> <ul> <li><a href="http://www.codeplex.com/IronPython">IronPython</a> with .NET interface capability/support built-in</li> <li>Python with the <a href="http://pythonnet.sourceforge.net/">Py...
56
2009-07-23T00:06:00Z
26,218,197
<p>Most of scientific and numerical Python libaries that rely on C-API (numpy, scipy, matplotlib, pandas, cython, etc.) are working mostly under CPython, so in that case your best bet is pythonnet (other names - Python.NET and Python for .NET). The same is true for CPython GUI bindings such as WxWidgets, PyQt/PySide, G...
6
2014-10-06T14:14:17Z
[ ".net", "python", "ironpython", "python.net" ]
IronPython vs. Python .NET
1,168,914
<p>I want to access some .NET assemblies written in C# from Python code. </p> <p>A little research showed I have two choices:</p> <ul> <li><a href="http://www.codeplex.com/IronPython">IronPython</a> with .NET interface capability/support built-in</li> <li>Python with the <a href="http://pythonnet.sourceforge.net/">Py...
56
2009-07-23T00:06:00Z
36,650,789
<p>As for 2016. </p> <p>In my company we used IronPython, but we were not satisfied with performances (mostly memory use - garbage collector was too slow) so we decided to switch to standard Python and integrate it with .Net using Zeroce-s ICE. </p>
0
2016-04-15T15:09:08Z
[ ".net", "python", "ironpython", "python.net" ]
Smart date interpretation
1,169,000
<p>I can't remember which application I was using, but I do recall it having really neat date parsing/interpretation.</p> <p>For example, you could type in 'two days ago' or 'tomorrow' and it would understand.</p> <p>Any libraries to suggest? Bonus points if usable from Python.</p>
6
2009-07-23T00:36:47Z
1,169,014
<p>Perhaps you are thinking of PHP's <code>strtotime()</code> function, the <a href="http://brian.moonspot.net/2008/09/20/strtotime-the-php-date-swiss-army-knife/">Swiss Army Knife of date parsing</a>:</p> <blockquote> <p>Man, what did I do before <code>strtotime()</code>. Oh, I know, I had a 482 line function to p...
8
2009-07-23T00:41:44Z
[ "python", "date-parsing" ]
Smart date interpretation
1,169,000
<p>I can't remember which application I was using, but I do recall it having really neat date parsing/interpretation.</p> <p>For example, you could type in 'two days ago' or 'tomorrow' and it would understand.</p> <p>Any libraries to suggest? Bonus points if usable from Python.</p>
6
2009-07-23T00:36:47Z
1,169,027
<p>The simple one I have seen for python is <a href="http://pyparsing.wikispaces.com/UnderDevelopment#toc0" rel="nofollow">here</a>.</p> <p>It uses pyparsing and is only a small script, but it does what you ask. However, the advantage being it would be pretty easy to extend and improve on if needed. Pyparsing is rela...
2
2009-07-23T00:46:41Z
[ "python", "date-parsing" ]
Smart date interpretation
1,169,000
<p>I can't remember which application I was using, but I do recall it having really neat date parsing/interpretation.</p> <p>For example, you could type in 'two days ago' or 'tomorrow' and it would understand.</p> <p>Any libraries to suggest? Bonus points if usable from Python.</p>
6
2009-07-23T00:36:47Z
1,169,085
<p>See my <a href="http://stackoverflow.com/questions/552073/whats-the-best-way-to-make-a-time-from-today-or-yesterday-and-a-time-in-pyth/552229#552229">SO answer</a> for links to three Python date parsing libraries. The one of these most commonly used is <a href="http://labix.org/python-dateutil">python-dateutils</a>...
6
2009-07-23T01:09:40Z
[ "python", "date-parsing" ]
Python OS X 10.5 development environment
1,169,025
<p>I would like to try out the Google App Engine Python environment, which the docs say runs 2.5.2. As I use OS X Leopard, I have Python 2.5.1 installed, but would like the latest 2.5.x version installed (not 2.6 or 3.0). It seems the latest version is <a href="http://www.python.org/download/releases/2.5.4/" rel="nof...
4
2009-07-23T00:45:23Z
1,169,058
<p>Your current python is in <code>/System/Library/Frameworks/Python.framework/</code>.</p> <p>If you install MacPython, it will go into <code>/Library/Frameworks/Python.framework/</code>. The installer will modify your $PATH (environment variable) so that typing <code>python</code> at the command line will run the v...
3
2009-07-23T00:59:28Z
[ "python", "google-app-engine", "osx", "development-environment" ]
Python OS X 10.5 development environment
1,169,025
<p>I would like to try out the Google App Engine Python environment, which the docs say runs 2.5.2. As I use OS X Leopard, I have Python 2.5.1 installed, but would like the latest 2.5.x version installed (not 2.6 or 3.0). It seems the latest version is <a href="http://www.python.org/download/releases/2.5.4/" rel="nof...
4
2009-07-23T00:45:23Z
1,169,279
<p>You can install python on your Mac, and it won't mess with the default installation. However, I strongly recommend that you use <a href="http://www.macports.org/">MacPorts</a> to install Python, since that will make it much easier for you to install Python libraries and packages further down the road. Additionally, ...
7
2009-07-23T02:32:01Z
[ "python", "google-app-engine", "osx", "development-environment" ]