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:55 | admin | link | issue966431 messages |
| 2008年01月20日 09:56:55 | admin | create |
|