Tom Blackwell wrote: > 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. > > For example: > >>> 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 > **succeeds** > >>> _mechanoid_Common > <module 'mechanoid._mechanoid_Common' from > 'mechanoid\_mechanoid_Common.pyc'> > > 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.
I don't think this has anything to do with the underscore. The import statement doesn't reference module globals; instead, it uses its own mechanism to find the module you specify: >>> from os import path >>> path.sys <module 'sys' (built-in)> >>> from path import sys Traceback (most recent call last): File "<interactive input>", line 1, in ? ImportError: No module named path In your example ("from _mechanoid_Common import Common"), import can't find any module named "_mechanoid_Common" in site-packages, PYTHONPATH, or other known sources. Robert Brewer MIS Amor Ministries [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list