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

Peter Otten __peter__ at web.de
Sun Dec 23 22:14:37 CET 2012


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'

You have assigned a built-in function to the curs variable. Example:

>>> curs = open
>>> curs.execute
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'builtin_function_or_method' object has no attribute 
'execute'

You can find out the name of the actual function with

>>> print curs.__name__
open

PS: This question is only loosely related to your previous question. You 
should have started a new thread.







More information about the Python-list mailing list