I'm having trouble to understand how a classmethod object works in Python, especially in the context of metaclasses and in __new__. In my special case I would like to get the name of a classmethod member, when I iterate through the members that were given to __new__.
For normal methods the name is simply stored in a __name__ attribute, ...
Can we control where matplotlib places figures on the screen? I want to generate four figures (in four separate windows) that do not overlap.
Thanks.
...
I need to digitally sign some text in python using a private key stored in a .pem file. It seems like M2Crypto is the preferred way to do that these days, so that's what I'm using. I think I get most of it, but I'm confused about how to configure padding. To be specific, I need to verify the signature in an iPhone app, using a padding ...
I want to convert an int64 numpy array to a uint64 numpy array, adding 2**63 to the values in the process so that they are still within the valid range allowed by the arrays. So for example if I start from
a = np.array([-2**63,2**63-1], dtype=np.int64)
I want to end up with
np.array([0.,2**64], dtype=np.uint64)
Sounds simple at fir...
I am trying to build python2.6 with support for the sqlite3 module.
I have successfully built and installed the sqlite-amalgamation to a non standard path:
./configure --prefix=/my/non/standard/install/path/sqlite/3.6.20/
make
make install
I would like the python2.6 build to use this path & build the sqlite3 module. I checked './config...
Basically, I have a list like: [START, 'foo', 'bar', 'spam', eggs', END] and the START/END identifiers are necessary for later so I can compare later on. Right now, I have it set up like this:
START = object()
END = object()
This works fine, but it suffers from the problem of not working with pickling. I tried doing it the following w...
When creating decorators for use on class methods, I'm having trouble when the decorator mechanism is a class rather than a function/closure. When the class form is used, my decorator doesn't get treated as a bound method.
Generally I prefer to use the function form for decorators but in this case I have to use an existing class to imp...
I have a small Python web application using the Cherrypy framework. I am by no means an expert in web servers.
I got Cherrypy working with Apache using mod_python on our Ubuntu server. This time, however, I have to use Windows 2003 and IIS 6.0 to host my site.
The site runs perfectly as a stand alone server - I am just so lost when it...
Hi, My test uses Selenium to loop through a CSV list of URLs via an HTTP proxy (working script below). As I watch the script run I can see about 10% of the calls produce "Proxy error: 502" ("Bad_Gateway"); however, the errors are not captured by my catch-all "except Exception" clause -- ie: instead of writing 'error' in the appropriate r...
How can you convert the following code to PHP?
summat = [sum(arra[i:i+4]) for i in range(0,len(arra),4)]
My attempt
$summat = array()
foreach ( range(0, $arra.length, 4) as $i) {
$summat = array ( array_sum( array_slice( $array, $i, $i+5) ) ) // don't know how to append the sums the array
...
Hi,
My Django application uses memcached via cmemcache. An issue sprung up when I was trying to monitor its usage:
I tried to access stats memcached provides through both Django and cmemcache:
django:
from django.core.cache import cache
cache._cache.get_stats()
[[email protected]] mcm_server_stats():3027: unknown stat variable: ...
I'm using Komodo Edit for Python development, and I want to get the best out of the auto complete.
If I do this:
a = A()
a.
I can see a list of members of A.
But if I do this:
a = [A()]
b = a[0]
b.
It does not work. I want to be able to do this:
a = [A()]
b = a[0]
"""b
Type: A
"""
b.
So how can I tell the auto complete that ...
How can I plot an 2D array as an image with Matplotlib having the y scale relative to the power of two of the y value?
For instance the first row of my array will have a height in the image of 1, the second row will have a height of 4, etc. (units are irrelevant)
It's not simple to explain with words so look at this image please (that's...
I'm trying to convert a Python dictionary into a Python list, in order to perform some calculations.
#My dictionary
dict = {}
dict['Capital']="London"
dict['Food']="Fish&Chips"
dict['2012']="Olympics"
#lists
temp = []
dictList = []
#My attempt:
for key, value in dict.iteritems():
aKey = key
aValue = value
temp.append(aKey)...
Hi,
I have made some changes in a python module in my checked out copy of a repository, and need to test them. However, when I try to run a script that uses the module, it keeps importing the module from the trunk of the repository, which is of no use to me.
I tried setting PYTHONPATH, which did nothing at all. After some searching a...
My application prints a PDF to a temporary file. How can I open that file with the default application in Python?
I need a solution for
Windows
Linux (Ubuntu with Xfce if there's nothing more general.)
Related
Open document with default application in Python
...
I considered using tmpnam to set the output file name of a QPrinter. But the Python documentation recommends against using it.
os.tmpnam()
Return a unique path name that is reasonable for creating a temporary
file. ... Applications are responsible
for properly creating and managing
files created using paths returned by
t...
This is a very specific inforgraphic challange altough the fundemental question is how do you build archs between words using matplotlib, cario or an other python libary.
Given a the following data structure.
me, you, 7 |
me, apple, 9 |
apple, you, 1 |
bike, me, 5
Names would be displayed horizontally the names with the most relation...
How can I reverse a word in Vim? Preferably with a regex or normal-mode commands, but other methods are welcome too:
word => drow
Thanks for your help!
PS: I'm in windows XP
Python is built in supported in my vim, but not Perl.
...
Hi, so I've read the Bittorrent specification and done a number of searches, trying to find out how I can get the seeds/peers/downloaded data from a torrent tracker (using Python). I can calculate the info hash from a Torrent no problem, which matches up with the info hash given by various working torrent applications.
However, when I t...