By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,261 Members | 1,658 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,261 IT Pros & Developers. It's quick & easy.

Re[2]: import fails

P: n/a
exarkun@boson:~$ cat foo.py
x = 10
__all__ = [x]
exarkun@boson:~$ cat bar.py
x = 20
__all__ = ['x']
exarkun@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@boson:~$ python -c "from bar import *; print x"
20
exarkun@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:ga*****@geochemsource.com
web:http://designasign.biz
Jul 18 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.