[Help] [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

Roy Smith roy at panix.com
Sun Dec 23 16:15:12 EST 2012


In article <mailman.1225.1356296379.29569.python-list at python.org>,
 prilisauer at googlemail.com wrote:

> Thanks to all your answers, I have read a lot about namespaces, but still 
> there's something I do not understood. I have tried your example but as I 
> expected:
> 
> line 13, in HandoverSQLCursor
>     curs.execute("SELECT * FROM lager")
> AttributeError: 'builtin_function_or_method' object has no attribute 
> 'execute'
> 
> I will try my best to write tomorrow a sample as detailed as possible.
> 
> Good evening

Polishing up my crystal ball, I'm going to guess you're using one of the 
Python Database APIs (http://www.python.org/dev/peps/pep-0249/).  And 
that at some point, you tried to generate a cursor by doing:

   curs = connection.cursor

instead of 

   curs = connection.cursor()

This left you with curs being (a reference to) the cursor function 
itself, rather than what the function returns when it's called.

You own the oracle 20 minutes spent reading ESR's classic essay, "How To 
Ask Questions The Smart Way" (http://tinyurl.com/cabqnop).



More information about the Python-list mailing list