John Salerno wrote:
> How does the __init__ file help if you are still individually importing
> class1 and class2 in each other module of your program?

Felipe's example is a little confusing because he uses the same name
for the module and the class. Here's another example:

---  package/class1.py ---

class C1:
        pass

--- package/class2.py ---

class C2:
        pass

--- package/__init__.py ---

from class1 import C1
from class2 import C2

--- end ---

Now, in your code you can do:

import package

c = package.C1()

If you hadn't included the lines in __init__.py, you would have to
write:

import package

c = package.class1.C1()

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to