import fails

Laszlo Zsolt Nagy gandalf at geochemsource.com
Sun Dec 5 14:15:26 EST 2004


>     exarkun at boson:~$ cat foo.py
>     x = 10
>     __all__ = [x]
>     exarkun at boson:~$ cat bar.py 
>     x = 20
>     __all__ = ['x']
>     exarkun at boson:~$ python -c "from foo import *; print x"
>     Traceback (most recent call last):
>       File "<string>", line 1, in ?
>     TypeError: attribute name must be string
>     exarkun at boson:~$ python -c "from bar import *; print x"
>     20
>     exarkun at boson:~$ 

>   Hope this helps,


Definitely. However, it would be better if the exception occurred on the
bad assignment (e.g.  __all__ = [x]) but probably it would be
extremely hard to implement. Moreover, you can add items to __all__ in
runtime. Well okay, this is not something humans do. :-)

Another note: the same code was working with 2.3.x, the problem I'm
having is only 2.3.4. - I should have checked the change log.

Thank again

-- 
 Laszlo
 mailto:gandalf at geochemsource.com
 web:http://designasign.biz
 




More information about the Python-list mailing list