usage of __import__ across two files

Diez B. Roggisch deetsNOSPAM at
Mon Dec 13 13:05:30 CET 2004

>         tb = __import__('BMTest2')

This yields the _module_ BMTest2 in the variable tb. Now in that module
there is a class BMToolbar that defines PrintHello - so this should work:


It worked with your commented lines because you did

from BMTest2 import BMToolbar

which results in BMToolbar beeing part of the global namespace, so you could


I suggest you re-read the tutorial sections covering modules for the
nitty-gritty details of importing.


Diez B. Roggisch

More information about the Python-list mailing list