I would like to do something like:
dct = ['do_this', 'do_that']
dct[0]() // call do_this
But you can't call the string as a function (will get an error).
How can I achieve this without switching and without using a list of lambdas or functions?
Explicitly I want to refer the function by name.
...
Hey Everyone. I am trying to figure out how to copy a disk based sqlite table to a memory database in python.I know the schema of the table. Is there any easy way to do this?
...
In order to install Python XMP Toolkit,
I
need to install Exempi on my Mac, but doing this is becoming a real nightmare...
After a lot of trouble, i finally made it with boost, and had the fantastic
The Boost C++ Libraries were successfully built!
The following directory should be added to compiler include paths:
/usr/loc...
So I have a view that does a queryset and returns a simple list:
def cdr(request):
queryset = CdrView.objects.all()
return object_list(request,
queryset = queryset,
template_name = "reports/cdrview_list.html",
paginate_by = 200,
page = request.GET.g...
I have a python program which can either act as an executable or Windows service, depending on command-line flags (e.g., -s start would launch it as a service). I'm trying to bundle this as an exe using py2exe, which works all fine and well until I try to start the program as a service. Then, I get the classic "unable to respond" error...
Here more or less is my Python code.
import cx_Oracle
conn = cx_Oracle.connect( "...")
cursor = conn.cursor()
cursor.execute( "SELECT * FROM test_table" )
row = cursor.fetchone():
for col in row:
print type( col )
if isinstance( col, cx_Oracle.OBJECT):
print "true"
If the underlying column in Oracle is of type GEOMETRY, the ...
In Python you can get the path of the file that is executing via __file__ is there a java equivalent?
Also is there a way to get the current package you are in similar to __name__?
And Lastly, What is a good resource for java introspection?
...
I have a function similar to the following:
def getCost(list):
cost = 0
for item in list:
cost += item
return cost
and I call it as so:
cost = getCost([1, 2, 3, 4])
This is GREATLY simplified but it illustrates what is going on. No matter what I do, cost always ends up == 0. If I change the value of cost in the function...
I'm currently writing a python application that will take a directory of text files and parse them into custom python objects based on the the attributes specified in the text file. As part of my application, I compare the current loaded object data set to a previous dataset (same format) and scan it for possible duplicates, conflicts, u...
I have a camera that is taking pictures one by one (about 10 pictures per second) and sending them to PC. I need to show this incoming sequence of images as a live video in PC.
Is it enough just to use some Python GUI framework, create a control that will hold a single image and just change the image in the control very fast?
Or would ...
I am using .kml file which points to an overlay image (presumably in UTM projection?).
The KML file provides the latitudes and longitudes of the bounding box using the "LatLonBox" tag.
I need to calculate the latitudes and longitudes of each pixel in this image.
Are there any pre-existing libraries in Python that would do this for m...
How can I take a dictionary and split it into two lists, one of keys, one of values. For example take:
{'name': 'Han Solo', 'firstname': 'Han', 'lastname': 'Solo', 'age': 37, 'score': 100, 'yrclass': 10}
and split it into:
['name', 'firstname', 'lastname', 'age', 'score', 'yrclass']
# and
['Han Solo', 'Han', 'Solo', 36, 100, 10]
An...
I was trying to pass an additional parameter to my form, which is anObject to ForeignKey relation. But dunno why form returns __init__() got an unexpected keyword argument 'parent' when I'm pretty sure that it is possible to send additional parameters to form's __init__ (ie here : http://stackoverflow.com/questions/3182262/simple-form-no...
In python, how does one split a SHA256 hash into a 32bit prefixes? I'm working with Google's safebrowsing api, which requires that I compare 32bit prefixes between my own collection, and the collection the API sends to me. I understand how to pull the list from Google, and I understand how to form a collection of hashes from parsed URLs,...
I was wondering what are the most popular open source obdc/database connection libraries are.
I've heard of pyodbc, but I wasn't sure how widely used it was.
Thanks
...
To keep it short & sweet:
I'm pulling a sum from a DB which is a decimal value.
I'm trying to use that value in a JSON result
json.dumps( { 'sum': amount } ) #where amount is my Decimal
Django can't serialize the Decimal.
I can convert it to a string, but I'd like a numeric type within the js
If I try and convert it to a float I en...
I have written a custom container object.
According to this page, I need to implement this method on my object:
__iter__(self)
However, upon following up the link to Iterator Types in the Python reference manual, there are no examples given of how to implement your own.
Can someone post a snippet (or link to a resource), that shows ...
How can I see script errors for my python MIDI Remote Scripts in Ableton Live? I've seen references online to a hidden Python console, but no documentation on how to open it, if it would even help me!
Currently I type code, reload the script, and see what happens. If nothing happens, then something is wrong. Very tedious...
Edit: I ...
I am playing around with django and python and have hit a bit of a roadblock here. I query my model and return the objects and then perform some simple operations on the results and return them to the view. After the 2nd request the childs for the forum category are duplicated and I have no idea why this happens.
ForumBuilder class whic...
I have already installed python2.5 and wxpython already, and I also download the pys60 emulation library(four files:"appuifw.py, e32.py, graphics.py, key_codes.py") and put them in the folder: PYTHON25/lib. It works, while I find that this library just provides some simple basic modules, some functions like
appuifw.multi_selection_list...