Message 60495 - Python tracker

Message60495

Author arigo
Recipients
Date 2004-06-04.10:58:58
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
To get to the module object from the body of the module itself, the usual trick is to import it from itself, as in:

x.py:
import x
do_stuff_with(x)

This fails strangely if x is in a package:

package/x.py:
import package.x
do_stuff_with(package.x)

The last line triggers an AttributeError: 'module' object has no attribute 'x'.  In other words, the import succeeds but the expression 'package.x' still isn't valid after it.
History
Date User Action Args
2008-01-20 09:56:55adminlinkissue966431 messages
2008-01-20 09:56:55admincreate