Package

Matthieu Pichaud matth at gmx.net
Fri Jun 2 12:08:21 EDT 2006


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/__init__.py	(containing: __all__=['test1'])
/test/test1/
/test/test1/__init__.py	(containing: __all__=['test2'])
/test/test1/test2/
/test/test1/test2/__init__.py	(containing: __all__=['test3'])
/test/test1/test2/test3.py	(containing: print 'test3')

Then I run:
 >>> from test import *
 >>> test1
<module 'test.test1' from 'test/test1/__init__.py'>
 >>> 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.
Is it normal? Am I silly organizing my programs like that?

Thanks for your help!

Matth








More information about the Python-list mailing list