bruno at modulix onurb at xiludom.gro
Fri Jun 2 19:11:24 CEST 2006

Matthieu Pichaud wrote:
> I have a problem organizing my programs in packages and subpackages.
> I use python.2.3.3
> I built a test structure to try to understand how it worked:
> /test
> /test/    (containing: __all__=['test1'])
> /test/test1/
> /test/test1/    (containing: __all__=['test2'])
> /test/test1/test2/
> /test/test1/test2/    (containing: __all__=['test3'])
> /test/test1/test2/    (containing: print 'test3')
> Then I run:
>>>> from test import *
>>>> test1
> <module 'test.test1' from 'test/test1/'>
>>>> test2
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
> NameError: name 'test2' is not defined

> So it seems that I am very limited in the number of subpackages I can
> create.

Not at all.

> Is it normal?

Yes : when you have nested namespaces, it won't magically become a flat
namespace. There's a mostly clear documention on this in the official
Python tutorial.

> Am I silly organizing my programs like that?

Dunno - it depends on the program. But still:
python -c "import this" | grep nested

bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'onurb at xiludom.gro'.split('@')])"

More information about the Python-list mailing list