Packages, modules, libraries,...

Adrian Eyre a.eyre at optichrome.com
Tue Feb 1 09:43:37 EST 2000


> Just to be sure: I guess I have to import cafe before I can import 
> cafe.bacon.

No, but be aware that importing cafe.bacon will implicitly import
the cafe package first, so any code in __init__.py will get executed
first.

> Are there any special demands on cafe/__init__.py compared to
> ordinary modules?

Not as far as I am aware. Bear in mind that any symbols exported in
the __init__.py file will be put in the cafe namespace, so be cafeful
not to use the same names as any modules in the cafe package.

Oh. One more thing I forgot to mention. A package has an additional
attribute called "__path__" which is the full path that the __init__.py
file is in.

-----------------------------------------------------------------
Adrian Eyre <a.eyre at optichrome.com> - http://www.optichrome.com 





More information about the Python-list mailing list