Big problem fetching members from dynamically loaded module

Peter Otten __peter__ at
Sun Jun 26 08:45:54 CEST 2005

Philippe C. Martin wrote:

> Any clue would be quite welcome.

I didn't recognize the pattern in the code you posted, but sometimes the
order of imports matters:

$ find .
$ python
Python 2.3.3 (#1, Feb  5 2005, 16:22:10)
[GCC 3.3.3 (SuSE Linux)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from package.beta import *
>>> from package import *
>>> from package.alpha import *
>>> alpha
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
NameError: name 'alpha' is not defined
>>> beta
<module 'package.beta' from 'package/'>

The 'right' way to do the imports if you want both 'alpha' and 'beta' is of

from package import alpha
from package import beta


More information about the Python-list mailing list