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 |
|---|---|---|---|---|---|---|---|---|---|
What is the most compatible way to install python modules on a Mac? | 1,213,690 | <p>I'm starting to learn python and loving it. I work on a Mac mainly as well as Linux. I'm finding that on Linux (Ubuntu 9.04 mostly) when I install a python module using apt-get it works fine. I can import it with no trouble.</p>
<p>On the Mac, I'm used to using Macports to install all the Unixy stuff. However, I'm ... | 108 | 2009-07-31T16:58:55Z | 1,213,801 | <p>I use <a href="http://pypi.python.org/pypi/setuptools" rel="nofollow">easy_install</a> with Apple's Python, and it works like a charm.</p>
| -1 | 2009-07-31T17:21:32Z | [
"python",
"osx",
"module",
"packages",
"macports"
] |
What is the most compatible way to install python modules on a Mac? | 1,213,690 | <p>I'm starting to learn python and loving it. I work on a Mac mainly as well as Linux. I'm finding that on Linux (Ubuntu 9.04 mostly) when I install a python module using apt-get it works fine. I can import it with no trouble.</p>
<p>On the Mac, I'm used to using Macports to install all the Unixy stuff. However, I'm ... | 108 | 2009-07-31T16:58:55Z | 1,213,811 | <p>Regarding which python version to use, Mac OS usually ships an old version of python. It's a good idea to upgrade to a newer version. You can download a .dmg from <a href="http://www.python.org/download/" rel="nofollow">http://www.python.org/download/</a> . If you do that, remember to update the path. You can find ... | 1 | 2009-07-31T17:23:02Z | [
"python",
"osx",
"module",
"packages",
"macports"
] |
What is the most compatible way to install python modules on a Mac? | 1,213,690 | <p>I'm starting to learn python and loving it. I work on a Mac mainly as well as Linux. I'm finding that on Linux (Ubuntu 9.04 mostly) when I install a python module using apt-get it works fine. I can import it with no trouble.</p>
<p>On the Mac, I'm used to using Macports to install all the Unixy stuff. However, I'm ... | 108 | 2009-07-31T16:58:55Z | 1,213,823 | <p>Please see <a href="http://stackoverflow.com/questions/1169025/python-os-x-10-5-development-environment">Python OS X development environment</a>. The best way is to use <a href="http://www.macports.org/">MacPorts</a>. Download and install MacPorts, then install Python via MacPorts by typing the following commands in... | 30 | 2009-07-31T17:25:10Z | [
"python",
"osx",
"module",
"packages",
"macports"
] |
What is the most compatible way to install python modules on a Mac? | 1,213,690 | <p>I'm starting to learn python and loving it. I work on a Mac mainly as well as Linux. I'm finding that on Linux (Ubuntu 9.04 mostly) when I install a python module using apt-get it works fine. I can import it with no trouble.</p>
<p>On the Mac, I'm used to using Macports to install all the Unixy stuff. However, I'm ... | 108 | 2009-07-31T16:58:55Z | 1,214,096 | <p>There's nothing wrong with using a MacPorts Python installation. If you are installing python modules from MacPorts but then not seeing them, that likely means you are not invoking the MacPorts python you installed to. In a terminal shell, you can use absolute paths to invoke the various Pythons that may be install... | 6 | 2009-07-31T18:26:32Z | [
"python",
"osx",
"module",
"packages",
"macports"
] |
What is the most compatible way to install python modules on a Mac? | 1,213,690 | <p>I'm starting to learn python and loving it. I work on a Mac mainly as well as Linux. I'm finding that on Linux (Ubuntu 9.04 mostly) when I install a python module using apt-get it works fine. I can import it with no trouble.</p>
<p>On the Mac, I'm used to using Macports to install all the Unixy stuff. However, I'm ... | 108 | 2009-07-31T16:58:55Z | 1,214,123 | <p>I use MacPorts to install Python and any third-party modules tracked by MacPorts into <code>/opt/local</code>, and I install any manually installed modules (those not in the MacPorts repository) into <code>/usr/local</code>, and this has never caused any problems. I think you may be confused as to the use of certain... | 6 | 2009-07-31T18:31:26Z | [
"python",
"osx",
"module",
"packages",
"macports"
] |
What is the most compatible way to install python modules on a Mac? | 1,213,690 | <p>I'm starting to learn python and loving it. I work on a Mac mainly as well as Linux. I'm finding that on Linux (Ubuntu 9.04 mostly) when I install a python module using apt-get it works fine. I can import it with no trouble.</p>
<p>On the Mac, I'm used to using Macports to install all the Unixy stuff. However, I'm ... | 108 | 2009-07-31T16:58:55Z | 1,283,224 | <p>For MacPython installations, I found an effective solution to fixing the problem with setuptools (easy_install) in this blog post:</p>
<p><a href="http://droidism.com/getting-running-with-django-and-macpython-26-on-leopard" rel="nofollow">http://droidism.com/getting-running-with-django-and-macpython-26-on-leopard</... | 3 | 2009-08-16T00:44:05Z | [
"python",
"osx",
"module",
"packages",
"macports"
] |
What is the most compatible way to install python modules on a Mac? | 1,213,690 | <p>I'm starting to learn python and loving it. I work on a Mac mainly as well as Linux. I'm finding that on Linux (Ubuntu 9.04 mostly) when I install a python module using apt-get it works fine. I can import it with no trouble.</p>
<p>On the Mac, I'm used to using Macports to install all the Unixy stuff. However, I'm ... | 108 | 2009-07-31T16:58:55Z | 2,380,159 | <p>If you use Python from MacPorts, it has it's own easy_install located at: <strong>/opt/local/bin/easy_install-2.6</strong> (for py26, that is). It's not the same one as simply calling easy_install directly, even if you used python_select to change your default python command.</p>
| 6 | 2010-03-04T14:51:18Z | [
"python",
"osx",
"module",
"packages",
"macports"
] |
What is the most compatible way to install python modules on a Mac? | 1,213,690 | <p>I'm starting to learn python and loving it. I work on a Mac mainly as well as Linux. I'm finding that on Linux (Ubuntu 9.04 mostly) when I install a python module using apt-get it works fine. I can import it with no trouble.</p>
<p>On the Mac, I'm used to using Macports to install all the Unixy stuff. However, I'm ... | 108 | 2009-07-31T16:58:55Z | 7,220,022 | <p>Your question is already three years old and there are some details not covered in other answers:</p>
<p>Most people I know use <a href="http://mxcl.github.com/homebrew/">HomeBrew</a> or <a href="https://trac.macports.org/wiki/Python">MacPorts</a>, I prefer MacPorts because of its clean cut of what is a default Mac... | 37 | 2011-08-28T09:13:47Z | [
"python",
"osx",
"module",
"packages",
"macports"
] |
What is the most compatible way to install python modules on a Mac? | 1,213,690 | <p>I'm starting to learn python and loving it. I work on a Mac mainly as well as Linux. I'm finding that on Linux (Ubuntu 9.04 mostly) when I install a python module using apt-get it works fine. I can import it with no trouble.</p>
<p>On the Mac, I'm used to using Macports to install all the Unixy stuff. However, I'm ... | 108 | 2009-07-31T16:58:55Z | 19,816,612 | <p>Directly install one of the fink packages (Django 1.6 as of 2013-Nov)</p>
<pre><code>fink install django-py27
fink install django-py33
</code></pre>
<p>Or create yourself a virtualenv:</p>
<pre><code>fink install virtualenv-py27
virtualenv django-env
source django-env/bin/activate
pip install django
deactivate # ... | -1 | 2013-11-06T15:53:01Z | [
"python",
"osx",
"module",
"packages",
"macports"
] |
What user do python scripts run as in windows? | 1,213,706 | <p>I'm trying to have python delete some directories and I get access errors on them. I think its that the python user account doesn't have rights?</p>
<pre><code>WindowsError: [Error 5] Access is denied: 'path'
</code></pre>
<p>is what I get when I run the script.<br />
I've tried </p>
<pre><code>shutil.rmtree
o... | 21 | 2009-07-31T17:02:28Z | 1,213,713 | <p>I've never used Python, but I would assume it runs as whatever user executes the script.</p>
| 4 | 2009-07-31T17:03:52Z | [
"python",
"windows",
"file-permissions"
] |
What user do python scripts run as in windows? | 1,213,706 | <p>I'm trying to have python delete some directories and I get access errors on them. I think its that the python user account doesn't have rights?</p>
<pre><code>WindowsError: [Error 5] Access is denied: 'path'
</code></pre>
<p>is what I get when I run the script.<br />
I've tried </p>
<pre><code>shutil.rmtree
o... | 21 | 2009-07-31T17:02:28Z | 1,213,724 | <p>How are you running the script? From an interactive console session? If so, just open up a DOS command window (using cmd) and type 'whoami'. That is who you are running the scripts interactively.</p>
<p>Ok I saw your edits just now...why don't you print the path and check the properties to see if the user account r... | 0 | 2009-07-31T17:06:12Z | [
"python",
"windows",
"file-permissions"
] |
What user do python scripts run as in windows? | 1,213,706 | <p>I'm trying to have python delete some directories and I get access errors on them. I think its that the python user account doesn't have rights?</p>
<pre><code>WindowsError: [Error 5] Access is denied: 'path'
</code></pre>
<p>is what I get when I run the script.<br />
I've tried </p>
<pre><code>shutil.rmtree
o... | 21 | 2009-07-31T17:02:28Z | 1,213,743 | <p>If the script is being run as a scheduled task (which seems likely for a cleanup script), it will probably run as SYSTEM. It's (unwise, but) possible to set permissions on directories so that SYSTEM has no access.</p>
| 0 | 2009-07-31T17:09:15Z | [
"python",
"windows",
"file-permissions"
] |
What user do python scripts run as in windows? | 1,213,706 | <p>I'm trying to have python delete some directories and I get access errors on them. I think its that the python user account doesn't have rights?</p>
<pre><code>WindowsError: [Error 5] Access is denied: 'path'
</code></pre>
<p>is what I get when I run the script.<br />
I've tried </p>
<pre><code>shutil.rmtree
o... | 21 | 2009-07-31T17:02:28Z | 1,213,758 | <p>Are the directories empty, and if not do those methods support decursively deleting the contents of a directory?</p>
| 0 | 2009-07-31T17:12:10Z | [
"python",
"windows",
"file-permissions"
] |
What user do python scripts run as in windows? | 1,213,706 | <p>I'm trying to have python delete some directories and I get access errors on them. I think its that the python user account doesn't have rights?</p>
<pre><code>WindowsError: [Error 5] Access is denied: 'path'
</code></pre>
<p>is what I get when I run the script.<br />
I've tried </p>
<pre><code>shutil.rmtree
o... | 21 | 2009-07-31T17:02:28Z | 1,213,797 | <p>The scripts have no special user, they just run under the currently logged-in user which executed the script.</p>
<p>Have you tried checking that:</p>
<ul>
<li>you are trying to delete a valid path? and that</li>
<li>the path has no locked files?</li>
</ul>
| 3 | 2009-07-31T17:20:31Z | [
"python",
"windows",
"file-permissions"
] |
What user do python scripts run as in windows? | 1,213,706 | <p>I'm trying to have python delete some directories and I get access errors on them. I think its that the python user account doesn't have rights?</p>
<pre><code>WindowsError: [Error 5] Access is denied: 'path'
</code></pre>
<p>is what I get when I run the script.<br />
I've tried </p>
<pre><code>shutil.rmtree
o... | 21 | 2009-07-31T17:02:28Z | 1,214,935 | <p>We've had issues removing files and directories on Windows, even if we had just copied them, if they were set to 'readonly'. <code>shutil.rmtree()</code> offers you sort of exception handlers to handle this situation. You call it and provide an exception handler like this:</p>
<pre><code>import errno, os, stat, shu... | 41 | 2009-07-31T21:15:18Z | [
"python",
"windows",
"file-permissions"
] |
What user do python scripts run as in windows? | 1,213,706 | <p>I'm trying to have python delete some directories and I get access errors on them. I think its that the python user account doesn't have rights?</p>
<pre><code>WindowsError: [Error 5] Access is denied: 'path'
</code></pre>
<p>is what I get when I run the script.<br />
I've tried </p>
<pre><code>shutil.rmtree
o... | 21 | 2009-07-31T17:02:28Z | 9,735,134 | <p>@ThomasH : another brick to the wall.</p>
<p>On unix systems, you have to ensure that parent directory is writeable too.
Here is another version :</p>
<pre><code>def remove_readonly(func, path, exc):
excvalue = exc[1]
if func in (os.rmdir, os.remove) and excvalue.errno == errno.EACCES:
# ensure pa... | 0 | 2012-03-16T09:59:24Z | [
"python",
"windows",
"file-permissions"
] |
Remap keyboard navigation with Jython / Swing | 1,213,730 | <p>I'm trying to remap several navigation keys:</p>
<ul>
<li>ENTER: to work like standard TAB behavior (focus to next control)</li>
<li>SHIFT+ENTER: to work like SHIFT+TAB behavior (focus to previous control)</li>
<li>UP / DOWN arrows: previous /next control</li>
<li>etc</li>
</ul>
<p>I tried with a couple of options... | 3 | 2009-07-31T17:07:38Z | 1,213,879 | <p>Add keyPressed to the swing competent that you want to listen for the key press on</p>
<pre><code>self.textfield1 = JTextField('Type something here',15,focusGained=self.myOnFocus,keyPressed=self.myOnKey)
</code></pre>
<p><strong><em>myOnKey can be named anything in that method do something like:</em></strong></p>
... | 0 | 2009-07-31T17:37:08Z | [
"python",
"swing",
"jython"
] |
Remap keyboard navigation with Jython / Swing | 1,213,730 | <p>I'm trying to remap several navigation keys:</p>
<ul>
<li>ENTER: to work like standard TAB behavior (focus to next control)</li>
<li>SHIFT+ENTER: to work like SHIFT+TAB behavior (focus to previous control)</li>
<li>UP / DOWN arrows: previous /next control</li>
<li>etc</li>
</ul>
<p>I tried with a couple of options... | 3 | 2009-07-31T17:07:38Z | 1,214,292 | <p>I made a new post for readability.</p>
<pre><code>self.textfield1 = JTextField('Type something here',15,focusGained=self.myOnFocus,keyPressed=self.myOnKey)
#create textfield2...must be created before can be referenced below.
self.textfield1.setNextFocusableComponent(self.textfield2)
</code></pre>
<p>then in your... | 1 | 2009-07-31T19:05:38Z | [
"python",
"swing",
"jython"
] |
Remap keyboard navigation with Jython / Swing | 1,213,730 | <p>I'm trying to remap several navigation keys:</p>
<ul>
<li>ENTER: to work like standard TAB behavior (focus to next control)</li>
<li>SHIFT+ENTER: to work like SHIFT+TAB behavior (focus to previous control)</li>
<li>UP / DOWN arrows: previous /next control</li>
<li>etc</li>
</ul>
<p>I tried with a couple of options... | 3 | 2009-07-31T17:07:38Z | 1,216,973 | <p>Finally used part of Jack's answer (the keyPressed event) but without manually setting setNextFocusableComponent:</p>
<pre><code>keyFocusMgr = KeyboardFocusManager.getCurrentKeyboardFocusManager()
keyFocusMgr.focusNextComponent()
</code></pre>
| 1 | 2009-08-01T16:39:01Z | [
"python",
"swing",
"jython"
] |
Filter and sort music info on Google App Engine | 1,213,959 | <p>I've enjoyed building out a couple simple applications on the GAE, but now I'm stumped about how to architect a music collection organizer on the app engine. In brief, I can't figure out how to filter on multiple properties while sorting on another.</p>
<p>Let's assume the core model is an Album that contains seve... | 1 | 2009-07-31T17:55:20Z | 1,214,106 | <p>As you say, you can't have an inequality condition on one field and an order by another (or inequalities on two fields, etc, etc). The workaround is simply to use the "best" inequality condition to get data in memory (where "best" means the one that's expected to yield the least data) and then further refine it and ... | 0 | 2009-07-31T18:28:35Z | [
"python",
"google-app-engine",
"django-models",
"model"
] |
Filter and sort music info on Google App Engine | 1,213,959 | <p>I've enjoyed building out a couple simple applications on the GAE, but now I'm stumped about how to architect a music collection organizer on the app engine. In brief, I can't figure out how to filter on multiple properties while sorting on another.</p>
<p>Let's assume the core model is an Album that contains seve... | 1 | 2009-07-31T17:55:20Z | 1,216,332 | <p>There's a couple of options here: You can filter as best as possible, then sort the results in memory, as Alex suggests, or you can rework your data structures for equality filters instead of inequality filters.</p>
<p>For example, assuming you only want to filter by decade, you can add a field encoding the decade ... | 1 | 2009-08-01T10:27:56Z | [
"python",
"google-app-engine",
"django-models",
"model"
] |
Filter and sort music info on Google App Engine | 1,213,959 | <p>I've enjoyed building out a couple simple applications on the GAE, but now I'm stumped about how to architect a music collection organizer on the app engine. In brief, I can't figure out how to filter on multiple properties while sorting on another.</p>
<p>Let's assume the core model is an Album that contains seve... | 1 | 2009-07-31T17:55:20Z | 1,220,528 | <p>Since storage is cheap, you could create your own ListProperty based indexfiles with key_names that reflect the sort criteria. </p>
<pre><code>class album_pubyear_List(db.Model):
words = db.StringListProperty()
class album_length_List(db.Model):
words = db.StringListProperty()
class album_artist_List(db.M... | 1 | 2009-08-03T03:06:11Z | [
"python",
"google-app-engine",
"django-models",
"model"
] |
Remove ppc from compilation flags in python setup scripts | 1,214,133 | <p>I'm trying to install PIL on an Intel Mac OS X Leopard machine. Unfortunately, "setup.py build" thinks it should be compiling for ppc.</p>
<pre><code>gcc -arch ppc -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -fno-strict-aliasing -Wno-long-double -no-cpp-precomp -mno-fused-madd -fno-common -dynamic -DNDEBU... | 7 | 2009-07-31T18:34:03Z | 1,214,163 | <p>The easiest solution (for a single or a few C files) is to copy the compiler line, edit it, and invoke it manually, then run setup.py again - it should notice that this step was already done.</p>
<p>To make setup.py not use these options anymore, you need to change the Makefile in Python's config directory, and rem... | 2 | 2009-07-31T18:40:10Z | [
"python",
"python-imaging-library"
] |
Remove ppc from compilation flags in python setup scripts | 1,214,133 | <p>I'm trying to install PIL on an Intel Mac OS X Leopard machine. Unfortunately, "setup.py build" thinks it should be compiling for ppc.</p>
<pre><code>gcc -arch ppc -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -fno-strict-aliasing -Wno-long-double -no-cpp-precomp -mno-fused-madd -fno-common -dynamic -DNDEBU... | 7 | 2009-07-31T18:34:03Z | 5,808,548 | <p>The solution that worked for me was:</p>
<p>ARCHFLAGS="-arch i386 -arch x86_64" python setup.py build</p>
<p>Just pass the values for the flag right in the command line.</p>
| 17 | 2011-04-27T18:07:07Z | [
"python",
"python-imaging-library"
] |
Django transaction.commit_on_success not rolling back transaction | 1,214,143 | <p>I'm trying to use Django transactions on MySQL with <a href="http://docs.djangoproject.com/en/dev/topics/db/transactions/#django-db-transaction-commit-on-success" rel="nofollow">the <code>commit_on_success</code> decorator</a>. According to the documentation, "If the function raises an exception, though, Django wil... | 2 | 2009-07-31T18:35:29Z | 1,214,224 | <p>Apparently MySQL doesn't support transactions with MyISAM tables, which is the default type of tables. InnoDB tables do support transactions, so I'll recreate the tables and then see whether the transactions work then.</p>
| 3 | 2009-07-31T18:53:54Z | [
"python",
"mysql",
"django",
"transactions"
] |
Django transaction.commit_on_success not rolling back transaction | 1,214,143 | <p>I'm trying to use Django transactions on MySQL with <a href="http://docs.djangoproject.com/en/dev/topics/db/transactions/#django-db-transaction-commit-on-success" rel="nofollow">the <code>commit_on_success</code> decorator</a>. According to the documentation, "If the function raises an exception, though, Django wil... | 2 | 2009-07-31T18:35:29Z | 1,214,406 | <p>From <a href="http://docs.djangoproject.com/en/dev/ref/databases/" rel="nofollow">http://docs.djangoproject.com/en/dev/ref/databases/</a>:</p>
<p>"The default engine is MyISAM [1]. The main drawback of MyISAM is that it doesn't currently support transactions or foreign keys. On the plus side, it's currently the onl... | 8 | 2009-07-31T19:26:34Z | [
"python",
"mysql",
"django",
"transactions"
] |
Multiple periodic timers | 1,214,164 | <p>Is there any standard python module for creating multiple periodic timers.
I want to design a system which supports creating multiple periodic timers of different periodicity running in just one thread. The system should be able to cancel a specific timer at any point of time.</p>
<p>Thanks in advance for any input... | 3 | 2009-07-31T18:40:20Z | 1,214,352 | <p>If you have to stick with 1 thread - maintain a list of tasks, along with the frequency they should execute and what function should be called:</p>
<pre><code>import time
def example1():
print 'Example'
class Task(object):
def __init__(self, func, delay, args=()):
self.args = args
self.fun... | 1 | 2009-07-31T19:17:47Z | [
"python"
] |
Multiple periodic timers | 1,214,164 | <p>Is there any standard python module for creating multiple periodic timers.
I want to design a system which supports creating multiple periodic timers of different periodicity running in just one thread. The system should be able to cancel a specific timer at any point of time.</p>
<p>Thanks in advance for any input... | 3 | 2009-07-31T18:40:20Z | 1,215,690 | <p>Check out the <a href="http://docs.python.org/search.html?q=sched">sched</a> module in Python's standard library -- per se, it doesn't directly support periodic timers, only one-off "events", but the standard trick to turn a one-off event into a periodic timer applies (the callable handling the one-off event just re... | 6 | 2009-08-01T02:38:48Z | [
"python"
] |
Basic Python dictionary question | 1,214,422 | <p>I have a dictionary with one key and two values and I want to set each value to a separate variable.</p>
<p>d= {'key' : ('value1, value2'),
'key2' : ('value3, value4'),
'key3' : ('value5, value6')}</p>
<p>I tried d[key][0] in the hope it would return "value1" but instead it return "v"</p>
<p>Any sug... | 2 | 2009-07-31T19:28:50Z | 1,214,430 | <p>Try something like this:</p>
<pre><code>d = {'key' : 'value1, value2'}
list = d['key'].split(', ')
</code></pre>
<p><code>list[0]</code> will be "value1" and <code>list[1]</code> will be "value2".</p>
| 4 | 2009-07-31T19:30:36Z | [
"python",
"dictionary"
] |
Basic Python dictionary question | 1,214,422 | <p>I have a dictionary with one key and two values and I want to set each value to a separate variable.</p>
<p>d= {'key' : ('value1, value2'),
'key2' : ('value3, value4'),
'key3' : ('value5, value6')}</p>
<p>I tried d[key][0] in the hope it would return "value1" but instead it return "v"</p>
<p>Any sug... | 2 | 2009-07-31T19:28:50Z | 1,214,443 | <p>A better solution is to store your value as a two-tuple:</p>
<pre><code>d = {'key' : ('value1', 'value2')}
</code></pre>
<p>That way you don't have to split every time you want to access the values.</p>
| 16 | 2009-07-31T19:32:22Z | [
"python",
"dictionary"
] |
Basic Python dictionary question | 1,214,422 | <p>I have a dictionary with one key and two values and I want to set each value to a separate variable.</p>
<p>d= {'key' : ('value1, value2'),
'key2' : ('value3, value4'),
'key3' : ('value5, value6')}</p>
<p>I tried d[key][0] in the hope it would return "value1" but instead it return "v"</p>
<p>Any sug... | 2 | 2009-07-31T19:28:50Z | 1,214,455 | <p>I would suggest storing lists in your dictionary. It'd make it much easier to reference. For instance,</p>
<pre><code>from collections import defaultdict
my_dict = defaultdict(list)
my_dict["key"].append("value 1")
my_dict["key"].append("value 2")
print my_dict["key"][1]
</code></pre>
| 1 | 2009-07-31T19:33:51Z | [
"python",
"dictionary"
] |
Basic Python dictionary question | 1,214,422 | <p>I have a dictionary with one key and two values and I want to set each value to a separate variable.</p>
<p>d= {'key' : ('value1, value2'),
'key2' : ('value3, value4'),
'key3' : ('value5, value6')}</p>
<p>I tried d[key][0] in the hope it would return "value1" but instead it return "v"</p>
<p>Any sug... | 2 | 2009-07-31T19:28:50Z | 1,214,461 | <p>To obtain the two values and assign them to value1 and value2:</p>
<pre><code>for v in d.itervalues():
value1, value2 = v.split(', ')
</code></pre>
<p>As said by zenazn, I wouldn't consider this to be a sensible data structure, using a tuple or a class to store the multiple values would be better.</p>
| 1 | 2009-07-31T19:35:28Z | [
"python",
"dictionary"
] |
Basic Python dictionary question | 1,214,422 | <p>I have a dictionary with one key and two values and I want to set each value to a separate variable.</p>
<p>d= {'key' : ('value1, value2'),
'key2' : ('value3, value4'),
'key3' : ('value5, value6')}</p>
<p>I tried d[key][0] in the hope it would return "value1" but instead it return "v"</p>
<p>Any sug... | 2 | 2009-07-31T19:28:50Z | 1,214,606 | <p>The way you're storing your values, you'll need something like:</p>
<pre><code>value1, value2 = d['key'].split(', ')
print value1, value2
</code></pre>
<p>or to iterate over all values:</p>
<pre><code>for key in d:
v1, v2 = d[k].split(', ')
print v1, v2
</code></pre>
<p>But, if you can, you should probab... | 0 | 2009-07-31T20:08:19Z | [
"python",
"dictionary"
] |
Allowing the " - " character in usernames in the Django Admin interface | 1,214,453 | <p>In our webapp we needed to allow dashes "-" in our usernames.
I've enabled that for the consumer signup process just fine with this regex
r'^[\w-]+$' </p>
<p>How can I tell the admin app so that I can edit usernames in auth > users to allows the "-" character in usernames? Currently I am unable to edit any userna... | 7 | 2009-07-31T19:33:23Z | 1,214,660 | <p>This should be as simple as overriding the behavior of the User ModelAdmin class. In one of your apps, in <code>admin.py</code> include the following code.</p>
<pre><code>from django.contrib import admin
from django import forms
from django.contrib.auth.models import User
from django.contrib.auth.admin import UserA... | 17 | 2009-07-31T20:18:53Z | [
"python",
"django",
"django-admin"
] |
How to get environment from a subprocess in Python | 1,214,496 | <p>I want to call a process via a python program, however, this process need some specific environment variables that are set by another process. How can I get the first process environment variables to pass them to the second?</p>
<p>This is what the program look like:</p>
<pre><code>import subprocess
subprocess.ca... | 12 | 2009-07-31T19:44:22Z | 1,214,515 | <p>As you say, processes don't share the environment - so what you literally ask is not possible, not only in Python, but with any programming language.</p>
<p>What you <em>can</em> do is to put the environment variables in a file, or in a pipe, and either</p>
<ul>
<li>have the parent process read them, and pass them... | 2 | 2009-07-31T19:48:31Z | [
"python",
"environment-variables",
"subprocess",
"popen"
] |
How to get environment from a subprocess in Python | 1,214,496 | <p>I want to call a process via a python program, however, this process need some specific environment variables that are set by another process. How can I get the first process environment variables to pass them to the second?</p>
<p>This is what the program look like:</p>
<pre><code>import subprocess
subprocess.ca... | 12 | 2009-07-31T19:44:22Z | 1,214,517 | <p>Environment is inherited from the parent process. Set the environment you need in the main script, not a subprocess (child).</p>
| 1 | 2009-07-31T19:49:06Z | [
"python",
"environment-variables",
"subprocess",
"popen"
] |
How to get environment from a subprocess in Python | 1,214,496 | <p>I want to call a process via a python program, however, this process need some specific environment variables that are set by another process. How can I get the first process environment variables to pass them to the second?</p>
<p>This is what the program look like:</p>
<pre><code>import subprocess
subprocess.ca... | 12 | 2009-07-31T19:44:22Z | 1,214,518 | <p>Two things spring to mind: (1) make the processes share the same environment, by combining them somehow into the same process, or (2) have the first process produce output that contains the relevant environment variables, that way Python can read it and construct the environment for the second process. I think (thou... | 0 | 2009-07-31T19:49:12Z | [
"python",
"environment-variables",
"subprocess",
"popen"
] |
How to get environment from a subprocess in Python | 1,214,496 | <p>I want to call a process via a python program, however, this process need some specific environment variables that are set by another process. How can I get the first process environment variables to pass them to the second?</p>
<p>This is what the program look like:</p>
<pre><code>import subprocess
subprocess.ca... | 12 | 2009-07-31T19:44:22Z | 1,214,802 | <p><a href="http://docs.python.org/library/multiprocessing.html" rel="nofollow">The Python standard module multiprocessing</a> have a Queues system that allow you to pass pickle-able object to be passed through processes. Also processes can exchange messages (a pickled object) using os.pipe. Remember that resources (e.... | 0 | 2009-07-31T20:44:51Z | [
"python",
"environment-variables",
"subprocess",
"popen"
] |
How to get environment from a subprocess in Python | 1,214,496 | <p>I want to call a process via a python program, however, this process need some specific environment variables that are set by another process. How can I get the first process environment variables to pass them to the second?</p>
<p>This is what the program look like:</p>
<pre><code>import subprocess
subprocess.ca... | 12 | 2009-07-31T19:44:22Z | 1,215,189 | <p>Since you're apparently in Windows, you need a Windows answer.</p>
<p>Create a wrapper batch file, eg. "run_program.bat", and run both programs:</p>
<pre><code>@echo off
call proc1.bat
proc2
</code></pre>
<p>The script will run and set its environment variables. Both scripts run in the same interpreter (cmd.exe ... | 1 | 2009-07-31T22:31:09Z | [
"python",
"environment-variables",
"subprocess",
"popen"
] |
How to get environment from a subprocess in Python | 1,214,496 | <p>I want to call a process via a python program, however, this process need some specific environment variables that are set by another process. How can I get the first process environment variables to pass them to the second?</p>
<p>This is what the program look like:</p>
<pre><code>import subprocess
subprocess.ca... | 12 | 2009-07-31T19:44:22Z | 2,214,292 | <p>Here's an example of how you can extract environment variables from a batch or cmd file without creating a wrapper script. Enjoy.</p>
<pre><code>from __future__ import print_function
import sys
import subprocess
import itertools
def validate_pair(ob):
try:
if not (len(ob) == 2):
print("Unex... | 21 | 2010-02-06T18:53:31Z | [
"python",
"environment-variables",
"subprocess",
"popen"
] |
XSLT Transform of Unicode source | 1,214,733 | <p>In my application I am using the <a href="http://4suite.org/docs/CoreManual.xml#xslt%5Fengine" rel="nofollow">4Suite.org XSLT library</a> to perform transformations of source XML. The syntax is like this:</p>
<pre><code>from Ft.Xml.Xslt import Transform
transformed_xml = Transform(raw_xml, stylesheet)
</code></pre... | 0 | 2009-07-31T20:33:18Z | 1,214,763 | <p>You are likely better off using the more modern and actively maintained <a href="http://codespeak.net/lxml/xpathxslt.html#xslt" rel="nofollow">lxml</a>.</p>
| 2 | 2009-07-31T20:39:30Z | [
"python",
"xslt",
"unicode"
] |
XSLT Transform of Unicode source | 1,214,733 | <p>In my application I am using the <a href="http://4suite.org/docs/CoreManual.xml#xslt%5Fengine" rel="nofollow">4Suite.org XSLT library</a> to perform transformations of source XML. The syntax is like this:</p>
<pre><code>from Ft.Xml.Xslt import Transform
transformed_xml = Transform(raw_xml, stylesheet)
</code></pre... | 0 | 2009-07-31T20:33:18Z | 1,215,184 | <p>I'm not sure <code>Transform</code> actually needs <em>ascii</em> -- looks to me like it should support any encoded Python str. What happens if you call <code>Transform(raw_xml.encode('utf8'), stylesheet)</code> (and then decode the resulting utf8-encoded string back to Unicode when you're done processing it of cour... | 2 | 2009-07-31T22:29:37Z | [
"python",
"xslt",
"unicode"
] |
Counting and filtering objects in a database with Django | 1,214,740 | <p>I'm struggling a little to work out how to follow the relation and count fields of objects.</p>
<p>In my Django site, I have a profile model:</p>
<pre><code>user = models.ForeignKey(User, unique=True)
name = models.CharField(_('name'), null=True, blank=True)
about = models.TextField(_('about'), null=True, blank=Tr... | 1 | 2009-07-31T20:35:10Z | 1,214,775 | <p>You should be able to get them using:</p>
<pre><code>Profile.objects.filter(name__isnull=False)
</code></pre>
| 1 | 2009-07-31T20:40:55Z | [
"python",
"django",
"django-models"
] |
Filtering dictionaries and creating sub-dictionaries based on keys/values in Python? | 1,214,968 | <p>Ok, I'm stuck, need some help from here on... </p>
<p>If I've got a main dictionary like this:</p>
<pre><code>data = [ {"key1": "value1", "key2": "value2", "key1": "value3"},
{"key1": "value4", "key2": "value5", "key1": "value6"},
{"key1": "value1", "key2": "value8", "key1": "value9"} ]
</code></pre>
<p>Now, I... | 5 | 2009-07-31T21:22:52Z | 1,215,024 | <p>The answer is too simple, so I guess we are missing some information. Anyway:</p>
<pre><code>result = []
for datadict in data:
for key, value in datadict.items():
thefiltering()
if datadict.get('matchkey') == 'matchvalue':
result.append(datadict)
</code></pre>
<p>Also, you "main dictionary... | 1 | 2009-07-31T21:39:32Z | [
"python",
"list",
"dictionary",
"filter"
] |
Filtering dictionaries and creating sub-dictionaries based on keys/values in Python? | 1,214,968 | <p>Ok, I'm stuck, need some help from here on... </p>
<p>If I've got a main dictionary like this:</p>
<pre><code>data = [ {"key1": "value1", "key2": "value2", "key1": "value3"},
{"key1": "value4", "key2": "value5", "key1": "value6"},
{"key1": "value1", "key2": "value8", "key1": "value9"} ]
</code></pre>
<p>Now, I... | 5 | 2009-07-31T21:22:52Z | 1,215,039 | <p>Here is a not so pretty way of doing it. The result is a generator, but if you really want a list you can surround it with a call to <code>list()</code>. Mostly it doesn't matter.</p>
<p>The predicate is a function which decides for each key/value pair if a dictionary in the list is going to cut it. The default one... | 9 | 2009-07-31T21:44:29Z | [
"python",
"list",
"dictionary",
"filter"
] |
Filtering dictionaries and creating sub-dictionaries based on keys/values in Python? | 1,214,968 | <p>Ok, I'm stuck, need some help from here on... </p>
<p>If I've got a main dictionary like this:</p>
<pre><code>data = [ {"key1": "value1", "key2": "value2", "key1": "value3"},
{"key1": "value4", "key2": "value5", "key1": "value6"},
{"key1": "value1", "key2": "value8", "key1": "value9"} ]
</code></pre>
<p>Now, I... | 5 | 2009-07-31T21:22:52Z | 1,215,173 | <p>Net of the issues already pointed out in other comments and answers (multiple identical keys can't be in a dict, etc etc), here's how I'd do it:</p>
<pre><code>def select_sublist(list_of_dicts, **kwargs):
return [d for d in list_of_dicts
if all(d.get(k)==kwargs[k] for k in kwargs)]
subdata = selec... | 3 | 2009-07-31T22:24:15Z | [
"python",
"list",
"dictionary",
"filter"
] |
Filtering dictionaries and creating sub-dictionaries based on keys/values in Python? | 1,214,968 | <p>Ok, I'm stuck, need some help from here on... </p>
<p>If I've got a main dictionary like this:</p>
<pre><code>data = [ {"key1": "value1", "key2": "value2", "key1": "value3"},
{"key1": "value4", "key2": "value5", "key1": "value6"},
{"key1": "value1", "key2": "value8", "key1": "value9"} ]
</code></pre>
<p>Now, I... | 5 | 2009-07-31T21:22:52Z | 3,602,315 | <p>Inspired by the answer of Skurmedal, I split this into a recursive scheme to work with a database of nested dictionaries. In this case, a "record" is the subdictionary at the trunk. The predicate defines which records we are after -- those that match some (key,value) pair where these pairs may be deeply nested.</p>
... | 0 | 2010-08-30T16:33:07Z | [
"python",
"list",
"dictionary",
"filter"
] |
Filtering dictionaries and creating sub-dictionaries based on keys/values in Python? | 1,214,968 | <p>Ok, I'm stuck, need some help from here on... </p>
<p>If I've got a main dictionary like this:</p>
<pre><code>data = [ {"key1": "value1", "key2": "value2", "key1": "value3"},
{"key1": "value4", "key2": "value5", "key1": "value6"},
{"key1": "value1", "key2": "value8", "key1": "value9"} ]
</code></pre>
<p>Now, I... | 5 | 2009-07-31T21:22:52Z | 32,983,032 | <p>It's an old question, but for some reason there is no one-liner syntax answer:</p>
<pre><code>{ k: v for k, v in <SOURCE_DICTIONARY>.iteritems() if <CONDITION> }
</code></pre>
<p>For example:</p>
<pre><code>src_dict = { 1: 'a', 2: 'b', 3: 'c', 4: 'd' }
predicate = lambda k, v: k % 2 == 0
filtered_dict... | 0 | 2015-10-07T02:53:38Z | [
"python",
"list",
"dictionary",
"filter"
] |
oauth google using python | 1,215,033 | <p>i am fairly new to programming for web. and i want to start from scratch here.
i tried to search the net but ended up completely confused.
now what i want to learn is how to authenticate a google account through a python script.
can anyone please provide me with a code fragment or any example.</p>
<p>thanks a lot ... | 11 | 2009-07-31T21:42:37Z | 1,215,073 | <p>try this <a href="http://oauth.googlecode.com/svn/code/python/oauth/example/" rel="nofollow">example</a></p>
| 3 | 2009-07-31T21:56:02Z | [
"python",
"oauth"
] |
oauth google using python | 1,215,033 | <p>i am fairly new to programming for web. and i want to start from scratch here.
i tried to search the net but ended up completely confused.
now what i want to learn is how to authenticate a google account through a python script.
can anyone please provide me with a code fragment or any example.</p>
<p>thanks a lot ... | 11 | 2009-07-31T21:42:37Z | 1,215,078 | <p>See the document on Google Data API docs:</p>
<ul>
<li><a href="http://code.google.com/apis/gdata/articles/python%5Fclient%5Flib.html" rel="nofollow">Getting Started with the Google Data Python Library</a></li>
</ul>
<p>There's a ClientLogin sample under "Hello World".</p>
| 0 | 2009-07-31T21:56:55Z | [
"python",
"oauth"
] |
oauth google using python | 1,215,033 | <p>i am fairly new to programming for web. and i want to start from scratch here.
i tried to search the net but ended up completely confused.
now what i want to learn is how to authenticate a google account through a python script.
can anyone please provide me with a code fragment or any example.</p>
<p>thanks a lot ... | 11 | 2009-07-31T21:42:37Z | 1,215,081 | <p>Good intro:
<a href="http://code.google.com/apis/accounts/docs/OAuth.html" rel="nofollow">http://code.google.com/apis/accounts/docs/OAuth.html</a></p>
<p>Great working, playable example: <a href="http://googlecodesamples.com/oauth%5Fplayground/" rel="nofollow">http://googlecodesamples.com/oauth_playground/</a></p>... | 1 | 2009-07-31T21:57:39Z | [
"python",
"oauth"
] |
oauth google using python | 1,215,033 | <p>i am fairly new to programming for web. and i want to start from scratch here.
i tried to search the net but ended up completely confused.
now what i want to learn is how to authenticate a google account through a python script.
can anyone please provide me with a code fragment or any example.</p>
<p>thanks a lot ... | 11 | 2009-07-31T21:42:37Z | 1,572,565 | <p>Some good links above (the playground is invaluable).</p>
<p>I use a mixture of Leah Culver's oAuth code (the example in b3rx's post) and <a href="http://fireeagle.yahoo.net/developer/documentation/python%5Fwalkthru" rel="nofollow">FireEagle's Python OAuth code</a>. The former, the last time I looked, was lacking s... | 0 | 2009-10-15T14:00:06Z | [
"python",
"oauth"
] |
oauth google using python | 1,215,033 | <p>i am fairly new to programming for web. and i want to start from scratch here.
i tried to search the net but ended up completely confused.
now what i want to learn is how to authenticate a google account through a python script.
can anyone please provide me with a code fragment or any example.</p>
<p>thanks a lot ... | 11 | 2009-07-31T21:42:37Z | 5,592,986 | <p>I spent a whole day on coding this, after several failed attempts over the past few weeks. This only gets you as far as the first step, but it does so without any external libraries. And yes, I know it's close to two years after the OP, but from what I could see it still needed to be done.</p>
<pre><code>
#!/usr/bi... | 19 | 2011-04-08T09:14:37Z | [
"python",
"oauth"
] |
How might I remove duplicate lines from a file? | 1,215,208 | <p>I have a file with one column. How to delete repeated lines in a file?</p>
| 17 | 2009-07-31T22:37:44Z | 1,215,234 | <p>If you're on *nix, try running the following command:</p>
<pre><code>sort <file name> | uniq
</code></pre>
| 23 | 2009-07-31T22:43:14Z | [
"python",
"text",
"file-io"
] |
How might I remove duplicate lines from a file? | 1,215,208 | <p>I have a file with one column. How to delete repeated lines in a file?</p>
| 17 | 2009-07-31T22:37:44Z | 1,215,244 | <p>On Unix/Linux, use the <code>uniq</code> command, as per David Locke's answer, or <code>sort</code>, as per William Pursell's comment.</p>
<p>If you need a Python script:</p>
<pre><code>lines_seen = set() # holds lines already seen
outfile = open(outfilename, "w")
for line in open(infilename, "r"):
if line not... | 45 | 2009-07-31T22:46:20Z | [
"python",
"text",
"file-io"
] |
How might I remove duplicate lines from a file? | 1,215,208 | <p>I have a file with one column. How to delete repeated lines in a file?</p>
| 17 | 2009-07-31T22:37:44Z | 1,216,544 | <pre><code>uniqlines = set(open('/tmp/foo').readlines())
</code></pre>
<p>this will give you the list of unique lines.</p>
<p>writing that back to some file would be as easy as:</p>
<pre><code>bar = open('/tmp/bar', 'w').writelines(set(uniqlines))
bar.close()
</code></pre>
| 10 | 2009-08-01T12:51:25Z | [
"python",
"text",
"file-io"
] |
How might I remove duplicate lines from a file? | 1,215,208 | <p>I have a file with one column. How to delete repeated lines in a file?</p>
| 17 | 2009-07-31T22:37:44Z | 1,216,798 | <p>get all your lines in the list and make a set of lines and you are done.
for example,</p>
<pre><code>>>> x = ["line1","line2","line3","line2","line1"]
>>> list(set(x))
['line3', 'line2', 'line1']
>>>
</code></pre>
<p>and write the content back to the file.</p>
| 3 | 2009-08-01T15:18:15Z | [
"python",
"text",
"file-io"
] |
How might I remove duplicate lines from a file? | 1,215,208 | <p>I have a file with one column. How to delete repeated lines in a file?</p>
| 17 | 2009-07-31T22:37:44Z | 17,356,204 | <p>Here is my solution</p>
<pre><code>if __name__ == '__main__':
f = open('temp.txt','w+')
flag = False
with open('file.txt') as fp:
for line in fp:
for temp in f:
if temp == line:
flag = True
print('Found Match')
break
if flag == False:
... | -1 | 2013-06-28T02:15:04Z | [
"python",
"text",
"file-io"
] |
How might I remove duplicate lines from a file? | 1,215,208 | <p>I have a file with one column. How to delete repeated lines in a file?</p>
| 17 | 2009-07-31T22:37:44Z | 18,810,771 | <p><strong>Python One liners :</strong></p>
<pre><code>python -c "import sys; lines = sys.stdin.readlines(); print ''.join(sorted(set(lines)))" < InputFile > OutputFile
</code></pre>
| 2 | 2013-09-15T09:16:39Z | [
"python",
"text",
"file-io"
] |
How might I remove duplicate lines from a file? | 1,215,208 | <p>I have a file with one column. How to delete repeated lines in a file?</p>
| 17 | 2009-07-31T22:37:44Z | 24,097,615 | <p>You can do:</p>
<pre><code>import os
os.system("awk '!x[$0]++' /path/to/file > /path/to/rem-dups")
</code></pre>
<p>Here You are using bash into python :)</p>
<p>You have also other way:</p>
<pre><code>with open('/tmp/result.txt') as result:
uniqlines = set(result.readlines())
with open('/tmp/... | 2 | 2014-06-07T13:15:58Z | [
"python",
"text",
"file-io"
] |
How might I remove duplicate lines from a file? | 1,215,208 | <p>I have a file with one column. How to delete repeated lines in a file?</p>
| 17 | 2009-07-31T22:37:44Z | 29,366,486 | <p>Its a rehash of whats already been said here - here what I use.</p>
<pre><code>import optparse
def removeDups(inputfile, outputfile):
lines=open(inputfile, 'r').readlines()
lines_set = set(lines)
out=open(outputfile, 'w')
for line in lines_set:
out.write(line)
def m... | 4 | 2015-03-31T10:29:50Z | [
"python",
"text",
"file-io"
] |
Where can I find useful documentation for pyusb (Python USB library)? | 1,215,399 | <p>I am trying to interact with a keyboard with pyusb but I can't find any documentation or tutorial for it. <a href="http://sourceforge.net/projects/pyusb/">The project homepage</a> has absolutely no information and the installed README file is pretty useless. There is no man page. I found mailing lists but the people... | 7 | 2009-07-31T23:53:23Z | 1,215,465 | <p>Well from what I can see it is an fairly thin ctype wrapper around libusb, so I would start there: <a href="http://libusb.sourceforge.net/api-1.0/">http://libusb.sourceforge.net/api-1.0/</a></p>
| 5 | 2009-08-01T00:25:51Z | [
"python",
"documentation",
"usb"
] |
How to list all class properties | 1,215,408 | <p>I have class SomeClass with properties. For example <code>id</code> and <code>name</code>:</p>
<pre><code>class SomeClass(object):
def __init__(self):
self.__id = None
self.__name = None
def get_id(self):
return self.__id
def set_id(self, value):
self.__id = value
... | 9 | 2009-07-31T23:58:46Z | 1,215,428 | <pre><code>property_names=[p for p in dir(SomeClass) if isinstance(getattr(SomeClass,p),property)]
</code></pre>
| 14 | 2009-08-01T00:05:19Z | [
"python",
"serialization",
"properties"
] |
How to list all class properties | 1,215,408 | <p>I have class SomeClass with properties. For example <code>id</code> and <code>name</code>:</p>
<pre><code>class SomeClass(object):
def __init__(self):
self.__id = None
self.__name = None
def get_id(self):
return self.__id
def set_id(self, value):
self.__id = value
... | 9 | 2009-07-31T23:58:46Z | 1,215,609 | <pre><code>import inspect
def isprop(v):
return isinstance(v, property)
propnames = [name for (name, value) in inspect.getmembers(SomeClass, isprop)]
</code></pre>
<p><code>inspect.getmembers</code> gets inherited members as well (and selects members by a predicate, here we coded <code>isprop</code> because it's n... | 17 | 2009-08-01T01:45:03Z | [
"python",
"serialization",
"properties"
] |
Can a Python function take a generator and return generators to subsets of its generated output? | 1,215,464 | <p>Let's say I have a generator function like this:</p>
<pre><code>import random
def big_gen():
i = 0
group = 'a'
while group != 'd':
i += 1
yield (group, i)
if random.random() < 0.20:
group = chr(ord(group) + 1)
</code></pre>
<p>Example output might be:
('a', 1), ('a', 2), ('a', 3), ('a', ... | 4 | 2009-08-01T00:24:45Z | 1,215,481 | <p>You have a slight problem here. You'd like the function to printer() to take a generator for each group, but in reality you have the same generator yielding all groups. You have two options, as I see it:</p>
<p>1) Change big_gen() to yield generators:</p>
<pre><code>import random
def big_gen():
i = 0
group = '... | 0 | 2009-08-01T00:40:26Z | [
"python",
"generator"
] |
Can a Python function take a generator and return generators to subsets of its generated output? | 1,215,464 | <p>Let's say I have a generator function like this:</p>
<pre><code>import random
def big_gen():
i = 0
group = 'a'
while group != 'd':
i += 1
yield (group, i)
if random.random() < 0.20:
group = chr(ord(group) + 1)
</code></pre>
<p>Example output might be:
('a', 1), ('a', 2), ('a', 3), ('a', ... | 4 | 2009-08-01T00:24:45Z | 1,215,600 | <p>Sure, this does what you want:</p>
<pre><code>import itertools
import operator
def main():
for let, gen in itertools.groupby(big_gen(), key=operator.itemgetter(0)):
secgen = itertools.imap(operator.itemgetter(1), gen)
printer(let, secgen)
</code></pre>
<p><code>groupby</code> does the bulk of the work h... | 8 | 2009-08-01T01:39:01Z | [
"python",
"generator"
] |
Ubuntu + virtualenv = a mess? virtualenv hates dist-packages, wants site-packages | 1,215,610 | <p>Can someone please explain to me what is going on with python in ubuntu 9.04?</p>
<p>I'm trying to spin up <code>virtualenv</code>, and the <code>--no-site-packages</code> flag seems to do nothing with ubuntu. I installed <code>virtualenv 1.3.3</code> with <code>easy_install</code> (which I've upgraded to <code>set... | 15 | 2009-08-01T01:45:22Z | 1,215,627 | <p>I'd be tempted to hack it by making site-packages a link to dist-packages, but I guess this might affect other cases where you want to install some extension other than from the ubuntu dist. I can't think of another answer to 1 except tweaking virtualenv's sources (with both ubuntu and virtualenv being so popular I ... | 9 | 2009-08-01T01:52:29Z | [
"python",
"ubuntu",
"setuptools",
"virtualenv"
] |
Ubuntu + virtualenv = a mess? virtualenv hates dist-packages, wants site-packages | 1,215,610 | <p>Can someone please explain to me what is going on with python in ubuntu 9.04?</p>
<p>I'm trying to spin up <code>virtualenv</code>, and the <code>--no-site-packages</code> flag seems to do nothing with ubuntu. I installed <code>virtualenv 1.3.3</code> with <code>easy_install</code> (which I've upgraded to <code>set... | 15 | 2009-08-01T01:45:22Z | 1,216,108 | <p>Well I have a Ubuntu 9.04 and quickly tried setting up a couple sandboxes with site-packages and one without. And things are working fine.</p>
<p>The only difference in the approach I took is I used Ubuntu's python-virtualenv package (1.3.3). And presume that it is tweaked by Ubuntu team to suit Ubuntu setups.</p>
... | 2 | 2009-08-01T07:50:26Z | [
"python",
"ubuntu",
"setuptools",
"virtualenv"
] |
Ubuntu + virtualenv = a mess? virtualenv hates dist-packages, wants site-packages | 1,215,610 | <p>Can someone please explain to me what is going on with python in ubuntu 9.04?</p>
<p>I'm trying to spin up <code>virtualenv</code>, and the <code>--no-site-packages</code> flag seems to do nothing with ubuntu. I installed <code>virtualenv 1.3.3</code> with <code>easy_install</code> (which I've upgraded to <code>set... | 15 | 2009-08-01T01:45:22Z | 1,558,028 | <p>I believe Mike Orr's answer from <a href="http://groups.google.com/group/python-virtualenv/browse_thread/thread/1412994580f0a2c6/17271fcd6a6e747e?lnk=gst&q=ubuntu+virtualenv#17271fcd6a6e747e" rel="nofollow">the virtual-env mailing list</a> seems to be the best. Note the OP published this question in both places.... | 16 | 2009-10-13T03:09:20Z | [
"python",
"ubuntu",
"setuptools",
"virtualenv"
] |
Ubuntu + virtualenv = a mess? virtualenv hates dist-packages, wants site-packages | 1,215,610 | <p>Can someone please explain to me what is going on with python in ubuntu 9.04?</p>
<p>I'm trying to spin up <code>virtualenv</code>, and the <code>--no-site-packages</code> flag seems to do nothing with ubuntu. I installed <code>virtualenv 1.3.3</code> with <code>easy_install</code> (which I've upgraded to <code>set... | 15 | 2009-08-01T01:45:22Z | 6,919,668 | <p>You really should not touch Ubuntu's Python installation unless you are building system admin tools, or building something that could be considered to be a new system service.</p>
<p>If you are using Ubuntu to develop or deploy Python applications, always build your own Python from source, tar it up, and use that f... | 3 | 2011-08-02T22:51:51Z | [
"python",
"ubuntu",
"setuptools",
"virtualenv"
] |
Ubuntu + virtualenv = a mess? virtualenv hates dist-packages, wants site-packages | 1,215,610 | <p>Can someone please explain to me what is going on with python in ubuntu 9.04?</p>
<p>I'm trying to spin up <code>virtualenv</code>, and the <code>--no-site-packages</code> flag seems to do nothing with ubuntu. I installed <code>virtualenv 1.3.3</code> with <code>easy_install</code> (which I've upgraded to <code>set... | 15 | 2009-08-01T01:45:22Z | 17,265,851 | <p>Another way to fix it:<br>
<a href="http://stackoverflow.com/a/17265840/202168">http://stackoverflow.com/a/17265840/202168</a></p>
<p>Have to remember to do that in each virtualenv where you need it, but doesn't rely on hacks or a special version of virtualenv</p>
| 1 | 2013-06-23T22:17:48Z | [
"python",
"ubuntu",
"setuptools",
"virtualenv"
] |
Search engine woes | 1,215,661 | <p>I have been trying to make this search engine for a MySQL database. Taking in user input is no problem, database querying is also fine.</p>
<p>One thing I need to figure out is this:</p>
<blockquote>
<p>I am a string in the database</p>
</blockquote>
<p>How do I match the input "AM", but keep the same case? The... | 0 | 2009-08-01T02:11:53Z | 1,215,697 | <p>I suggest you read this</p>
<p><a href="http://dev.mysql.com/doc/refman/5.1/en/fulltext-search.html" rel="nofollow">http://dev.mysql.com/doc/refman/5.1/en/fulltext-search.html</a></p>
<p>It may help you build a better search engine and probably answer some part of your question</p>
<p>Here is a good example of w... | 4 | 2009-08-01T02:42:20Z | [
"php",
"javascript",
"python",
"mysql",
"search"
] |
Removing (or prefilling) the address details for PayPal Express Checkout | 1,215,704 | <p>I am looking at using PayPal as a payment option for my custom shopping cart I have built. I already have a cart set up, and a checkout 'complete'. It asks the user for their address. Once they have completed all the fields, they hit 'Pay with PayPal'. This does not send them to PayPal yet. First it processes the da... | 4 | 2009-08-01T02:45:23Z | 1,216,057 | <p>Yes, there is an option in the Paypal API to override the address input. See here:</p>
<p><a href="https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_ECCustomizing#id0864F070OHS__id0864H804030" rel="nofollow">https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content... | 2 | 2009-08-01T07:22:46Z | [
"python",
"django",
"paypal"
] |
Removing (or prefilling) the address details for PayPal Express Checkout | 1,215,704 | <p>I am looking at using PayPal as a payment option for my custom shopping cart I have built. I already have a cart set up, and a checkout 'complete'. It asks the user for their address. Once they have completed all the fields, they hit 'Pay with PayPal'. This does not send them to PayPal yet. First it processes the da... | 4 | 2009-08-01T02:45:23Z | 14,672,025 | <p>In your SetExpressCheckout call you can set "NOSHIPPING" to 1. This removes any shipping address details from being requested on the PayPal payment page. It also means, however, that no shipping details are attached to the payment (if you or the customer want to have that kind of information available from within yo... | 0 | 2013-02-03T11:34:37Z | [
"python",
"django",
"paypal"
] |
Removing (or prefilling) the address details for PayPal Express Checkout | 1,215,704 | <p>I am looking at using PayPal as a payment option for my custom shopping cart I have built. I already have a cart set up, and a checkout 'complete'. It asks the user for their address. Once they have completed all the fields, they hit 'Pay with PayPal'. This does not send them to PayPal yet. First it processes the da... | 4 | 2009-08-01T02:45:23Z | 14,673,250 | <p>David, it's absolutely possible for you to pass in address so it's prefilled for new PayPal customers, or to have PayaPal not ask for it at all. </p>
<p>Once you have gotten that working, however, I'd like to encourage you to also add in PayPal as a "shortcut" that skips straight from a button next to your "checkou... | 0 | 2013-02-03T13:59:12Z | [
"python",
"django",
"paypal"
] |
import serial error occured in Python | 1,215,889 | <p>I wrote</p>
<pre><code>import serial
</code></pre>
<p>There message are occured.</p>
<pre><code>Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/lib/python2.4/site-packages/serial/__init__.py", line 20, in ?
from serialposix import *
File "/usr/lib/python2.4/site-packages... | 0 | 2009-08-01T05:14:51Z | 1,215,904 | <p><code>termios</code> has been in the Python standard library since 2.0 at least (I'm not very familiar with older Python versions), but it's always been a Unix-only module. Your 2.4 should be fine, IF you're running under any Unix flavor -- i.e., anything but Windows, more or less. The problem you're seeing suggest... | 3 | 2009-08-01T05:35:04Z | [
"python",
"serial-port",
"debian"
] |
comparing two strings with 'is' -- not performing as expected | 1,216,259 | <p>I'm attempting to compare two strings with <strong>is</strong>. One string is returned by a function, and the other is just declared in the comparison. <strong>is</strong> tests for object identity, but according to <a href="http://zetcode.com/tutorials/pythontutorial/keywords/" rel="nofollow">this page</a>, it also... | 1 | 2009-08-01T09:44:37Z | 1,216,265 | <p>That page you quoted says "If two string <strong>literals</strong> are equal, they have been put to same memory location" (emphasis mine). Python interns literal strings, but strings that are returned from some arbitrary function are separate objects. The <code>is</code> operator can be thought of as a pointer compa... | 3 | 2009-08-01T09:50:39Z | [
"python",
"string-comparison",
"string-literals"
] |
comparing two strings with 'is' -- not performing as expected | 1,216,259 | <p>I'm attempting to compare two strings with <strong>is</strong>. One string is returned by a function, and the other is just declared in the comparison. <strong>is</strong> tests for object identity, but according to <a href="http://zetcode.com/tutorials/pythontutorial/keywords/" rel="nofollow">this page</a>, it also... | 1 | 2009-08-01T09:44:37Z | 1,216,266 | <p>The site you quote says this:</p>
<blockquote>
<p>If two string literals are equal, they have been put to same memory location.</p>
</blockquote>
<p>But</p>
<pre><code>uSplit('theuser!host')
</code></pre>
<p>is not a string literal -- it's the result of an operation on the literal <code>'theuser!host'</code>.<... | 2 | 2009-08-01T09:51:16Z | [
"python",
"string-comparison",
"string-literals"
] |
comparing two strings with 'is' -- not performing as expected | 1,216,259 | <p>I'm attempting to compare two strings with <strong>is</strong>. One string is returned by a function, and the other is just declared in the comparison. <strong>is</strong> tests for object identity, but according to <a href="http://zetcode.com/tutorials/pythontutorial/keywords/" rel="nofollow">this page</a>, it also... | 1 | 2009-08-01T09:44:37Z | 1,216,268 | <p>What you have run into is the fact that Python does not always intern all of its strings. More detail here:</p>
<p><a href="http://mail.python.org/pipermail/tutor/2009-July/070157.html" rel="nofollow">http://mail.python.org/pipermail/tutor/2009-July/070157.html</a></p>
| 0 | 2009-08-01T09:52:14Z | [
"python",
"string-comparison",
"string-literals"
] |
Django newbie deployment question - ImportError: Could not import settings 'settings' | 1,216,340 | <p>The app runs fine using django internal server however when I use apache + mod_python I get the below error </p>
<p><hr /></p>
<pre><code> File "/usr/local/lib/python2.6/dist-packages/django/conf/__init__.py", line 75, in __init__
raise ImportError, "Could not import settings '%s' (Is it on sys.path? Does it ... | 14 | 2009-08-01T10:34:27Z | 1,216,392 | <p>Your apache configuration should look like this:</p>
<pre><code><Location "/mysite">
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE mysite.settings
PythonOption django.root /mysite
PythonPath "['/root/djangoprojects/', '/root/djangoproj... | 5 | 2009-08-01T11:05:01Z | [
"python",
"django",
"deployment",
"mod-python"
] |
Django newbie deployment question - ImportError: Could not import settings 'settings' | 1,216,340 | <p>The app runs fine using django internal server however when I use apache + mod_python I get the below error </p>
<p><hr /></p>
<pre><code> File "/usr/local/lib/python2.6/dist-packages/django/conf/__init__.py", line 75, in __init__
raise ImportError, "Could not import settings '%s' (Is it on sys.path? Does it ... | 14 | 2009-08-01T10:34:27Z | 1,363,719 | <p>Try changing to the following:</p>
<pre><code><Location "/mysite">
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE mysite.settings
PythonOption django.root /mysite
PythonPath "['/root/djangoprojects', '/var/www'] + sys.path"
PythonDe... | 0 | 2009-09-01T17:43:45Z | [
"python",
"django",
"deployment",
"mod-python"
] |
Is it safe to replace a self object by another object of the same type in a method? | 1,216,356 | <p>I would like to replace an object instance by another instance inside a method like this:</p>
<pre><code>class A:
def method1(self):
self = func(self)
</code></pre>
<p>The object is retrieved from a database.</p>
| 11 | 2009-08-01T10:42:21Z | 1,216,359 | <p>Yes, all that will happen is that you won't be able to reference the current instance of your class <code>A</code> (unless you set another variable to <code>self</code> before you change it.) I wouldn't recommend it though, it makes for less readable code.</p>
<p>Note that you're only changing a variable, just like... | 6 | 2009-08-01T10:44:56Z | [
"python"
] |
Is it safe to replace a self object by another object of the same type in a method? | 1,216,356 | <p>I would like to replace an object instance by another instance inside a method like this:</p>
<pre><code>class A:
def method1(self):
self = func(self)
</code></pre>
<p>The object is retrieved from a database.</p>
| 11 | 2009-08-01T10:42:21Z | 1,216,361 | <p>It is unlikely that replacing the 'self' variable will accomplish whatever you're trying to do, that couldn't just be accomplished by storing the result of func(self) in a different variable. 'self' is effectively a local variable only defined for the duration of the method call, used to pass in the instance of the ... | 21 | 2009-08-01T10:45:18Z | [
"python"
] |
Is it safe to replace a self object by another object of the same type in a method? | 1,216,356 | <p>I would like to replace an object instance by another instance inside a method like this:</p>
<pre><code>class A:
def method1(self):
self = func(self)
</code></pre>
<p>The object is retrieved from a database.</p>
| 11 | 2009-08-01T10:42:21Z | 18,529,310 | <p>It is not a direct answer to the question, but in the posts below there's a solution for what amirouche tried to do:</p>
<ul>
<li><a href="http://stackoverflow.com/questions/2153295/python-object-conversion">Python object conversion</a></li>
<li><a href="http://stackoverflow.com/questions/8062161/can-i-dynamically-... | 5 | 2013-08-30T09:20:57Z | [
"python"
] |
Is it safe to replace a self object by another object of the same type in a method? | 1,216,356 | <p>I would like to replace an object instance by another instance inside a method like this:</p>
<pre><code>class A:
def method1(self):
self = func(self)
</code></pre>
<p>The object is retrieved from a database.</p>
| 11 | 2009-08-01T10:42:21Z | 19,023,873 | <p>One can use the self assignment in a method, to change the class of instance to a derived class. </p>
<p>Of course one could assign it to a new object, but then the use of the new object ripples through the rest of code in the method. Reassiging it to self, leaves the rest of the method untouched.</p>
<pre><code... | 0 | 2013-09-26T09:06:57Z | [
"python"
] |
Is it safe to replace a self object by another object of the same type in a method? | 1,216,356 | <p>I would like to replace an object instance by another instance inside a method like this:</p>
<pre><code>class A:
def method1(self):
self = func(self)
</code></pre>
<p>The object is retrieved from a database.</p>
| 11 | 2009-08-01T10:42:21Z | 37,658,673 | <p>As far as i understand, If you are trying to replace the current object with another object of same type (assuming func wont change the object type) from an member function. I think this will achieve that</p>
<pre><code>class A:
def method1(self):
newObj = func(self)
self.__dict__.update(newObj.__dict__)
</... | 2 | 2016-06-06T13:23:48Z | [
"python"
] |
Newbie to python conventions, is my code on the right track? | 1,216,395 | <p>I've been reading about python for a week now and just thought I'd try my hand at it by creating a tax bracket calculator. I'm not finished but I wanted to know if I'm on the right track or not as far as python programming goes. I've only done a little C++ programming before, and it feels like it shows (good/bad?)... | 1 | 2009-08-01T11:07:55Z | 1,216,413 | <p>There's probably a more efficient way to do this using lists and pairs instead of separate variables for each bracket's limit and rate. For instance, consider the following:</p>
<pre><code># List of (upper-limit, rate) pairs for brackets.
brackets = [ (8350, .10), (33950, .15), (82250, .25), (171550, .28), (372950,... | 13 | 2009-08-01T11:23:11Z | [
"python",
"conventions"
] |
Newbie to python conventions, is my code on the right track? | 1,216,395 | <p>I've been reading about python for a week now and just thought I'd try my hand at it by creating a tax bracket calculator. I'm not finished but I wanted to know if I'm on the right track or not as far as python programming goes. I've only done a little C++ programming before, and it feels like it shows (good/bad?)... | 1 | 2009-08-01T11:07:55Z | 1,216,500 | <p>4 space indenting! Check out this <a href="http://www.python.org/dev/peps/pep-0008/" rel="nofollow">doc</a>, and the <pre><code>import this</code></pre> output for more. Looks pretty good to me though, very easy to read. </p>
| 2 | 2009-08-01T12:14:14Z | [
"python",
"conventions"
] |
Newbie to python conventions, is my code on the right track? | 1,216,395 | <p>I've been reading about python for a week now and just thought I'd try my hand at it by creating a tax bracket calculator. I'm not finished but I wanted to know if I'm on the right track or not as far as python programming goes. I've only done a little C++ programming before, and it feels like it shows (good/bad?)... | 1 | 2009-08-01T11:07:55Z | 1,216,519 | <p>You can change lines like this:</p>
<pre><code>if salary >= 0 and salary <= first_bracket:
</code></pre>
<p>to this:</p>
<pre><code>if 0 <= salary <= first_bracket:
</code></pre>
<p>like you'd do in mathematics. It generally makes the code more readable.</p>
| 2 | 2009-08-01T12:26:13Z | [
"python",
"conventions"
] |
Newbie to python conventions, is my code on the right track? | 1,216,395 | <p>I've been reading about python for a week now and just thought I'd try my hand at it by creating a tax bracket calculator. I'm not finished but I wanted to know if I'm on the right track or not as far as python programming goes. I've only done a little C++ programming before, and it feels like it shows (good/bad?)... | 1 | 2009-08-01T11:07:55Z | 1,216,526 | <p>Tools like <a href="http://www.logilab.org/857" rel="nofollow">PyLint</a> can catch a lot of errors and bad practices, including bad naming conventions. <a href="http://pychecker.sourceforge.net/" rel="nofollow">PyChecker</a> is nice too.</p>
| 0 | 2009-08-01T12:35:02Z | [
"python",
"conventions"
] |
Newbie to python conventions, is my code on the right track? | 1,216,395 | <p>I've been reading about python for a week now and just thought I'd try my hand at it by creating a tax bracket calculator. I'm not finished but I wanted to know if I'm on the right track or not as far as python programming goes. I've only done a little C++ programming before, and it feels like it shows (good/bad?)... | 1 | 2009-08-01T11:07:55Z | 1,216,737 | <p>Particularly when working with financial values, you should consider using the <a href="http://docs.python.org/library/decimal.html" rel="nofollow">decimal</a> module to make sure that there are no floating-point errors in your output.</p>
<p>Not a big deal when you're just making a toy to learn a language, but goo... | 5 | 2009-08-01T14:49:24Z | [
"python",
"conventions"
] |
Newbie to python conventions, is my code on the right track? | 1,216,395 | <p>I've been reading about python for a week now and just thought I'd try my hand at it by creating a tax bracket calculator. I'm not finished but I wanted to know if I'm on the right track or not as far as python programming goes. I've only done a little C++ programming before, and it feels like it shows (good/bad?)... | 1 | 2009-08-01T11:07:55Z | 1,216,804 | <p>Since those functions are fairly simple you could do something like:</p>
<pre><code>def b1(a):
return a * .10
</code></pre>
<p>you could also make one unified taxing function:</p>
<pre><code>def tax_me(salary, rate):
return salary * rate
</code></pre>
<p>Seems like Dav has ya fixed up pretty good :)</p>
... | 1 | 2009-08-01T15:20:47Z | [
"python",
"conventions"
] |
Newbie to python conventions, is my code on the right track? | 1,216,395 | <p>I've been reading about python for a week now and just thought I'd try my hand at it by creating a tax bracket calculator. I'm not finished but I wanted to know if I'm on the right track or not as far as python programming goes. I've only done a little C++ programming before, and it feels like it shows (good/bad?)... | 1 | 2009-08-01T11:07:55Z | 1,217,465 | <p>Structuring the income and tax-rate data as a table (list of tuples or tuple of tuples) is a huge improvement. As shown in that example it allows one to approach the rest of the task with a table driven approach (traverse up the table to find the top rate for a given salary, then traverse from that point downward a... | 1 | 2009-08-01T20:50:45Z | [
"python",
"conventions"
] |
Make python __doc__ property display correctly in a Windows CMD window? | 1,216,697 | <p>In Windows, if I open a command prompt, start python, and inspect something using its __doc__ property, it doesn't display correctly. Instead of the lines being separated, I see one continuous string with the newline character every once and a while.</p>
<p>Is there a way to make it appear correctl... | 1 | 2009-08-01T14:18:10Z | 1,216,700 | <p>try</p>
<pre><code>>>> print hashlib.__doc__
</code></pre>
<p>or (v3)</p>
<pre><code>>>> print(hashlib.__doc__)
</code></pre>
| 3 | 2009-08-01T14:20:26Z | [
"python",
"documentation"
] |
Make python __doc__ property display correctly in a Windows CMD window? | 1,216,697 | <p>In Windows, if I open a command prompt, start python, and inspect something using its __doc__ property, it doesn't display correctly. Instead of the lines being separated, I see one continuous string with the newline character every once and a while.</p>
<p>Is there a way to make it appear correctl... | 1 | 2009-08-01T14:18:10Z | 1,217,015 | <p>Rather than pulling <code>__doc__</code> yourself, try this:</p>
<pre><code>>>> help(hashlib)
</code></pre>
<p>It will give you a nicely formatted summary of the module, including (but not limited to) the docstring.</p>
| 5 | 2009-08-01T17:00:40Z | [
"python",
"documentation"
] |
Make python __doc__ property display correctly in a Windows CMD window? | 1,216,697 | <p>In Windows, if I open a command prompt, start python, and inspect something using its __doc__ property, it doesn't display correctly. Instead of the lines being separated, I see one continuous string with the newline character every once and a while.</p>
<p>Is there a way to make it appear correctl... | 1 | 2009-08-01T14:18:10Z | 18,709,639 | <pre><code>def help_(obj):
if type(obj).__name__ == 'ufunc':
print obj.__doc__
else:
help(obj)
</code></pre>
| 0 | 2013-09-10T01:58:33Z | [
"python",
"documentation"
] |
Python subprocess.Popen erroring with OSError: [Errno 12] Cannot allocate memory after period of time | 1,216,794 | <p><strong>Note</strong>: This question has been re-asked with a summary of all debugging attempts <a href="http://stackoverflow.com/questions/1367373/python-subprocess-popen-oserror-errno-12-cannot-allocate-memory">here</a>.</p>
<p><hr /></p>
<p>I have a Python script that is running as a background process executin... | 8 | 2009-08-01T15:14:30Z | 1,216,824 | <p>You might want to actually wait for all of those PS processes to finish before adding swap space.</p>
<p>It's not at all clear what "running as a background process executing every 60 seconds" means.</p>
<p>But your call to subprocess.Popen is forking a new process each time. </p>
<p><strong>Update</strong>.</p>
... | 1 | 2009-08-01T15:29:39Z | [
"python",
"linux",
"memory"
] |
Python subprocess.Popen erroring with OSError: [Errno 12] Cannot allocate memory after period of time | 1,216,794 | <p><strong>Note</strong>: This question has been re-asked with a summary of all debugging attempts <a href="http://stackoverflow.com/questions/1367373/python-subprocess-popen-oserror-errno-12-cannot-allocate-memory">here</a>.</p>
<p><hr /></p>
<p>I have a Python script that is running as a background process executin... | 8 | 2009-08-01T15:14:30Z | 1,216,917 | <p>I don't think that the circumstances given in the Zenoss article you linked to is the only cause of this message, so it's not clear yet that swap space is definitely the problem. I would advise logging some more information even around successful calls, so that you can see the state of free memory every time just be... | 0 | 2009-08-01T16:15:44Z | [
"python",
"linux",
"memory"
] |
Python subprocess.Popen erroring with OSError: [Errno 12] Cannot allocate memory after period of time | 1,216,794 | <p><strong>Note</strong>: This question has been re-asked with a summary of all debugging attempts <a href="http://stackoverflow.com/questions/1367373/python-subprocess-popen-oserror-errno-12-cannot-allocate-memory">here</a>.</p>
<p><hr /></p>
<p>I have a Python script that is running as a background process executin... | 8 | 2009-08-01T15:14:30Z | 1,269,829 | <p>Have you watched your process over time? </p>
<ul>
<li>lsof </li>
<li>ps -aux | grep -i pname </li>
<li>top</li>
</ul>
<p>All should give interesting information. I am thinking that the process is tying up resources that should be freed up. Is there a chance that it is tying up resource handles (memory blocks, str... | 0 | 2009-08-13T03:08:51Z | [
"python",
"linux",
"memory"
] |
Python subprocess.Popen erroring with OSError: [Errno 12] Cannot allocate memory after period of time | 1,216,794 | <p><strong>Note</strong>: This question has been re-asked with a summary of all debugging attempts <a href="http://stackoverflow.com/questions/1367373/python-subprocess-popen-oserror-errno-12-cannot-allocate-memory">here</a>.</p>
<p><hr /></p>
<p>I have a Python script that is running as a background process executin... | 8 | 2009-08-01T15:14:30Z | 1,270,171 | <p>That swap space answer is bogus. Historically Unix systems wanted swap space available like that, but they don't work that way anymore (and Linux never worked that way). You're not even close to running out of memory, so that's not likely the actual problem - you're running out of some other limited resource.</p>
<... | 3 | 2009-08-13T05:30:15Z | [
"python",
"linux",
"memory"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.