Message60495
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. |
|
| Date |
User |
Action |
Args |
| 2008-01-20 09:56:55 | admin | link | issue966431 messages |
| 2008-01-20 09:56:55 | admin | create | |
|