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 |
|---|---|---|---|---|---|---|---|---|---|
Better to install MySQL 32bit or 64bit on my 64bit Intel-based Mac (Perl/Python user)? | 1,436,422 | <p>I have had numerous headaches trying to get the MySQL APIs for Perl and Python working on my 64 bit Macbook Pro (Leopard). I installed the 64 bit version of MySQL, but Googling around now I have the impression that this could be the source of my pain. None of the various blogs and SO answers quite seem to work (fo... | 5 | 2009-09-17T02:23:39Z | 1,436,434 | <p>32-bit and 64-bit libraries don't play nice together. So, it depends whether you're using 32-bit Perl/Python or not.</p>
<p>If you are, you'll need 32-bit MySQL. Chances are your Python, at least, is 32-bit, since both the Apple-shipped Python and the binaries from python.org are 32-bit only. You can build 64-bit ... | 4 | 2009-09-17T02:29:48Z | [
"python",
"mysql",
"perl"
] |
Better to install MySQL 32bit or 64bit on my 64bit Intel-based Mac (Perl/Python user)? | 1,436,422 | <p>I have had numerous headaches trying to get the MySQL APIs for Perl and Python working on my 64 bit Macbook Pro (Leopard). I installed the 64 bit version of MySQL, but Googling around now I have the impression that this could be the source of my pain. None of the various blogs and SO answers quite seem to work (fo... | 5 | 2009-09-17T02:23:39Z | 1,437,190 | <p>You <strong>will</strong> need the 32vit vs 64bit of the MySQL <em>client libraries</em> to match the application you're trying to link them with. However, this not prevent you from connecting to a 64-bit install of MySQL <em>server</em>.</p>
<p>In Unix, the MySQL client libraries support multiple versions of thems... | 2 | 2009-09-17T07:15:51Z | [
"python",
"mysql",
"perl"
] |
Python: Passing a class name as a parameter to a function? | 1,436,444 | <pre><code>class TestSpeedRetrieval(webapp.RequestHandler):
"""
Test retrieval times of various important records in the BigTable database
"""
def get(self):
commandValidated = True
beginTime = time()
itemList = Subscriber.all().fetch(1000)
for item in itemList:
pass
... | 21 | 2009-09-17T02:32:43Z | 1,436,461 | <pre><code>class TestSpeedRetrieval(webapp.RequestHandler):
"""
Test retrieval times of various important records in the BigTable database
"""
def __init__(self, cls):
self.cls = cls
def get(self):
commandValidated = True
beginTime = time()
itemList = self.cls.all().fetch(1000)
... | 13 | 2009-09-17T02:37:09Z | [
"python",
"function"
] |
Python: Passing a class name as a parameter to a function? | 1,436,444 | <pre><code>class TestSpeedRetrieval(webapp.RequestHandler):
"""
Test retrieval times of various important records in the BigTable database
"""
def get(self):
commandValidated = True
beginTime = time()
itemList = Subscriber.all().fetch(1000)
for item in itemList:
pass
... | 21 | 2009-09-17T02:32:43Z | 1,436,462 | <p>If you pass the class object directly, as in your code between "like this" and "or",
you can get its name as the <code>__name__</code> attribute.</p>
<p>Starting with the name (as in your code <em>after</em> "or") makes it REALLY hard (and not unambiguous) to retrieve the class object unless you have some indicatio... | 9 | 2009-09-17T02:37:23Z | [
"python",
"function"
] |
Python: Passing a class name as a parameter to a function? | 1,436,444 | <pre><code>class TestSpeedRetrieval(webapp.RequestHandler):
"""
Test retrieval times of various important records in the BigTable database
"""
def get(self):
commandValidated = True
beginTime = time()
itemList = Subscriber.all().fetch(1000)
for item in itemList:
pass
... | 21 | 2009-09-17T02:32:43Z | 1,436,624 | <p>A slight variation of Ned's code that I used. This is a web application,
so I start it by running the get routine via a URL: <a href="http://localhost:8080/TestSpeedRetrieval" rel="nofollow">http://localhost:8080/TestSpeedRetrieval</a>. I didn't see the need of the <strong>init</strong>. </p>
<pre><code>class Te... | 0 | 2009-09-17T03:47:30Z | [
"python",
"function"
] |
Sharing widgets between PyQT and Boost.Python | 1,436,514 | <p>I was wondering if it was possible to share widgets between PyQt and Boost.Python.</p>
<p>I will be embedding a Python interpreter into an application of mine that uses Qt. I would like users of my application to be able to embed their own UI widgets into UI widgets programmed in C++ and exposed via Boost.Python.<... | 3 | 2009-09-17T02:59:18Z | 1,530,455 | <p>I've tried to write some proxying for this, but I haven't succeeded completely. Here's a start that tries to solve this, but the dir() won't work. Calling functions directly works somewhat.</p>
<p>The idea was to create an additional python object wrapped in SIP and forward any calls/attributes to that object if th... | 2 | 2009-10-07T09:13:36Z | [
"python",
"qt",
"pyqt",
"sip",
"boost-python"
] |
GAE - How Do i edit / update the datastore in python | 1,436,545 | <p>I have this datastore model</p>
<pre><code>class Project(db.Model)
projectname = db.StringProperty()
projecturl = db.StringProperty()
class Task(db.Model)
project = db.ReferenceProperty(Project)
taskname= db.StringProperty()
taskdesc = db.StringProperty()
</code></pre>
<p>How do I edit the value of taskname ? say... | 2 | 2009-09-17T03:12:28Z | 1,436,553 | <p>Given an instance <code>t</code> of <code>Task</code> (e.g. from some <code>get</code> operation on the <code>db</code>) you can perform the alteration you want e.g. by <code>t.taskname = t.taskname + '-project'</code> (if what you want is to "append <code>'-project'</code> to whatever was there before). Eventually,... | 1 | 2009-09-17T03:18:19Z | [
"python",
"google-app-engine",
"gql",
"gqlquery"
] |
GAE - How Do i edit / update the datastore in python | 1,436,545 | <p>I have this datastore model</p>
<pre><code>class Project(db.Model)
projectname = db.StringProperty()
projecturl = db.StringProperty()
class Task(db.Model)
project = db.ReferenceProperty(Project)
taskname= db.StringProperty()
taskdesc = db.StringProperty()
</code></pre>
<p>How do I edit the value of taskname ? say... | 2 | 2009-09-17T03:12:28Z | 1,436,563 | <p>Probably the easiest way is to use the admin console. Locally it's:</p>
<pre><code>http://localhost:8080/_ah/admin
</code></pre>
<p>and if you've uploaded it, it's the dashboard:</p>
<pre><code>http://appengine.google.com/dashboard?&app_id=******
</code></pre>
<p><a href="http://code.google.com/appengine/doc... | -1 | 2009-09-17T03:20:05Z | [
"python",
"google-app-engine",
"gql",
"gqlquery"
] |
GAE - How Do i edit / update the datastore in python | 1,436,545 | <p>I have this datastore model</p>
<pre><code>class Project(db.Model)
projectname = db.StringProperty()
projecturl = db.StringProperty()
class Task(db.Model)
project = db.ReferenceProperty(Project)
taskname= db.StringProperty()
taskdesc = db.StringProperty()
</code></pre>
<p>How do I edit the value of taskname ? say... | 2 | 2009-09-17T03:12:28Z | 1,442,200 | <p>oops sorry, Here is the formatted code:</p>
<p>taskkey = self.request.get("taskkey") <br/>
taskid = Task.get(taskkey)<br/>
query = db.GqlQuery("SELECt * FROM Task WHERE key =:taskid", taskid=taskid)<br/></p>
<p>if query.count() > 0:<br/>
task = Task()<br/>
task.taskname = "task1-project"<br/>
task.put()</p>
<p... | 2 | 2009-09-18T01:30:39Z | [
"python",
"google-app-engine",
"gql",
"gqlquery"
] |
unique pin generator | 1,436,552 | <p>The task is to generate a given number of numeric pins of a given length.
Here's the code I came up with for a particular case of numeric pins that don't start with 0:</p>
<pre><code>def generate_pins(length, count):
return random.sample(range(int('1' + '0' * (length - 1)), int('9' * length)), count)
</code></p... | 0 | 2009-09-17T03:17:49Z | 1,436,574 | <p><code>random.sample</code> guarantees no repetition ("sampling without replacement", per <a href="http://docs.python.org/library/random.html?highlight=random.sample#random.sample" rel="nofollow">the docs</a>); is this condition part of your specs?</p>
<p>As expressed (without any word "<strong>distinct</strong>" to... | 6 | 2009-09-17T03:25:25Z | [
"python"
] |
unique pin generator | 1,436,552 | <p>The task is to generate a given number of numeric pins of a given length.
Here's the code I came up with for a particular case of numeric pins that don't start with 0:</p>
<pre><code>def generate_pins(length, count):
return random.sample(range(int('1' + '0' * (length - 1)), int('9' * length)), count)
</code></p... | 0 | 2009-09-17T03:17:49Z | 1,436,698 | <p>As OP haven't said random PINs, only criteria seems to be unique pins
here is the fastest way</p>
<pre><code>def generate_pins(length, count):
start=10**length
return range(start,start+count,1)
</code></pre>
<p>also you can not always guarantee uniqeness, same length and count at same time
e.g. try generate_pi... | 1 | 2009-09-17T04:25:02Z | [
"python"
] |
Difference between __str__ and __repr__ in Python | 1,436,703 | <p>What is the difference between <code>__str__</code> and <code>__repr__</code> in Python?</p>
| 1,363 | 2009-09-17T04:27:45Z | 1,436,706 | <p>From <a href="http://pyref.infogami.com/%5F%5Fstr%5F%5F" rel="nofollow">http://pyref.infogami.com/%5F%5Fstr%5F%5F</a> by effbot:</p>
<p><code>__str__</code> "computes the "informal" string representation of an object. This differs from <code>__repr__</code> in that it does not have to be a valid Python expression: ... | 4 | 2009-09-17T04:28:52Z | [
"python"
] |
Difference between __str__ and __repr__ in Python | 1,436,703 | <p>What is the difference between <code>__str__</code> and <code>__repr__</code> in Python?</p>
| 1,363 | 2009-09-17T04:27:45Z | 1,436,721 | <p><strong><code>__repr__</code></strong>: representation of python object usually eval will convert it back to that object</p>
<p><strong><code>__str__</code></strong>: is whatever you think is that object in text form</p>
<p>e.g.</p>
<pre><code>>>> s="""w'o"w"""
>>> repr(s)
'\'w\\\'o"w\''
>>... | 99 | 2009-09-17T04:35:36Z | [
"python"
] |
Difference between __str__ and __repr__ in Python | 1,436,703 | <p>What is the difference between <code>__str__</code> and <code>__repr__</code> in Python?</p>
| 1,363 | 2009-09-17T04:27:45Z | 1,436,756 | <p>Unless you specifically act to ensure otherwise, most classes don't have helpful results for either:</p>
<pre><code>>>> class Sic(object): pass
...
>>> print str(Sic())
<__main__.Sic object at 0x8b7d0>
>>> print repr(Sic())
<__main__.Sic object at 0x8b7d0>
>>>
</code... | 215 | 2009-09-17T04:49:40Z | [
"python"
] |
Difference between __str__ and __repr__ in Python | 1,436,703 | <p>What is the difference between <code>__str__</code> and <code>__repr__</code> in Python?</p>
| 1,363 | 2009-09-17T04:27:45Z | 1,438,297 | <p>My rule of thumb: <code>__repr__</code> is for developers, <code>__str__</code> is for customers.</p>
| 205 | 2009-09-17T11:35:13Z | [
"python"
] |
Difference between __str__ and __repr__ in Python | 1,436,703 | <p>What is the difference between <code>__str__</code> and <code>__repr__</code> in Python?</p>
| 1,363 | 2009-09-17T04:27:45Z | 2,626,364 | <p>Alex summarized well but, surprisingly, was too succinct.</p>
<p>First, let me reiterate the main points in Alexâs post:</p>
<ul>
<li>The default implementation is useless (itâs hard to think of one which wouldnât be, but yeah)</li>
<li><code>__repr__</code> goal is to be unambiguous</li>
<li><code>__str__</... | 1,475 | 2010-04-13T00:56:52Z | [
"python"
] |
Difference between __str__ and __repr__ in Python | 1,436,703 | <p>What is the difference between <code>__str__</code> and <code>__repr__</code> in Python?</p>
| 1,363 | 2009-09-17T04:27:45Z | 13,395,755 | <p>In all honesty, <code>eval(repr(obj))</code> is never used. If you find yourself using it, you should stop, because <code>eval</code> is dangerous, and strings are a very inefficient way to serialize your objects (use <code>pickle</code> instead). </p>
<p>Therefore, I would recommend setting <code>__repr__ = __str_... | 6 | 2012-11-15T10:39:22Z | [
"python"
] |
Difference between __str__ and __repr__ in Python | 1,436,703 | <p>What is the difference between <code>__str__</code> and <code>__repr__</code> in Python?</p>
| 1,363 | 2009-09-17T04:27:45Z | 19,597,196 | <blockquote>
<p>In short, the goal of <code>__repr__</code> is to be unambiguous and <code>__str__</code> is to be
readable.</p>
</blockquote>
<p>Here is a good example:</p>
<pre><code>>>> import datetime
>>> today = datetime.datetime.now()
>>> str(today)
'2012-03-14 09:21:58.130922'
&g... | 55 | 2013-10-25T18:38:52Z | [
"python"
] |
Difference between __str__ and __repr__ in Python | 1,436,703 | <p>What is the difference between <code>__str__</code> and <code>__repr__</code> in Python?</p>
| 1,363 | 2009-09-17T04:27:45Z | 28,132,458 | <blockquote>
<h1>What is the difference between <code>__str__</code> and <code>__repr__</code> in Python?</h1>
</blockquote>
<p><code>__str__</code> (read as "dunder (double-underscore) string") and <code>__repr__</code> (read as "dunder-repper" (for "representation")) are both special methods that return strings ba... | 38 | 2015-01-25T02:01:30Z | [
"python"
] |
Difference between __str__ and __repr__ in Python | 1,436,703 | <p>What is the difference between <code>__str__</code> and <code>__repr__</code> in Python?</p>
| 1,363 | 2009-09-17T04:27:45Z | 31,427,937 | <pre><code>>>> print(decimal.Decimal(23) / decimal.Decimal("1.05"))
21.90476190476190476190476190
>>> decimal.Decimal(23) / decimal.Decimal("1.05")
Decimal('21.90476190476190476190476190')
</code></pre>
<p>When print() is called on the result of decimal.Decimal(23) / deci- mal.Decimal("1.05") the raw... | 1 | 2015-07-15T10:30:35Z | [
"python"
] |
Difference between __str__ and __repr__ in Python | 1,436,703 | <p>What is the difference between <code>__str__</code> and <code>__repr__</code> in Python?</p>
| 1,363 | 2009-09-17T04:27:45Z | 33,421,226 | <p>Excellent answers are already cover the difference between <code>__str__</code> and <code>__repr__</code>, which for me boils down to the former being readable even by an end user, and the latter being as useful as possible to developers. Given that, I find that the default implementation of <code>__repr__</code> of... | 0 | 2015-10-29T17:46:48Z | [
"python"
] |
Difference between __str__ and __repr__ in Python | 1,436,703 | <p>What is the difference between <code>__str__</code> and <code>__repr__</code> in Python?</p>
| 1,363 | 2009-09-17T04:27:45Z | 33,727,876 | <blockquote>
<p>One important thing to keep in mind is that container's <code>__str__</code> uses contained objects' <code>__repr__</code>.</p>
</blockquote>
<pre><code>>>> from datetime import datetime
>>> from decimal import Decimal
>>> print (Decimal('52'), datetime.now())
(Decimal('52'... | 0 | 2015-11-16T03:02:21Z | [
"python"
] |
Difference between __str__ and __repr__ in Python | 1,436,703 | <p>What is the difference between <code>__str__</code> and <code>__repr__</code> in Python?</p>
| 1,363 | 2009-09-17T04:27:45Z | 34,734,815 | <p>To put it simply:</p>
<p><code>__str__</code> is used in to show a string representation of your object <strong>to be read easily</strong> by others.</p>
<p><code>__repr__</code> is used to show a string representation of <strong>the</strong> object.</p>
<p>Let's say I want to create a <code>Fraction</code> class... | 1 | 2016-01-12T02:53:49Z | [
"python"
] |
Difference between __str__ and __repr__ in Python | 1,436,703 | <p>What is the difference between <code>__str__</code> and <code>__repr__</code> in Python?</p>
| 1,363 | 2009-09-17T04:27:45Z | 39,382,137 | <p>Apart from all the answers given, I would like to add few points :-</p>
<p>1) <code>__str__()</code> is invoked when you use object with print statement. In case, if <code>__str__</code> is missing, then print invokes <code>__repr__()</code> of object.</p>
<p>2) <code>__repr__()</code> is invoked when you simply w... | 0 | 2016-09-08T03:27:45Z | [
"python"
] |
Python sort() method on list vs builtin sorted() function | 1,436,962 | <p>I know that <code>__builtin__</code> sorted() function works on any iterable. But can someone explain this huge (10x) performance difference between anylist.sort() vs sorted(anylist) ? Also, please point out if I am doing anything wrong with way this is measured. </p>
<pre>
"""
Example Output:
$ python list_sort_ti... | 26 | 2009-09-17T06:07:36Z | 1,436,981 | <p>Well, the <code>.sort()</code> method of lists sorts the list in place, while <code>sorted()</code> creates a new list. So if you have a large list, part of your performance difference will be due to copying.</p>
<p>Still, an order of magnitude difference seems larger than I'd expect. Perhaps <code>list.sort()</c... | 5 | 2009-09-17T06:13:47Z | [
"python",
"sorting"
] |
Python sort() method on list vs builtin sorted() function | 1,436,962 | <p>I know that <code>__builtin__</code> sorted() function works on any iterable. But can someone explain this huge (10x) performance difference between anylist.sort() vs sorted(anylist) ? Also, please point out if I am doing anything wrong with way this is measured. </p>
<pre>
"""
Example Output:
$ python list_sort_ti... | 26 | 2009-09-17T06:07:36Z | 1,436,999 | <p>Because list.sort does in place sorting, so first time it sorts but next time you are sorting the sorted list.</p>
<p>e.g. try this and you will get same results
in timeit case most of the time is spent is copying and sorted also does one more copy</p>
<pre><code>import time
import random
test_list1=random.sample(... | 7 | 2009-09-17T06:20:30Z | [
"python",
"sorting"
] |
Python sort() method on list vs builtin sorted() function | 1,436,962 | <p>I know that <code>__builtin__</code> sorted() function works on any iterable. But can someone explain this huge (10x) performance difference between anylist.sort() vs sorted(anylist) ? Also, please point out if I am doing anything wrong with way this is measured. </p>
<pre>
"""
Example Output:
$ python list_sort_ti... | 26 | 2009-09-17T06:07:36Z | 1,437,009 | <p>Your error in measurement is as follows: after your first call of <code>test_list1.sort()</code>, that list object IS sorted -- and Python's sort, aka <a href="http://svn.python.org/projects/python/trunk/Objects/listsort.txt">timsort</a>, is <strong>wickedly fast</strong> on already sorted lists!!! That's the most ... | 40 | 2009-09-17T06:23:30Z | [
"python",
"sorting"
] |
Python HTML Minimizer | 1,437,357 | <p>I have a cherrypy web server that uses larges amounts of HTML data. Is there anyway in Python to minimize the HTML so that all comments, spaces, ext, are removed?</p>
| 1 | 2009-09-17T07:59:39Z | 1,437,384 | <p><a href="http://tidy.sourceforge.net/" rel="nofollow">HTML Tidy's libtidy</a> doesn't seem to have python bindings (bit it does have perl and c++ etc), but ought to be easy to run as an exe in a pipe.</p>
<p>Or ideally, use it to 'tidy' all static html files once so they don't need to be tidied each time they are s... | 0 | 2009-09-17T08:05:08Z | [
"python",
"html",
"minimize"
] |
Python HTML Minimizer | 1,437,357 | <p>I have a cherrypy web server that uses larges amounts of HTML data. Is there anyway in Python to minimize the HTML so that all comments, spaces, ext, are removed?</p>
| 1 | 2009-09-17T07:59:39Z | 1,437,464 | <p>Not what you mean, but: <a href="http://www.cherrypy.org/wiki/GzipFilter#Gzip" rel="nofollow">Gzip</a>. (Assuming you aren't already serving through a compressing front-end.) Compression will zip away whitespace to almost nothing; unless you have excessively large comments this will be more effective than minificati... | 4 | 2009-09-17T08:27:18Z | [
"python",
"html",
"minimize"
] |
Python HTML Minimizer | 1,437,357 | <p>I have a cherrypy web server that uses larges amounts of HTML data. Is there anyway in Python to minimize the HTML so that all comments, spaces, ext, are removed?</p>
| 1 | 2009-09-17T07:59:39Z | 1,531,684 | <p>there are bindings to tidy for python, called mxTidy from eGenix (Marc André Lemburg)</p>
| 2 | 2009-10-07T13:35:25Z | [
"python",
"html",
"minimize"
] |
How to install iPython on Snow Leopard | 1,437,402 | <p>Does iPython work on Mac OS X 10.6.1 Snow Leopard? I'm python noob, how can I install iPython on my Mac? Links? suggestions?</p>
<p>Thanks</p>
| 10 | 2009-09-17T08:11:26Z | 1,437,514 | <p>To install with the Apple-supplied Python in 10.6:</p>
<pre><code>$ sudo /usr/bin/easy_install-2.6 ipython
</code></pre>
<p>To use:</p>
<pre><code>$ ipython
</code></pre>
| 21 | 2009-09-17T08:37:58Z | [
"python",
"osx",
"ipython"
] |
How to install iPython on Snow Leopard | 1,437,402 | <p>Does iPython work on Mac OS X 10.6.1 Snow Leopard? I'm python noob, how can I install iPython on my Mac? Links? suggestions?</p>
<p>Thanks</p>
| 10 | 2009-09-17T08:11:26Z | 1,466,858 | <p>Though ipython installs and is runnable using easy_install, I found that there were some rendering problems which could only be solved by installing pyreadline as well. However, i found that there were some problems with pyreadline's installation using easy_install. The solution i've gone with involves manually extr... | 0 | 2009-09-23T15:46:12Z | [
"python",
"osx",
"ipython"
] |
How to install iPython on Snow Leopard | 1,437,402 | <p>Does iPython work on Mac OS X 10.6.1 Snow Leopard? I'm python noob, how can I install iPython on my Mac? Links? suggestions?</p>
<p>Thanks</p>
| 10 | 2009-09-17T08:11:26Z | 2,341,928 | <p>I may add that running </p>
<pre><code>$ sudo /usr/bin/easy_install-2.6 readline ipython
</code></pre>
<p>gives you the ability to use tab completion to see the attributes of a module....</p>
| 8 | 2010-02-26T13:32:49Z | [
"python",
"osx",
"ipython"
] |
How to install iPython on Snow Leopard | 1,437,402 | <p>Does iPython work on Mac OS X 10.6.1 Snow Leopard? I'm python noob, how can I install iPython on my Mac? Links? suggestions?</p>
<p>Thanks</p>
| 10 | 2009-09-17T08:11:26Z | 21,849,341 | <p>As with other python extensions, <a href="http://www.pip-installer.org/en/latest/" rel="nofollow">pip</a> makes it quite easy:</p>
<pre><code>sudo pip install ipython
</code></pre>
| 0 | 2014-02-18T09:30:09Z | [
"python",
"osx",
"ipython"
] |
What are the risks (if any) of mixing Psyco into my project? | 1,437,403 | <p>I work on a large financial pricing application in which some long running calculations. We have identified some functions which can be sped up by the selective application of psyco. My management have requested an assessment of the costs & benefits of adding psyco into our stack. </p>
<p>Given the critical na... | 2 | 2009-09-17T08:11:55Z | 1,437,437 | <p>Psyco is a JIT compiler. If your function are stateless, then there should be almost no draw back except more memory.</p>
| 2 | 2009-09-17T08:20:41Z | [
"python",
"psyco"
] |
What are the risks (if any) of mixing Psyco into my project? | 1,437,403 | <p>I work on a large financial pricing application in which some long running calculations. We have identified some functions which can be sped up by the selective application of psyco. My management have requested an assessment of the costs & benefits of adding psyco into our stack. </p>
<p>Given the critical na... | 2 | 2009-09-17T08:11:55Z | 1,437,658 | <p>Why not try profiling it? Psyco has a pretty detailed <a href="http://psyco.sourceforge.net/psycoguide/node23.html" rel="nofollow">logging</a> facility:</p>
<blockquote>
<p><strong>memory usage: x+ kb</strong></p>
<p>Psyco's current notion of how much memory is consumes for the emitted machine code and suppo... | 3 | 2009-09-17T09:10:51Z | [
"python",
"psyco"
] |
Encoding problems in PyQt | 1,437,838 | <p>My program stores file index in file packed by cPickle. There are non-english filenames.
When I just do this</p>
<pre><code>print f [0]
</code></pre>
<p>where f [0] is "\xc2\xe8\xf1\xee\xea\xee\xf1\xed\xfb\xe9 \xe3\xee\xe4" ("ÐиÑокоÑнÑй год" in normal view), it prints the string in proper way â in r... | 0 | 2009-09-17T10:02:00Z | 1,437,872 | <p>Have you run <code>decode</code> on the unpickled string using the correct encoding ("cp1251" by the look of it)? If not, you need to do this to make sure you're passing a Unicode string to the GUI.</p>
| 2 | 2009-09-17T10:12:13Z | [
"python",
"encoding",
"pyqt"
] |
Why does Psyco use a lot of memory? | 1,438,220 | <p><a href="http://psyco.sourceforge.net/" rel="nofollow">Psyco</a> is a specialising compiler for Python. The <a href="http://psyco.sourceforge.net/psycoguide/memlimits.html" rel="nofollow">documentation states</a></p>
<blockquote>
<p>Psyco can and will use large amounts of memory.</p>
</blockquote>
<p>What are th... | 5 | 2009-09-17T11:18:42Z | 1,438,250 | <blockquote>
<p>The memory overhead of Psyco is currently large. I has been reduced a bit over time, but it is still an overhead. <strong>This overhead is proportional to the amount of Python code that Psyco rewrites</strong>; thus if your application has a few algorithmic "core" functions, these are the ones you wil... | 2 | 2009-09-17T11:25:24Z | [
"python",
"memory",
"compiler-construction",
"jit",
"psyco"
] |
Why does Psyco use a lot of memory? | 1,438,220 | <p><a href="http://psyco.sourceforge.net/" rel="nofollow">Psyco</a> is a specialising compiler for Python. The <a href="http://psyco.sourceforge.net/psycoguide/memlimits.html" rel="nofollow">documentation states</a></p>
<blockquote>
<p>Psyco can and will use large amounts of memory.</p>
</blockquote>
<p>What are th... | 5 | 2009-09-17T11:18:42Z | 1,438,279 | <p>From psyco website "The difference with the traditional approach to JIT compilers is that Psyco writes <strong>several version of the same blocks</strong> (a block is a bit of a function), which are optimized by being specialized to some kinds of variables (a "kind" can mean a type, but it is more general)"</p>
| 10 | 2009-09-17T11:31:48Z | [
"python",
"memory",
"compiler-construction",
"jit",
"psyco"
] |
Why does Psyco use a lot of memory? | 1,438,220 | <p><a href="http://psyco.sourceforge.net/" rel="nofollow">Psyco</a> is a specialising compiler for Python. The <a href="http://psyco.sourceforge.net/psycoguide/memlimits.html" rel="nofollow">documentation states</a></p>
<blockquote>
<p>Psyco can and will use large amounts of memory.</p>
</blockquote>
<p>What are th... | 5 | 2009-09-17T11:18:42Z | 1,438,422 | <blockquote>
<p>"Psyco uses the actual run-time data that your program manipulates to write potentially several versions of the machine code, each differently specialized for different kinds of data." <a href="http://psyco.sourceforge.net/introduction.html" rel="nofollow">http://psyco.sourceforge.net/introduction.htm... | 5 | 2009-09-17T12:03:45Z | [
"python",
"memory",
"compiler-construction",
"jit",
"psyco"
] |
Why does Psyco use a lot of memory? | 1,438,220 | <p><a href="http://psyco.sourceforge.net/" rel="nofollow">Psyco</a> is a specialising compiler for Python. The <a href="http://psyco.sourceforge.net/psycoguide/memlimits.html" rel="nofollow">documentation states</a></p>
<blockquote>
<p>Psyco can and will use large amounts of memory.</p>
</blockquote>
<p>What are th... | 5 | 2009-09-17T11:18:42Z | 1,611,658 | <p>Definitely psyco memory usage comes from compiled assembler blocks. Psyco suffers sometimes from overspecialization of functions, which means there are multiple versions of assembler
blocks. Also, which is also very important, psyco never frees once allocated assembler blocks
even if the code assosciated with it is ... | 2 | 2009-10-23T06:17:47Z | [
"python",
"memory",
"compiler-construction",
"jit",
"psyco"
] |
Installing Python Imaging Library (PIL) on Snow Leopard with updated Python 2.6.2 | 1,438,270 | <p>I have a fresh install (started with a wiped drive) of Snow Leopard with the developer tools installed during the Snow Leopard installation.</p>
<p>I then installed Python 2.6.2, replacing the Snow Leopard default python 2.6.1. I've tried to install PIL by:</p>
<ol>
<li><code>easy_install</code></li>
<li><code>pip... | 26 | 2009-09-17T11:29:17Z | 1,438,288 | <p>Do you have <a href="http://developer.apple.com/technology/xcode.html" rel="nofollow">XCode</a> (comes on the Snow Leopard disc) installed? There are some key components (most notably <a href="http://gcc.gnu.org/" rel="nofollow">GCC</a>) that need to be installed which XCode handles for you.</p>
| 0 | 2009-09-17T11:32:52Z | [
"python",
"osx-snow-leopard",
"python-imaging-library"
] |
Installing Python Imaging Library (PIL) on Snow Leopard with updated Python 2.6.2 | 1,438,270 | <p>I have a fresh install (started with a wiped drive) of Snow Leopard with the developer tools installed during the Snow Leopard installation.</p>
<p>I then installed Python 2.6.2, replacing the Snow Leopard default python 2.6.1. I've tried to install PIL by:</p>
<ol>
<li><code>easy_install</code></li>
<li><code>pip... | 26 | 2009-09-17T11:29:17Z | 1,438,358 | <p>IT seems to me that the "No such file" is conjunction with stdarg.h is the most interesting error. There seems to be a header file missing. I don't know how to make sure it's installed on OS X, so this only half an answer, sorry about that, but maybe it pushes you in the right direction.</p>
| 1 | 2009-09-17T11:46:43Z | [
"python",
"osx-snow-leopard",
"python-imaging-library"
] |
Installing Python Imaging Library (PIL) on Snow Leopard with updated Python 2.6.2 | 1,438,270 | <p>I have a fresh install (started with a wiped drive) of Snow Leopard with the developer tools installed during the Snow Leopard installation.</p>
<p>I then installed Python 2.6.2, replacing the Snow Leopard default python 2.6.1. I've tried to install PIL by:</p>
<ol>
<li><code>easy_install</code></li>
<li><code>pip... | 26 | 2009-09-17T11:29:17Z | 1,438,551 | <p>May be you should try pre-build universal binaries from pythonmac site</p>
<p><a href="http://pythonmac.org/packages/py25-fat/index.html" rel="nofollow">http://pythonmac.org/packages/py25-fat/index.html</a></p>
<p>These are for python2.5 , with python2.5 included(so may or may not be usable for you), I have been u... | 1 | 2009-09-17T12:26:29Z | [
"python",
"osx-snow-leopard",
"python-imaging-library"
] |
Installing Python Imaging Library (PIL) on Snow Leopard with updated Python 2.6.2 | 1,438,270 | <p>I have a fresh install (started with a wiped drive) of Snow Leopard with the developer tools installed during the Snow Leopard installation.</p>
<p>I then installed Python 2.6.2, replacing the Snow Leopard default python 2.6.1. I've tried to install PIL by:</p>
<ol>
<li><code>easy_install</code></li>
<li><code>pip... | 26 | 2009-09-17T11:29:17Z | 1,439,772 | <p>The python.org Python was built with an earlier gcc. Try using gcc-4.0 instead of SL's default of 4.2:</p>
<pre><code>export CC=/usr/bin/gcc-4.0
</code></pre>
<p>See similar problem <a href="http://thread.gmane.org/gmane.comp.python.apple/16087" rel="nofollow">here</a>.</p>
<p>That gets past the stdarg problem. ... | 11 | 2009-09-17T16:02:09Z | [
"python",
"osx-snow-leopard",
"python-imaging-library"
] |
Installing Python Imaging Library (PIL) on Snow Leopard with updated Python 2.6.2 | 1,438,270 | <p>I have a fresh install (started with a wiped drive) of Snow Leopard with the developer tools installed during the Snow Leopard installation.</p>
<p>I then installed Python 2.6.2, replacing the Snow Leopard default python 2.6.1. I've tried to install PIL by:</p>
<ol>
<li><code>easy_install</code></li>
<li><code>pip... | 26 | 2009-09-17T11:29:17Z | 1,439,865 | <h1>Modified Answer</h1>
<p>Here are the steps that I took to successfully install PIL on Mac OS X 10.6 (without using MacPorts or Fink).</p>
<ol>
<li><p>Install readline</p>
<pre><code>cd ~/src
curl -O ftp://ftp.cwru.edu/pub/bash/readline-6.0.tar.gz
tar -xvzf readline-6.0.tar.gz
cd readline-6.0
./configure
make ... | 7 | 2009-09-17T16:19:14Z | [
"python",
"osx-snow-leopard",
"python-imaging-library"
] |
Installing Python Imaging Library (PIL) on Snow Leopard with updated Python 2.6.2 | 1,438,270 | <p>I have a fresh install (started with a wiped drive) of Snow Leopard with the developer tools installed during the Snow Leopard installation.</p>
<p>I then installed Python 2.6.2, replacing the Snow Leopard default python 2.6.1. I've tried to install PIL by:</p>
<ol>
<li><code>easy_install</code></li>
<li><code>pip... | 26 | 2009-09-17T11:29:17Z | 1,454,806 | <p>I found a simpler method.
sudo port install python26
sudo port install python_select</p>
<p>Then use python_select set python26 as default.</p>
<p>Then just install PIL as normal.</p>
| 1 | 2009-09-21T14:27:13Z | [
"python",
"osx-snow-leopard",
"python-imaging-library"
] |
Installing Python Imaging Library (PIL) on Snow Leopard with updated Python 2.6.2 | 1,438,270 | <p>I have a fresh install (started with a wiped drive) of Snow Leopard with the developer tools installed during the Snow Leopard installation.</p>
<p>I then installed Python 2.6.2, replacing the Snow Leopard default python 2.6.1. I've tried to install PIL by:</p>
<ol>
<li><code>easy_install</code></li>
<li><code>pip... | 26 | 2009-09-17T11:29:17Z | 1,485,751 | <p>I was able to get PIP installed with SL's Python using these instructions:</p>
<p><a href="http://jetfar.com/libjpeg-and-python-imaging-pil-on-snow-leopard/" rel="nofollow">http://jetfar.com/libjpeg-and-python-imaging-pil-on-snow-leopard/</a></p>
| 1 | 2009-09-28T06:56:18Z | [
"python",
"osx-snow-leopard",
"python-imaging-library"
] |
Installing Python Imaging Library (PIL) on Snow Leopard with updated Python 2.6.2 | 1,438,270 | <p>I have a fresh install (started with a wiped drive) of Snow Leopard with the developer tools installed during the Snow Leopard installation.</p>
<p>I then installed Python 2.6.2, replacing the Snow Leopard default python 2.6.1. I've tried to install PIL by:</p>
<ol>
<li><code>easy_install</code></li>
<li><code>pip... | 26 | 2009-09-17T11:29:17Z | 2,222,294 | <p>The problem I ran into was that PIL was being compiled against PowerPC architecture (-arch ppc).</p>
<p>Do this before setup/build/compile:</p>
<pre><code>export ARCHFLAGS="-arch i386"
</code></pre>
<p>(Assuming you're on i386)</p>
| 18 | 2010-02-08T14:42:02Z | [
"python",
"osx-snow-leopard",
"python-imaging-library"
] |
Installing Python Imaging Library (PIL) on Snow Leopard with updated Python 2.6.2 | 1,438,270 | <p>I have a fresh install (started with a wiped drive) of Snow Leopard with the developer tools installed during the Snow Leopard installation.</p>
<p>I then installed Python 2.6.2, replacing the Snow Leopard default python 2.6.1. I've tried to install PIL by:</p>
<ol>
<li><code>easy_install</code></li>
<li><code>pip... | 26 | 2009-09-17T11:29:17Z | 4,466,057 | <p>10.6 Snow Leopard install PIL without the hassle and without keeping MacPorts :)<br>
<br>
Step 1: Install MacPorts<br>
Step 2: sudo port install py26-pil<br>
Step 3: mv /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/* /Library/Python/2.6/site-packages/<br>
Step 4: Uninstall M... | 3 | 2010-12-16T22:37:04Z | [
"python",
"osx-snow-leopard",
"python-imaging-library"
] |
Installing Python Imaging Library (PIL) on Snow Leopard with updated Python 2.6.2 | 1,438,270 | <p>I have a fresh install (started with a wiped drive) of Snow Leopard with the developer tools installed during the Snow Leopard installation.</p>
<p>I then installed Python 2.6.2, replacing the Snow Leopard default python 2.6.1. I've tried to install PIL by:</p>
<ol>
<li><code>easy_install</code></li>
<li><code>pip... | 26 | 2009-09-17T11:29:17Z | 6,898,875 | <p>Following steps worked for me:</p>
<pre><code>$ brew install pip
$ export ARCHFLAGS="-arch i386 -arch x86_64"
$ pip install pil
</code></pre>
| 2 | 2011-08-01T13:10:56Z | [
"python",
"osx-snow-leopard",
"python-imaging-library"
] |
Installing Python Imaging Library (PIL) on Snow Leopard with updated Python 2.6.2 | 1,438,270 | <p>I have a fresh install (started with a wiped drive) of Snow Leopard with the developer tools installed during the Snow Leopard installation.</p>
<p>I then installed Python 2.6.2, replacing the Snow Leopard default python 2.6.1. I've tried to install PIL by:</p>
<ol>
<li><code>easy_install</code></li>
<li><code>pip... | 26 | 2009-09-17T11:29:17Z | 8,880,459 | <p><strong>Solved in 2 steps:</strong></p>
<p><strong>Step 1:</strong> Uninstalled and Installed Xcode, suggested here:
<a href="http://binarylionstudios.com/blog/2011/01/30/error-stdarg.h-no-such-file-or-directory/" rel="nofollow">http://binarylionstudios.com/blog/2011/01/30/error-stdarg.h-no-such-file-or-directory/<... | 0 | 2012-01-16T13:08:28Z | [
"python",
"osx-snow-leopard",
"python-imaging-library"
] |
Installing Python Imaging Library (PIL) on Snow Leopard with updated Python 2.6.2 | 1,438,270 | <p>I have a fresh install (started with a wiped drive) of Snow Leopard with the developer tools installed during the Snow Leopard installation.</p>
<p>I then installed Python 2.6.2, replacing the Snow Leopard default python 2.6.1. I've tried to install PIL by:</p>
<ol>
<li><code>easy_install</code></li>
<li><code>pip... | 26 | 2009-09-17T11:29:17Z | 10,029,954 | <p>On OS X Lion with current XCode and no gcc-4.0 I'm able to get around the missing stdard.h error by setting the follow environment variables:</p>
<blockquote>
<p>export CC="/usr/bin/llvm-gcc-4.2"</p>
</blockquote>
<p>I can't say I understand why this works.</p>
<p>By the way this works for the Pillow fork of PI... | 0 | 2012-04-05T13:54:00Z | [
"python",
"osx-snow-leopard",
"python-imaging-library"
] |
pygresql - insert and return serial | 1,438,430 | <p>I'm using <a href="http://www.pygresql.org/pg.html" rel="nofollow">PyGreSQL</a> to access my DB. In the use-case I'm currently working on; I am trying to insert a record into a table and return the last rowid... aka the value that the DB created for my ID field:</p>
<pre><code>create table job_runners (
id ... | 1 | 2009-09-17T12:05:16Z | 1,438,455 | <pre><code>INSERT INTO job_runners
(hostname,is_available) VALUES ('localhost',true)
RETURNING id
</code></pre>
<p>That said, I have no idea about pygresql, but by what you've already written, I guess it's <code>db.query()</code> that you want to use here.</p>
| 1 | 2009-09-17T12:09:20Z | [
"python",
"postgresql",
"pygresql"
] |
pygresql - insert and return serial | 1,438,430 | <p>I'm using <a href="http://www.pygresql.org/pg.html" rel="nofollow">PyGreSQL</a> to access my DB. In the use-case I'm currently working on; I am trying to insert a record into a table and return the last rowid... aka the value that the DB created for my ID field:</p>
<pre><code>create table job_runners (
id ... | 1 | 2009-09-17T12:05:16Z | 1,440,041 | <p>The documentation in PyGreSQL says that if you call dbconn.query() with and insert/update statement that it will return the OID. It goes on to say something about lists of OIDs when there are multiple rows involved.</p>
<p>First of all; I found that the OID features did not work. I suppose knowing the version numbe... | 0 | 2009-09-17T16:52:05Z | [
"python",
"postgresql",
"pygresql"
] |
pygresql - insert and return serial | 1,438,430 | <p>I'm using <a href="http://www.pygresql.org/pg.html" rel="nofollow">PyGreSQL</a> to access my DB. In the use-case I'm currently working on; I am trying to insert a record into a table and return the last rowid... aka the value that the DB created for my ID field:</p>
<pre><code>create table job_runners (
id ... | 1 | 2009-09-17T12:05:16Z | 2,345,736 | <p>Assuming you have a cursor object <code>cur</code>:</p>
<pre><code>cur.execute("INSERT INTO job_runners (hostname) VALUES (%(hostname)s) RETURNING id",
{'hostname': 'localhost'})
id = cur.fetchone()[0]
</code></pre>
<p>This ensures PyGreSQL correctly escapes the input string, preventing SQL injection.<... | 0 | 2010-02-27T00:40:03Z | [
"python",
"postgresql",
"pygresql"
] |
Google App Engine urlfetch to POST files | 1,438,542 | <p>I am trying to send a file to torrage.com from an app in GAE.
the file is stored in memory after being received from a user upload.</p>
<p>I would like to be able to post this file using the API available here:
<a href="http://torrage.com/automation.php">http://torrage.com/automation.php</a> but i am having some pr... | 5 | 2009-09-17T12:25:31Z | 1,438,614 | <p>Why not just use Python's <a href="http://docs.python.org/library/urllib2.html" rel="nofollow">urllib2</a> module to create a POST request, like they show in an example for PHP. It would be something like this:</p>
<pre><code>import urrlib, urllib2
data = (
('name', 'torrent'),
('type', 'applicatio... | 0 | 2009-09-17T12:39:29Z | [
"python",
"http",
"google-app-engine"
] |
Google App Engine urlfetch to POST files | 1,438,542 | <p>I am trying to send a file to torrage.com from an app in GAE.
the file is stored in memory after being received from a user upload.</p>
<p>I would like to be able to post this file using the API available here:
<a href="http://torrage.com/automation.php">http://torrage.com/automation.php</a> but i am having some pr... | 5 | 2009-09-17T12:25:31Z | 1,439,945 | <p>I find torrage's API docs on the POST interface (as opposed to the SOAP one) pretty confusing and conflicting with the sample C code they also supply. It seems to me that in their online example of PHP post they are not sending the file's contents (just like @kender's answer above is not sending it) while they ARE s... | 2 | 2009-09-17T16:36:11Z | [
"python",
"http",
"google-app-engine"
] |
Google App Engine urlfetch to POST files | 1,438,542 | <p>I am trying to send a file to torrage.com from an app in GAE.
the file is stored in memory after being received from a user upload.</p>
<p>I would like to be able to post this file using the API available here:
<a href="http://torrage.com/automation.php">http://torrage.com/automation.php</a> but i am having some pr... | 5 | 2009-09-17T12:25:31Z | 1,440,042 | <p>Judging from the C code, it's using the "multipart/form-data" format, which is very complex and it's very easy to get something wrong. I wouldn't hand-code the post body like that. </p>
<p>I used the function from this blog and it worked for me from stand-alone program. You might want give it a try in app engine,</... | 0 | 2009-09-17T16:52:06Z | [
"python",
"http",
"google-app-engine"
] |
How can I measure the overall memory requirements of a Python program | 1,438,773 | <p>I have a financial pricing application written in Python 2.4.4 which runs as an Excel plugin. Excel has a 1GB memory limit for all addins, so if any addin process tries to allocate more than 1Gb in total it will cause Excel to crash. </p>
<p>I've recently made a change to the program which may have changed the over... | 2 | 2009-09-17T13:07:13Z | 1,438,830 | <p>Simplest solution might just be to run your app from the command line and use Task Manager to see how much memory it's using.</p>
<p>Edit:
For something more complicated have a look at this question / answer <a href="http://stackoverflow.com/questions/282194/how-to-get-memory-usage-under-windows-in-c">http://stacko... | 1 | 2009-09-17T13:15:51Z | [
"python"
] |
How can I measure the overall memory requirements of a Python program | 1,438,773 | <p>I have a financial pricing application written in Python 2.4.4 which runs as an Excel plugin. Excel has a 1GB memory limit for all addins, so if any addin process tries to allocate more than 1Gb in total it will cause Excel to crash. </p>
<p>I've recently made a change to the program which may have changed the over... | 2 | 2009-09-17T13:07:13Z | 1,439,782 | <p>I don't believe XP keeps track of the peak memory requirements of a process (the way Linux does in /proc/pid/status for example). You can use third-party utilities such as <a href="http://www.loriotpro.com/ServiceAndSupport/How%5Fto/How%5Fto%5Fcontrol%5FMemory%5Fusage.php" rel="nofollow">this one</a> and set it to "... | 2 | 2009-09-17T16:03:58Z | [
"python"
] |
Finding closest match in collection of strings representing numbers | 1,438,924 | <p>I have a sorted list of datetimes in text format. The format of each entry is '2009-09-10T12:00:00'.</p>
<p>I want to find the entry closest to a target. There are many more entries than the number of searches I would have to do.</p>
<p>I could change each entry to a number, then search numerically (for example ... | 2 | 2009-09-17T13:33:42Z | 1,439,018 | <p>You want the <a href="http://docs.python.org/library/bisect.html" rel="nofollow">bisect module</a> from the standard library. It will do a binary search and tell you the correct insertion point for a new value into an already sorted list. Here's an example that will print the place in the list where <code>target</... | 4 | 2009-09-17T13:52:23Z | [
"python",
"search"
] |
Finding closest match in collection of strings representing numbers | 1,438,924 | <p>I have a sorted list of datetimes in text format. The format of each entry is '2009-09-10T12:00:00'.</p>
<p>I want to find the entry closest to a target. There are many more entries than the number of searches I would have to do.</p>
<p>I could change each entry to a number, then search numerically (for example ... | 2 | 2009-09-17T13:33:42Z | 1,439,436 | <pre><code>import bisect
def mid(res, target):
keys = [r['dt'] for r in res]
return res[bisect.bisect_left(keys, target)]
</code></pre>
| 2 | 2009-09-17T15:01:40Z | [
"python",
"search"
] |
Finding closest match in collection of strings representing numbers | 1,438,924 | <p>I have a sorted list of datetimes in text format. The format of each entry is '2009-09-10T12:00:00'.</p>
<p>I want to find the entry closest to a target. There are many more entries than the number of searches I would have to do.</p>
<p>I could change each entry to a number, then search numerically (for example ... | 2 | 2009-09-17T13:33:42Z | 1,439,519 | <p>First, change to this.</p>
<pre><code>import datetime
def parse_dt(dt):
return datetime.strptime( dt, "%Y-%m-%dT%H:%M:%S" )
</code></pre>
<p>This removes much of the "effort".</p>
<p>Consider this as the search.</p>
<pre><code>def mid( res, target ):
"""res is a list of entries, sorted by dt (dateTtime) ... | 1 | 2009-09-17T15:16:39Z | [
"python",
"search"
] |
Finding closest match in collection of strings representing numbers | 1,438,924 | <p>I have a sorted list of datetimes in text format. The format of each entry is '2009-09-10T12:00:00'.</p>
<p>I want to find the entry closest to a target. There are many more entries than the number of searches I would have to do.</p>
<p>I could change each entry to a number, then search numerically (for example ... | 2 | 2009-09-17T13:33:42Z | 1,439,712 | <p>"Copy and paste coding" (getting <code>bisect</code>'s sources into your code) is not recommended as it carries all sorts of costs down the road (lot of extra source code for you to test and maintain, difficulties dealing with upgrades in the upstream code you've copied, etc, etc); the best way to reuse standard lib... | 4 | 2009-09-17T15:51:43Z | [
"python",
"search"
] |
How to catch exit() in embedded C++ module from python code? | 1,439,533 | <p>I am embedding a c++ library (binding done with SIP) in my python application. Under certain circonstances (error cases), this library uses exit(), which causes my entire application to exit.
Is there a way to catch this event, or do I need to modify the library to handle error cases differently ? </p>
<p>Thank yo... | 4 | 2009-09-17T15:19:36Z | 1,439,585 | <p>You must modify the source of the library. There is no "exception handling" in C and <code>exit()</code> does not return to the calling code under any circumstances.</p>
| 6 | 2009-09-17T15:27:46Z | [
"python",
"exception",
"binding",
"exit"
] |
How to catch exit() in embedded C++ module from python code? | 1,439,533 | <p>I am embedding a c++ library (binding done with SIP) in my python application. Under certain circonstances (error cases), this library uses exit(), which causes my entire application to exit.
Is there a way to catch this event, or do I need to modify the library to handle error cases differently ? </p>
<p>Thank yo... | 4 | 2009-09-17T15:19:36Z | 8,099,938 | <p>You can override the library linking with LD_LIBRARY_PATH and make your own exit function. Works fine.</p>
| 0 | 2011-11-11T21:03:01Z | [
"python",
"exception",
"binding",
"exit"
] |
have you seen? _mysql_exceptions.OperationalError "Lost connection to MySQL server during query" being ignored | 1,439,616 | <p>I am just starting out with the MySQLdb module for python, and upon running some SELECT and UPDATE queries, the following gets output:</p>
<blockquote>
<p>Exception
_mysql_exceptions.OperationalError: (2013, 'Lost connection to MySQL
server during query') in bound method Cursor.<strong>del</strong> of
MySQL... | 0 | 2009-09-17T15:33:15Z | 1,439,734 | <p>Ha! Just realized I was trying to use the cursor <em>after</em> having closed the connection! In any case, it was nice writing! : )</p>
<p>l</p>
| 0 | 2009-09-17T15:54:52Z | [
"python",
"mysql"
] |
What is the builtin name of the 'type' of functions, in Python? | 1,439,815 | <p>What Python builtin returns <code><type 'function'></code>?</p>
<pre><code>>>> type(lambda: None)
<type 'function'>
</code></pre>
<p>Is there way of avoiding creating this lambda function, in order to get the type of functions in general?</p>
<p>See <a href="http://www.finalcog.com/python-mem... | 0 | 2009-09-17T16:11:24Z | 1,439,824 | <p>built-ins are not <code>function</code>s they are: <code>builtin_function_or_method</code>. Isn't it the whole point of naming?</p>
<p>you can get by doing something like:</p>
<pre><code>>>> type(len)
<class 'builtin_function_or_method'>
</code></pre>
| 0 | 2009-09-17T16:12:54Z | [
"python",
"types"
] |
What is the builtin name of the 'type' of functions, in Python? | 1,439,815 | <p>What Python builtin returns <code><type 'function'></code>?</p>
<pre><code>>>> type(lambda: None)
<type 'function'>
</code></pre>
<p>Is there way of avoiding creating this lambda function, in order to get the type of functions in general?</p>
<p>See <a href="http://www.finalcog.com/python-mem... | 0 | 2009-09-17T16:11:24Z | 1,439,852 | <p>You should be able to use <code>types.FunctionType</code> to do what you want:</p>
<pre>
Python 2.6.1 (r261:67515, Jul 7 2009, 23:51:51)
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import types
>>> help(types.Function... | 5 | 2009-09-17T16:16:51Z | [
"python",
"types"
] |
What is the builtin name of the 'type' of functions, in Python? | 1,439,815 | <p>What Python builtin returns <code><type 'function'></code>?</p>
<pre><code>>>> type(lambda: None)
<type 'function'>
</code></pre>
<p>Is there way of avoiding creating this lambda function, in order to get the type of functions in general?</p>
<p>See <a href="http://www.finalcog.com/python-mem... | 0 | 2009-09-17T16:11:24Z | 1,439,853 | <p>"What Python builtin returns <code><type 'function'></code>?"</p>
<p>Functions.</p>
<p>"Is there way of avoiding creating this lambda function, in order to get the type of functions in general?"</p>
<p>Yes, types.FunctionType.
or just type(anyfunction)</p>
<p>If you are asking how to get rid of lambdas (bu... | 1 | 2009-09-17T16:16:55Z | [
"python",
"types"
] |
What is the builtin name of the 'type' of functions, in Python? | 1,439,815 | <p>What Python builtin returns <code><type 'function'></code>?</p>
<pre><code>>>> type(lambda: None)
<type 'function'>
</code></pre>
<p>Is there way of avoiding creating this lambda function, in order to get the type of functions in general?</p>
<p>See <a href="http://www.finalcog.com/python-mem... | 0 | 2009-09-17T16:11:24Z | 1,439,902 | <p>You should get away from the idea of 'types' in Python. Most of the time you don't want to check the 'type' of something. Explicitly checking types is prone to breakage, for example:</p>
<pre><code>>>> s1 = 'hello'
>>> s2 = u'hello'
>>> type(s1) == type(s2)
False
</code></pre>
<p>What yo... | 3 | 2009-09-17T16:27:26Z | [
"python",
"types"
] |
How do i return a quoted string from a tuple? | 1,439,862 | <p>I have a tuple of strings that i would want to extract the contents as a quoted string, i.e.</p>
<pre><code>tup=('string1', 'string2', 'string3')
when i do this
main_str = ",".join(tup)
#i get
main_str = 'string1, string2, string3'
#I want the main_str to have something like this
main_str = '"string1", "strin... | 1 | 2009-09-17T16:18:59Z | 1,439,879 | <pre><code>", ".join('"{0}"'.format(i) for i in tup)
</code></pre>
<p>or</p>
<pre><code>", ".join('"%s"' % i for i in tup)
</code></pre>
| 9 | 2009-09-17T16:21:51Z | [
"python",
"tuples"
] |
How do i return a quoted string from a tuple? | 1,439,862 | <p>I have a tuple of strings that i would want to extract the contents as a quoted string, i.e.</p>
<pre><code>tup=('string1', 'string2', 'string3')
when i do this
main_str = ",".join(tup)
#i get
main_str = 'string1, string2, string3'
#I want the main_str to have something like this
main_str = '"string1", "strin... | 1 | 2009-09-17T16:18:59Z | 1,439,880 | <p>Well, one answer would be:</p>
<pre><code>', '.join([repr(x) for x in tup])
</code></pre>
<p>or</p>
<pre><code>repr(tup)[1:-1]
</code></pre>
<p>But that's not really nice. ;)</p>
<p>Updated:
Although, noted, you will not be able to control if resulting string starts with '" or '". If that matters, you need to b... | 2 | 2009-09-17T16:21:59Z | [
"python",
"tuples"
] |
How do i return a quoted string from a tuple? | 1,439,862 | <p>I have a tuple of strings that i would want to extract the contents as a quoted string, i.e.</p>
<pre><code>tup=('string1', 'string2', 'string3')
when i do this
main_str = ",".join(tup)
#i get
main_str = 'string1, string2, string3'
#I want the main_str to have something like this
main_str = '"string1", "strin... | 1 | 2009-09-17T16:18:59Z | 1,439,889 | <p>Here's one way to do it:</p>
<pre><code>>>> t = ('s1', 's2', 's3')
>>> ", ".join( s.join(['"','"']) for s in t)
'"s1", "s2", "s3"'
</code></pre>
| 0 | 2009-09-17T16:23:56Z | [
"python",
"tuples"
] |
possible to intercept and rewrite email on outlook client side using ironpython? | 1,440,233 | <p>I want to intercept and transform some automated emails into a more readable format. I believe this is possible using VBA, but I would prefer to manipulate the text with Python. Can I create an ironpython client-side script to pre-process certain emails?</p>
<p>EDIT:
I believe this can be done with outlook rules.... | 1 | 2009-09-17T17:31:22Z | 1,441,330 | <p>I can only offer you a pointer. Years ago, I used a Bayesian spam filter with Outlook. It was written in Python, and provided an Outlook plug-in that would filter incoming mail. The name of the software was <a href="http://spambayes.sourceforge.net/" rel="nofollow"><em>SpamBayes</em></a>, and the project is still on... | 2 | 2009-09-17T21:01:27Z | [
"python",
"vba",
"outlook",
"ironpython"
] |
possible to intercept and rewrite email on outlook client side using ironpython? | 1,440,233 | <p>I want to intercept and transform some automated emails into a more readable format. I believe this is possible using VBA, but I would prefer to manipulate the text with Python. Can I create an ironpython client-side script to pre-process certain emails?</p>
<p>EDIT:
I believe this can be done with outlook rules.... | 1 | 2009-09-17T17:31:22Z | 1,441,579 | <p>You can reference the outlook object model here:
<a href="http://msdn.microsoft.com/en-us/library/ms268893.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/ms268893.aspx</a></p>
<p>Connect to outlook through COM, you'll need <a href="http://sourceforge.net/projects/pywin32/" rel="nofollow">pywin32</a>.<... | 2 | 2009-09-17T22:10:01Z | [
"python",
"vba",
"outlook",
"ironpython"
] |
possible to intercept and rewrite email on outlook client side using ironpython? | 1,440,233 | <p>I want to intercept and transform some automated emails into a more readable format. I believe this is possible using VBA, but I would prefer to manipulate the text with Python. Can I create an ironpython client-side script to pre-process certain emails?</p>
<p>EDIT:
I believe this can be done with outlook rules.... | 1 | 2009-09-17T17:31:22Z | 1,719,000 | <p>This is a work in progress, but I've figured out part of the answer with the help of the other posts. Here are the instructions for re-writing specified emails by running a script. I'm using Outlook 2007.</p>
<ol>
<li><p>Download and install <a href="http://sourceforge.net/projects/pywin32/" rel="nofollow">pywin3... | 1 | 2009-11-12T00:15:24Z | [
"python",
"vba",
"outlook",
"ironpython"
] |
possible to intercept and rewrite email on outlook client side using ironpython? | 1,440,233 | <p>I want to intercept and transform some automated emails into a more readable format. I believe this is possible using VBA, but I would prefer to manipulate the text with Python. Can I create an ironpython client-side script to pre-process certain emails?</p>
<p>EDIT:
I believe this can be done with outlook rules.... | 1 | 2009-09-17T17:31:22Z | 15,686,621 | <p>There is an answer here: <a href="http://stackoverflow.com/questions/13265861/how-to-trigger-a-python-script-in-outlook-using-rules">how to trigger a python script in outlook using rules?</a> that may help you. You can make a simple VBA script to trigger the python script.</p>
| 0 | 2013-03-28T16:02:23Z | [
"python",
"vba",
"outlook",
"ironpython"
] |
How to use Python plugin reCaptcha client for validation? | 1,440,239 | <p>I want to make a captcha validation.</p>
<p>I get the key from the <a href="http://recaptcha.net/">recaptcha website</a> and already succeed to put the public key to load the webpage with the challenge.</p>
<pre><code><script type="text/javascript"
src="http://api.recaptcha.net/challenge?k=<your_public_ke... | 15 | 2009-09-17T17:32:07Z | 1,440,429 | <p>It is quite straightforward.
This is an example from a trivial trac plugin I'm using:</p>
<pre><code>from recaptcha.client import captcha
if req.method == 'POST':
response = captcha.submit(
req.args['recaptcha_challenge_field'],
req.args['recaptcha_response_field'],
self.private_key,
... | 24 | 2009-09-17T18:06:28Z | [
"python",
"validation",
"plugins",
"captcha",
"recaptcha"
] |
How to use Python plugin reCaptcha client for validation? | 1,440,239 | <p>I want to make a captcha validation.</p>
<p>I get the key from the <a href="http://recaptcha.net/">recaptcha website</a> and already succeed to put the public key to load the webpage with the challenge.</p>
<pre><code><script type="text/javascript"
src="http://api.recaptcha.net/challenge?k=<your_public_ke... | 15 | 2009-09-17T17:32:07Z | 12,045,423 | <p>Sorry to say, but this module, while it works just fine, is almost entirely undocumented, and it's layout is a tad confusing for those of us who prefer using ">> help(modulename)" after installation. I'll give an example using cherrypy, and make some cgi-related comments afterwards.</p>
<p>captcha.py contains two f... | 4 | 2012-08-20T21:24:30Z | [
"python",
"validation",
"plugins",
"captcha",
"recaptcha"
] |
How do I disable psycopg2 connection pooling? | 1,440,245 | <p>I have configured pgpool-II for postgres connection pooling and I want to disable psycopg2 connection pooling. How do I do this?</p>
<p>Thanks!</p>
| 0 | 2009-09-17T17:34:01Z | 1,443,845 | <p>I don't think you can. Dan McKinley bemoaned this fact (among some other interesting issues) in his blog post <a href="http://mcfunley.com/445/python-postgresql-driver-authors-hate-you" rel="nofollow">Python PostgreSQL Driver Authors Hate You</a>.</p>
| -1 | 2009-09-18T11:00:36Z | [
"python",
"psycopg2"
] |
How do I disable psycopg2 connection pooling? | 1,440,245 | <p>I have configured pgpool-II for postgres connection pooling and I want to disable psycopg2 connection pooling. How do I do this?</p>
<p>Thanks!</p>
| 0 | 2009-09-17T17:34:01Z | 1,492,172 | <p><code>psycopg2</code> doesn't pool connections unless you explicitely use the <code>psycopg.pool</code> module.</p>
| 6 | 2009-09-29T12:11:38Z | [
"python",
"psycopg2"
] |
How to create simplest p2p remote desktop OR any Robot(Java) equivalent in python | 1,440,323 | <p>I want to create a simplest remote desktop application using p2p communication.
I did created one small p2p program in python.</p>
<p>My Idea is-</p>
<ul>
<li><p>Transmit screenshots of remote computer periodically</p></li>
<li><p>Transmit keyboard and mouse events wrapped in xml to remote desktop.</p></li>
</ul>
... | 0 | 2009-09-17T17:47:55Z | 1,440,831 | <p>You can control the keyboard and the mouse with python on Windows by calling the win32 apis: <a href="http://msdn.microsoft.com/en-us/library/ms646304%28VS.85%29.aspx" rel="nofollow"><code>keybd_event</code></a> and <a href="http://msdn.microsoft.com/en-us/library/ms646260%28VS.85%29.aspx" rel="nofollow"><code>mouse... | 1 | 2009-09-17T19:18:35Z | [
"python",
"operating-system",
"remote-desktop",
"p2p"
] |
Class usage in Python | 1,440,434 | <p>I write a lot of scripts in Python to analyze and plot experimental data as well as write simple simulations to test how theories fit the data. The scripts tend to be very procedural; calculate some property, calculate some other property, plot properties, analyze plot...</p>
<p>Rather than just writing a procedur... | 7 | 2009-09-17T18:07:33Z | 1,440,467 | <p>By using Object Oriented Programming, you will have objects, that have associated functions, that are (should) be the only way to modify its properties (internal variables).</p>
<p>It was common to have functions called <code>trim_string(string)</code>, while with a <code>string</code> class you could do <code>stri... | 15 | 2009-09-17T18:13:28Z | [
"python",
"oop",
"class-design",
"procedural-programming"
] |
Class usage in Python | 1,440,434 | <p>I write a lot of scripts in Python to analyze and plot experimental data as well as write simple simulations to test how theories fit the data. The scripts tend to be very procedural; calculate some property, calculate some other property, plot properties, analyze plot...</p>
<p>Rather than just writing a procedur... | 7 | 2009-09-17T18:07:33Z | 1,440,655 | <p>You don't <em>need</em> to use classes in Python - it doesn't force you to do OOP. If you're more comfortable with the functional style, that's fine. I use classes when I want to model some abstraction which has variations, and I want to model those variations using classes. As the word "class" implies, they're usef... | 4 | 2009-09-17T18:46:28Z | [
"python",
"oop",
"class-design",
"procedural-programming"
] |
Class usage in Python | 1,440,434 | <p>I write a lot of scripts in Python to analyze and plot experimental data as well as write simple simulations to test how theories fit the data. The scripts tend to be very procedural; calculate some property, calculate some other property, plot properties, analyze plot...</p>
<p>Rather than just writing a procedur... | 7 | 2009-09-17T18:07:33Z | 1,440,684 | <p>"but the functions are not contained in a Class."</p>
<p>They could be.</p>
<pre><code>class Linear( object ):
a= 2.
b= 3.
def calculate( self, somePoint ):
somePoint['line']= b + somePoint['x']*a
class Exponential( object ):
a = 1.05
b = 3.2
def calculate( self, somePoint ):
... | 1 | 2009-09-17T18:54:19Z | [
"python",
"oop",
"class-design",
"procedural-programming"
] |
Class usage in Python | 1,440,434 | <p>I write a lot of scripts in Python to analyze and plot experimental data as well as write simple simulations to test how theories fit the data. The scripts tend to be very procedural; calculate some property, calculate some other property, plot properties, analyze plot...</p>
<p>Rather than just writing a procedur... | 7 | 2009-09-17T18:07:33Z | 1,440,734 | <p>OOP lends itself well to complex programs. It's great for capturing the state and behavior of real world concepts and orchestrating the interplay between them. Good OO code is easy to read/understand, protects your data's integrity, and maximizes code reuse. I'd say code reuse is one big advantage to keeping your fr... | 1 | 2009-09-17T19:01:28Z | [
"python",
"oop",
"class-design",
"procedural-programming"
] |
Class usage in Python | 1,440,434 | <p>I write a lot of scripts in Python to analyze and plot experimental data as well as write simple simulations to test how theories fit the data. The scripts tend to be very procedural; calculate some property, calculate some other property, plot properties, analyze plot...</p>
<p>Rather than just writing a procedur... | 7 | 2009-09-17T18:07:33Z | 1,447,527 | <ul>
<li><p>Object-oriented programming isn't the solution to every coding problem.</p></li>
<li><p>In Python, functions are objects. You can mix as many objects and functions as you want.</p></li>
<li><p>Modules with functions are already objects with properties.</p></li>
<li><p>If you find yourself passing a lot of t... | 1 | 2009-09-19T02:16:08Z | [
"python",
"oop",
"class-design",
"procedural-programming"
] |
Maximum size of object that can be saved in memcached with memcache.py | 1,440,722 | <p>I need to return a rather big file (11MB) to the user. For certain reasons, I can't just provide a direct url to the file (<a href="http://www.sample.com/mybigfile.exe">http://www.sample.com/mybigfile.exe</a>); instead it must be accessed through code.</p>
<p>Instead of having to read it from disk over and over, I ... | 20 | 2009-09-17T19:00:13Z | 1,440,765 | <p>The maximum data size is 1mb per item</p>
<p><a href="http://code.google.com/p/memcached/wiki/FAQ#What_is_the_maximum_data_size_you_can_store?_%281_megabyte%29" rel="nofollow">http://code.google.com/p/memcached/wiki/FAQ#What_is_the_maximum_data_size_you_can_store?_%281_megabyte%29</a></p>
<p>Update: This is a 2009... | 0 | 2009-09-17T19:06:35Z | [
"python",
"memcached"
] |
Maximum size of object that can be saved in memcached with memcache.py | 1,440,722 | <p>I need to return a rather big file (11MB) to the user. For certain reasons, I can't just provide a direct url to the file (<a href="http://www.sample.com/mybigfile.exe">http://www.sample.com/mybigfile.exe</a>); instead it must be accessed through code.</p>
<p>Instead of having to read it from disk over and over, I ... | 20 | 2009-09-17T19:00:13Z | 1,440,773 | <p>There are two entries about that in the <a href="http://docs.oracle.com/cd/E17952_01/refman-5.6-en/ha-memcached-faq.html">memcached FAQ</a> :</p>
<ul>
<li><a href="http://docs.oracle.com/cd/E17952_01/refman-5.6-en/ha-memcached-faq.html#qandaitem-17-6-5-1-2">What is the maximum size of an object you can store in mem... | 30 | 2009-09-17T19:07:28Z | [
"python",
"memcached"
] |
Maximum size of object that can be saved in memcached with memcache.py | 1,440,722 | <p>I need to return a rather big file (11MB) to the user. For certain reasons, I can't just provide a direct url to the file (<a href="http://www.sample.com/mybigfile.exe">http://www.sample.com/mybigfile.exe</a>); instead it must be accessed through code.</p>
<p>Instead of having to read it from disk over and over, I ... | 20 | 2009-09-17T19:00:13Z | 11,730,559 | <p>As of memcache 1.4.2, this is a user-configurable parameter:</p>
<p><a href="http://code.google.com/p/memcached/wiki/ReleaseNotes142">http://code.google.com/p/memcached/wiki/ReleaseNotes142</a></p>
<blockquote>
<p>Configurable maximum item size</p>
<p>Many people have asked for memcached to be able to store... | 27 | 2012-07-30T22:22:29Z | [
"python",
"memcached"
] |
Maximum size of object that can be saved in memcached with memcache.py | 1,440,722 | <p>I need to return a rather big file (11MB) to the user. For certain reasons, I can't just provide a direct url to the file (<a href="http://www.sample.com/mybigfile.exe">http://www.sample.com/mybigfile.exe</a>); instead it must be accessed through code.</p>
<p>Instead of having to read it from disk over and over, I ... | 20 | 2009-09-17T19:00:13Z | 18,182,563 | <p>To summarise the necessary steps:</p>
<p>1) Update Memcache to version 1.4.2 or later.</p>
<p>2) Add the flag -I 15M (or however many megabytes) to your memcache run command.</p>
<p>That's either command line, or in Ubuntu, add the line</p>
<pre><code>-I 15M
</code></pre>
<p>to anywhere in /etc/memcached.conf a... | 18 | 2013-08-12T08:32:25Z | [
"python",
"memcached"
] |
Maximum size of object that can be saved in memcached with memcache.py | 1,440,722 | <p>I need to return a rather big file (11MB) to the user. For certain reasons, I can't just provide a direct url to the file (<a href="http://www.sample.com/mybigfile.exe">http://www.sample.com/mybigfile.exe</a>); instead it must be accessed through code.</p>
<p>Instead of having to read it from disk over and over, I ... | 20 | 2009-09-17T19:00:13Z | 30,076,502 | <p>Following article explained why it limit max size of a single file to 1M.</p>
<p><a href="http://www.mikeperham.com/2009/06/22/slabs-pages-chunks-and-memcached/" rel="nofollow">http://www.mikeperham.com/2009/06/22/slabs-pages-chunks-and-memcached/</a></p>
<p>Basicly, there are small pieces of memory pages in memca... | 1 | 2015-05-06T12:16:58Z | [
"python",
"memcached"
] |
Maximum size of object that can be saved in memcached with memcache.py | 1,440,722 | <p>I need to return a rather big file (11MB) to the user. For certain reasons, I can't just provide a direct url to the file (<a href="http://www.sample.com/mybigfile.exe">http://www.sample.com/mybigfile.exe</a>); instead it must be accessed through code.</p>
<p>Instead of having to read it from disk over and over, I ... | 20 | 2009-09-17T19:00:13Z | 38,004,732 | <p>If you are using python memcached client, please also make sure to increase the limit in client memcache.py file along with the memcached server. </p>
<p>~/anaconda/lib/python2.7/site-packages/memcache.py</p>
<pre><code>SERVER_MAX_KEY_LENGTH = 250
SERVER_MAX_VALUE_LENGTH = 1024 * 1024 * 15
</code></pre>
<p>you c... | 0 | 2016-06-24T02:26:44Z | [
"python",
"memcached"
] |
Finding the command for a specific PID in Linux from Python | 1,440,941 | <p>I'd like to know if it's possible to find out the "command" that a PID is set to. When I say command, I mean what you see in the last column when you run the command "top" in a linux shell. I'd like to get this information from Python somehow when I have a specific PID.</p>
<p>Any help would be great. Thanks.</p>
| 5 | 2009-09-17T19:44:09Z | 1,440,953 | <p>Read up on the <a href="http://unixhelp.ed.ac.uk/CGI/man-cgi?ps"><code>ps</code></a> command and parse its output.</p>
<pre><code>ps -p [PID] -o cmd
</code></pre>
<p>should do it</p>
| 6 | 2009-09-17T19:46:34Z | [
"python",
"linux",
"process"
] |
Finding the command for a specific PID in Linux from Python | 1,440,941 | <p>I'd like to know if it's possible to find out the "command" that a PID is set to. When I say command, I mean what you see in the last column when you run the command "top" in a linux shell. I'd like to get this information from Python somehow when I have a specific PID.</p>
<p>Any help would be great. Thanks.</p>
| 5 | 2009-09-17T19:44:09Z | 1,440,965 | <p>The proc filesystem exports this (and other) information.
Look at the /proc/PID/cmd symlink.</p>
| 0 | 2009-09-17T19:49:09Z | [
"python",
"linux",
"process"
] |
Finding the command for a specific PID in Linux from Python | 1,440,941 | <p>I'd like to know if it's possible to find out the "command" that a PID is set to. When I say command, I mean what you see in the last column when you run the command "top" in a linux shell. I'd like to get this information from Python somehow when I have a specific PID.</p>
<p>Any help would be great. Thanks.</p>
| 5 | 2009-09-17T19:44:09Z | 1,440,969 | <h3>Look in <code>/proc/$PID/cmdline</code></h3>
| 7 | 2009-09-17T19:49:53Z | [
"python",
"linux",
"process"
] |
Finding the command for a specific PID in Linux from Python | 1,440,941 | <p>I'd like to know if it's possible to find out the "command" that a PID is set to. When I say command, I mean what you see in the last column when you run the command "top" in a linux shell. I'd like to get this information from Python somehow when I have a specific PID.</p>
<p>Any help would be great. Thanks.</p>
| 5 | 2009-09-17T19:44:09Z | 1,441,057 | <p>PLEASE, do not use <code>/proc</code> filesystem in production code. Instead, use well-defined POSIX interfaces, such as glibc calls and standard shell commands! Make the Linux world more standardized, it really needs to!</p>
<p>What you need is well achieved by invoking a shell command </p>
<pre><code>ps -p <... | 8 | 2009-09-17T20:06:02Z | [
"python",
"linux",
"process"
] |
Finding the command for a specific PID in Linux from Python | 1,440,941 | <p>I'd like to know if it's possible to find out the "command" that a PID is set to. When I say command, I mean what you see in the last column when you run the command "top" in a linux shell. I'd like to get this information from Python somehow when I have a specific PID.</p>
<p>Any help would be great. Thanks.</p>
| 5 | 2009-09-17T19:44:09Z | 1,443,544 | <p>Look in <code>/proc/$PID/cmdline</code>, and then os.readlink() on <code>/proc/$PID/exe</code>.</p>
<p><code>/proc/$PID/cmdline</code> is not necessarily going to be correct, as a program can change its argument vector or it may not contain a full path. Three examples of this from my current process list are:</p>
... | 5 | 2009-09-18T09:51:00Z | [
"python",
"linux",
"process"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.