I'd like to be able to write apps for my G15 keyboard using python. There seems to be a few people out there who have done it in the past, but I'm not sure what packages I need to install or where I should start. Does anyone have any experience with this?
...
A little background:
PEP 8 is the Style Guide for Python Code. It contains the conventions all python programmers should follow.
pep8.py is a (very useful) script that checks the code formating of a given python script, according to PEP 8.
Eclipse is a great IDE. With the Pydev extension, it that can be used to develop Python
I run p...
I'm trying to write a circuit schematic drawing tool in Python. I'm creating a simple database based on dictionaries which holds all the components and their properties. I'm also trying to create a simple query language where you can select, for example, all resistors with value>100ohms or footprint='0402'
So far, I can select thing...
I am using XML minidom (xml.dom.minidom) in Python, but any error in the XML will kill the parser.
Is it possible to ignore them, like a browser for example?
I am trying to write a browser in Python, but it just throws an exception if the tags aren't fully compatible.
...
When I pass the options in the program (a computational biology experiment) I usually pass them through a .py file.
So I have this .py file that reads like:
starting_length=9
starting_cell_size=1000
LengthofExperiments=5000000
Then I execute the file and get the data. Since the program is all on my machine and no one else has access t...
Using Python, how would I go about reading in (be from a string, file or url) a mathematical expression (1 + 1 is a good start) and executing it?
Aside from grabbing a string, file or url I have no idea of where to start with this.
...
Does * have a special meaning in Python as it does in C? I saw a function like this in the Python Cookbook:
def get(self, *a, **kw)
Would you please explain it to me or point out where I can find an answer (Google interprets the * as wild card character and thus I cannot find a satisfactory answer).
Thank you very much.
...
I need to resize jpg images with Python without losing the original image's EXIF data (metadata about date taken, camera model etc.). All google searches about python and images point to the PIL library which I'm currently using, but doesn't seem to be able to retain the metadata. The code I have so far (using PIL) is this:
img = Image....
Assume I have a form
class SampleClass(forms.Form):
name = forms.CharField(max_length=30)
age = forms.IntegerField()
django_hacker = forms.BooleanField(required=False)
Is there a way for me to define css classes on each field such that I can then use jQuery based on class in my rendered page?
I was hoping not to have to m...
I'm using Django to write a blog app, and I'm trying to implement a hierarchical category structure. Each category has a "parent" ForeignKey pointing back to the same Category model. I want to allow admins to add categories, and I want the interface to allow them to select a category's parent category. However, I want to avoid I'm-my-...
I'm working on a Python library that interfaces with a web service API. Like many web services I've encountered, this one requests limiting the rate of requests. I would like to provide an optional parameter, limit, to the class instantiation that, if provided, will hold outgoing requests until the number of seconds specified passes.
I ...
In Django, I've got loggers all over the place, currently with hard-coded names.
For module-level logging (i.e., in a module of view functions) I have the urge to do this.
log= logging.getLogger( __name__ )
For class-level logging (i.e., in a class __init__ method) I have the urge to do this.
self.log= logging.getLogger( "%s.%s" % (...
How can I make a pattern match so long as it's not inside of an HTML tag?
Here's my attempt below. Anyone have a better/different approach?
import re
inputstr = 'mary had a <b class="foo"> little loomb</b>'
rx = re.compile('[aob]')
repl = 'x'
outputstr = ''
i = 0
for astr in re.compile(r'(<[^>]*>)').split(inputstr):
i = 1 - i
...
Does anybody know how to scale the y-axis with matplotlib? I don't want to change the y-limit, I just want to extend the physical space.
^ ^
| |
| |
+----> |
Before +---->
After
Thanks!
...
I need to store some data on a Django model. These data are not equal to all instances of the model.
At first I thought on subclassing the model, but I'm trying to keep the application flexible; if I use subclasses, I'll need to create a whole class each time i need a new kind of object, and that's no good. I'll also end up with a lot o...
Can you simply delete the directory from your python installation, or are there any lingering files that you must delete?
...
My idea of program:
I have a dictionary:
options = { 'string' : select_fun(function pointer),
'float' : select_fun(function pointer),
'double' : select_fun(function pointer)
}
whatever type comes single function select_fun(function pointer) gets called.
Inside select_fun(function pointer),I will have diff functions for float, double ...
I currently have a unittest.TestCase that looks like..
class test_appletrailer(unittest.TestCase):
def setup(self):
self.all_trailers = Trailers(res = "720", verbose = True)
def test_has_trailers(self):
self.failUnless(len(self.all_trailers) > 1)
# ..more tests..
This works fine, but the Trailers() call t...
I want to see the type of a variabe whether it is unsigned 32 bit,signed 16 bit etc.
How to view...
...
I've got a list of Python objects that I'd like to sort by an attribute of the objects themselves. The list looks like:
>>> ut
[<Tag: 128>, <Tag: 2008>, <Tag: <>, <Tag: actionscript>, <Tag: addresses>, <Tag: aes>, <Tag: ajax> ...]
Each object has a count:
>>> ut[1].count
1L
I need to sort the list by number of counts descending.
...