I'm trying to map a struct definition using ctypes:
struct attrl {
struct attrl *next;
char *name;
char *resource;
char *value;
};
I'm unsure what to do with the "next" field of the struct in the ctypes mapping. A definition like:
class att...
Why code like that is not catching CTRL-C?
MaxVal = 10000
StepInterval = 10
for i in range(1,MaxVal,StepInterval):
try:
print str(i)
except KeyboardInterrupt:
break
print "done"
My expectation is -- if CTRL-C is pressed while program is running, KeyboardInterrupt is supposed to leave the loop. It does not.
A...
I'd like to map an int value pbs_errno declared as a global in the library libtorque.so using ctypes.
Currently I can load the library like so:
from ctypes import *
libtorque = CDLL("libtorque.so")
and have successfully mapped a bunch of the functions. However, for error checking purposes many of them set the pbs_errno variable so I ...
I've got a string, a signature, and a public key, and I want to verify the signature on the string. The key looks like this:
-----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDfG4IuFO2h/LdDNmonwGNw5srW
nUEWzoBrPRF1NM8LqpOMD45FAPtZ1NmPtHGo0BAS1UsyJEGXx0NPJ8Gw1z+huLrl
XnAVX5B4ec6cJfKKmpL/l94WhP2v8F3OGWrnaEX1mLMoxe124Pcfamt0...
I am trying to plot a bunch of data points (many thousands) in Python using matplotlib so I need each marker to be very small and precise. How do I get the smallest most simple marker possible? I use this command to plot my data:
matplotlib.pyplot( x , y ,'.',markersize=0.1,linewidth=None,markerfacecolor='black')
Then I can look at...
I have a model Post, and a model Vote. Vote (form django-voting) is essentially just a pointer to a Post and -1, 0, or 1.
There is also Tourn, which is a start date and an end date. A Post made between the start and end of a Tourn is submitted to that tournament.
For the sake of rep calculation, I'm trying to find the top 3 winners of...
I have enum and use the variables like myEnum.SomeNameA, myEnum.SomeNameB, etc. When I return one of these variables from a function, can I print their names (such as myEnum.SomeNameA) instead of the value they returned?
...
I am trying to determine the best way to handle getting rid of newlines when reading in newline delimited files in Python.
What I've come up with is the following code, include throwaway code to test.
import os
def getfile(filename,results):
f = open(filename)
filecontents = f.readlines()
for line in filecontents:
foo = ...
I know this question has been asked before, but there was no clear answer.
How do I change the printer tray programmatically?
I am trying to use python to batch print some PDFs. I need to print different pages from different trays. The printer is a Ricoh 2232C. Is there a way to do it through and Acrobat Reader command line parame...
Hi,
I need to write a script in python to check a webpage, which is protected by kerberos. Is there any possibility to do this from within python and how? The script is going to be deployed on a linux environment with python 2.4.something installed.
dertoni
...
Surely there must be a way to do this easily!
I've tried the linux command-line apps sha1sum & md5sum but they seem only to be able to compute hashes of individual files and output a list of hash values, one for each file.
I need to generate a single hash for the entire contents of a folder (not just the filenames).
I'd like to do s...
I'm using base class constructor as factory and changing class in this constructor/factory to select appropriate class -- is this approach is good python practice or there are more elegant ways?
I've tried to read help about metaclasses but without big success.
Here example of what I'm doing.
class Project(object):
"Base class and ...
I used to be a java developer and we used tools like ant or maven to manage our development/testing/UAT environments in a standardized way. This allowed us to handle library dependencies, setting OS variables, compiling, deploying, running unit tests, and all the required tasks. Also, the scripts generated guaranteed that all the environ...
I am creating a little dashboard for a user that will allow him to run specific jobs. I am using Django so I want him to be able to click a link to start the job and then return the page back to him with a message that the job is running. The results of the job will be emailed to him later.
I believe I am supposed to use subprocess.Po...
Hey,
I am using the datetime module. I am looking to calculate the date 6 months from the current date. Could someone give me a little help doing this?
Edit: The reason I am wanting to generate a date 6 months from the current date is to produce a Review Date. If the user enters data into the system it will have a review date of 6 mo...
I'm using Python 2.x and I have an object I'm summoning from the aether; the documentation on it is not particularly clear. I would like to be able to get a list of properties for that object and the type of each property.
Similarly, I'd like to get a list of methods for that object, as well, plus any other information I could find o...
Hi there,
I am trying to write a view that will generate a report which displays all Items within my Inventory system, and provide summaries at a certain point. This report is purely just an HTML template by the way.
In my case, each Item is part of an Order. An Order can have several items, and I want to be able to display SUM based s...
It seems like many OO discussions use Java or C# as examples (e.g. Head First Design Patterns).
Do these patterns apply equally to Python? Or if I follow the design patterns, will I just end up writing Java in Python (which apparently is a very bad thing)?
...
Is it possible to split a file? For example you have huge wordlist, I want to split it so that it becomes more than one file. How is this possible?
...
Does anyone know of a django forum plugin that allows each member to have his own forum? If there isn't anything, than what would be the best way to accomplish this with a "regular" forum plugin for Django?
...