Bug in handling of single underscore identifiers?
tom.blackwell at sympatico.ca
Tue Jan 4 17:55:15 EST 2005
Today I installed the 'mechanoid' package from sourceforge, but the
self-test failed. On looking into it, I noticed odd behaviour in the
handling of single underscore module names. Importing into the
current namespace with 'from' seems to work, but accessing members of
the imported module only works if the imported name is qualified by
the containing module name.
>>> from mechanoid import _mechanoid_Common
>>> from _mechanoid_Common import Common
Traceback (most recent call last):
File "<stdin>", line 1, in ?
ImportError: No module named _mechanoid_Common
>>> from mechanoid._mechanoid_Common import Common
<module 'mechanoid._mechanoid_Common' from
Is this a bug or a feature? The language reference section 2.3.2
'Reserved classes of identifiers' indicates that identifiers starting
with a single underscore are not imported by "from module import *".
However I can't find any indication that "from module import _name"
should work this way.
More information about the Python-list