Hi,
I'm using cProfile, pstats and Gprof2dot to profile a rather long python script.
The results tell me that the most time is spent calling a method in an object I've defined. However, what I would really like is to know exactly what line number within that function is eating up the time.
Any idea's how to get this additional inform...
Can some recommend an XML serializer that is element or attribute centric, and that doesn't use key-value pairs.
For example, GAE db.model has a to_xml() function but it writes out like this:
<property name="firstname" type="string">John</property>
<property name="lastname" type="string">Doe</property>
<property name="city" typ...
So just to establish, I feel like I understand the difference between copy vs. deepcopy in the copy module and I've used copy.copy and copy.deepcopy before successfully, but this is the first time I've actually gone about overloading the __copy__ and __deepcopy__ methods. I've already Googled around and looked through the built-in Pytho...
I am trying to install the pycairo (Python bindings for the cairo graphics library) under OSX.
I started with
easy_install pycairo
and got:
Requested 'cairo >= 1.8.8' but version of cairo is 1.0.4
error: Setup script exited with Error: cairo >= 1.8.8 not found
So I went to cairo's site and downloaded the latest package (1.8.8) o...
In this post, Nick suggested a decoartor:
http://stackoverflow.com/questions/1499832/python-webapp-google-app-engine-testing-for-user-pass-in-the-headers/1500047#1500047
I'm writing an API to expose potentially dozens of methods as web-services, so the decorator sounds like a great idea.
I tried to start coding one based on this sam...
Hi, I'm tying to get a certain Python script (although I guess it isn't really the language that's going to matter here) to find out the current geographic location of the machine running it. As you might have guessed, it's a little script that reports my laptop's location when it boots and stuff :)
Is there any free web service or API t...
I have a list in Python that I generate as part of the program. I have a strong assumption that these are all different, and I check this with an assertion.
This is the way I do it now:
If there are two elements:
try:
assert(x[0] != x[1])
except:
print debug_info
raise Exception("throw to caller")
If there are three:
t...
In PHP, I have to pass the arguments in the same order as the arguments are in the constructor.
Now, in Python, take
listbox = Listbox(root, yscrollcommand=scrollbar.set)
for example.
If I had passed yscrollcommand=scrollbar.set as the third argument and yscrollcommand was the second argument in the constructor, would I still be abl...
Is there a way to log the stdout output from a given Process when using the multiprocessing.Process class in python?
...
I am attempting to use BeautifulSoup to parse through a DOM tree and extract the names of authors. Below is a snippet of HTML to show the structure of the code I'm going to scrape.
<html>
<body>
<div class="list-authors">
<span class="descriptor">Authors:</span>
<a href="/find/astro-ph/1/au:+Lin_D/0/1/0/all/0/1">Dacheng Lin</a>,
<a h...
Hi
I am wondering what would be a pythonic solution for this question.
http://stackoverflow.com/questions/1483757/in-aa67bc54c9-is-there-any-way-to-print-aa-67-times-bc-54-times-and-so-on
...
I need to run a task every hour on the hour (00:00, 01:00, 02:00, ..., 23:00) every day of the week, but can't seem to find an example in App Engine's docs of how to do this.
There is an example of running at ask every hour, but this doesn't fit because the "start" of that hour depends on when you deploy the application. That is, if I d...
Is it possible to use the CherrPy server as a blocking/non-threading server (for easier debugging?)
...
I am a newbie to Python. Consider the function str.partition() which returns a 3-tuple. If I am interested in only elements 0 and 2 of this tuple, what is the best way to pick only certain elements out of such a tuple?
I can currently do either:
# Introduces "part1" variable, which is useless
(part0, part1, part2) = str.partition(' ')
...
While searching for my python completion nirvana in vim, I have come to really love <C-x> <C-i>: "keywords in the current and included files". This almost always gets me a long nasty name from another module completed, which is great.
(Omni-completion is obviously better when it works, but too often it reports it can't find any matches....
I'm using the following command in my pylons app in an attempt to stop the daemon on the server:
paster serve --daemon dev.ini stop
This is the error I get:
No PID file exists in paster.pid
Could not stop daemon; aborting
Wondering how I can stop this daemon so I can reload dev.ini.
Thanks!
...
I could not find a method to parse x509 pem files. I tried using ParseX509 of utils module which threw up.
...
I do not care about concurrency issues.
It is relatively easy to build unique form field:
from django import forms
class UniqueUserEmailField(forms.CharField):
def clean(self, value):
self.check_uniqueness(super(UniqueUserEmailField, self).clean(value))
def check_uniqueness(self, value):
same_user = users.User.a...
To learn from good examples, what are the best open source Google App Engine applications out there?
I don't care if it is Java or Python based.
Please one app per answer. Feel free to add a link to the live app (if there is) and to the project page.
...
I am looking for a way to check if 2 permutations (represented by lists) are of the same parity. Note that I am not interested if they are even or odd parity, just the equality.
I am new to Python and my naive solution is given below as a reply. I am looking forward to Python gurus showing me some cool tricks to achieve the same in less...