python

backend for python

which is the best back end for python applications and what is the advantage of using sqlite ,how it can be connected to python applications ...

Is there any Ruby or Python interpreter for Lego Mindstorm?

I want to start coding in Python or Ruby. Since I own a Lego Midstorms kit I thought it would be nice to program against it. Are there any good translators / interpeters for the Mindstorms brick? ...

PostgreSQL - how to run VACUUM from code outside transaction block?

I am using Python with psycopg2 and I'm trying to run a full VACUUM after a daily operation which inserts several thousand rows. The problem is that when I try to run the VACUUM command within my code I get the following error: psycopg2.InternalError: VACUUM cannot run inside a transaction block How do I run this from the code outsid...

NameError: global name 'has_no_changeset' is not defined

OK - Python newbie here - I assume I am doing something really stupid, could you please tell me what it is so we can all get on with our lives? I get the error NameError: global name 'has_no_changeset' is not defined in the line 55 (where I try calling the function has_no_changeset). from genshi.builder import tag from trac.core impor...

Why isn't Python very good for functional programming?

I have always thought that functional programming can be done in Python. Thus, I was surprised that Python didn't get much of a mention in this question, and when it was mentioned, it normally wasn't very positive. However, not many reasons were given for this (lack of pattern matching and algebraic data types were mentioned). So my ques...

Is there an API to access a Google Group data?

Hey there, I'm trying to build some statistics for an email group I participate. Is there any Python API to access the email data on a GoogleGroup? Also, I know some statistics are available on the group's main page. I'm looking for something more complex than what is shown there. ...

Formatting csv file data with html template

I have an csv file, the data, and an HTML file, the template. I want a script that will create an individual html file per record from the csv file, using the html file as a template. Which is the best way to do this in Ruby? Python? Is there a tool/library I can use for this in either language? ...

Python sys.path modification not working

I'm trying to modify the sys.path in one of my Python files in order to have some specific libraries dirs in the modules search path (it might not be the best way but ...). If I insert several paths in the front of sys.path my script is not taking into account those paths for future imports. If i make a whole new list containing those ...

How do I know which contract failed with Python's contract.py?

I'm playing with contract.py, Terrence Way's reference implementation of design-by-contract for Python. The implementation throws an exception when a contract (precondition/postcondition/invariant) is violated, but it doesn't provide you a quick way of identifying which specific contract has failed if there are multiple ones associated w...

Help me understand the difference between CLOBs and BLOBs in Oracle

This is mainly just a "check my understanding" type of question. Here's my understanding of CLOBs and BLOBs as they work in Oracle: CLOBs are for text like XML, JSON, etc. You should not assume what encoding the database will store it as (at least in an application) as it will be converted to whatever encoding the database was config...

One django installation different users per site

How can I have different users for different sites with django. My application should look like this: a.mydomain.com b.otherdomain.com Users should be bound to the domain, so that a.mydomain.com and b.otherdomain.com have different users. ...

Pass-through keyword arguments

I've got a class function that needs to "pass through" a particular keyword argument: def createOrOpenTable(self, tableName, schema, asType=Table): if self.tableExists(tableName): return self.openTable(tableName, asType=asType) else: return self.createTable(self, tableName, schema, asType=asType) When I call it...

Python and if statement

I'm running a script to feed an exe file a statement like below: for j in ('90.','52.62263.','26.5651.','10.8123.'): if j == '90.': z = ('0.') elif j == '52.62263.': z = ('0.', '72.', '144.', '216.', '288.') elif j == '26.5651': z = ('324.', '36.', '108.', '180.', '252.') else: z = ('288.'...

Python logging incompatibilty between 2.5 and 2.6

Could you help me solve the following incompatibility issue between Python 2.5 and 2.6? logger.conf: [loggers] keys=root,aLogger,bLogger [handlers] keys=consoleHandler [formatters] keys= [logger_root] level=NOTSET handlers=consoleHandler [logger_aLogger] level=DEBUG handlers=consoleHandler propagate=0 qualname=a [logger_bLogger] l...

'Unstarring' posts using Google Reader API

Does anybody know how to remove stars for articles starred in Google Reader using its unofficial API? I found this one but it doesn't work: http://www.niallkennedy.com/blog/2005/12/google-reader-api.html Neither does the pyrfeed module in Python, I get the IOError exception every time. ...

Python tkInter text entry validation

I'm trying to validate the entry of text using Python/tkInter def validate_text(): return False text = Entry(textframe, validate="focusout", validatecommand=validate_text) where validate_text is the function - I've tried always returning False and always returning True and there's no difference in the outcome..? Is there a set ...

Difference between using __init__ and setting a class variable

I'm trying to learn descriptors, and I'm confused by objects behaviour - in the two examples below, as I understood __init__ they should work the same. Can someone unconfuse me, or point me to a resource that explains this? import math class poweroftwo(object): """any time this is set with an int, turns it's value to a tuple of the ...

How to replace a column using Python's built-in .csv writer module?

I need to do a find and replace (specific to one column of URLs) in a huge Excel .csv file. Since I'm in the beginning stages of trying to teach myself a scripting language, I figured I'd try to implement the solution in python. I'm having trouble with the "replace" part of the solution. I've read the official csv module documentation a...

Algorithm for updating a list from a list

I've got a data source that provides a list of objects and their properties (a CSV file, but that doesn't matter). Each time my program runs, it needs to pull a new copy of the list of objects, compare it to the list of objects (and their properties) stored in the database, and update the database as needed. Dealing with new objects is ...

Is there an easy way to convert an std::list<double> to a Python list?

I'm writing a little Python extension in C/C++, and I've got a function like this: void set_parameters(int first_param, std::list<double> param_list) { //do stuff } I'd like to be able to call it from Python like this: set_parameters(f_param, [1.0, 0.5, 2.1]) Is there a reasonably easy way to make that conversion? Ideally, I'd ...