G
Gary Wilson Jr
I'm creating a python package foo.
What is intended use for __init__.py files?
Well, I found this: http://www.python.org/doc/essays/packages.html
use of the __init__.py file.
Looking at the distutils __init__.py file, it only defines things like
__version__. However, looking at the logging __init__.py file, it is a
1196-line monster with functions and classes defined throughout.
What is the RightThing?
Should I only define things in __init__.py that need to be defined when
importing a subpackage and/or module of package foo?
Is it ok for me to define classes in foo/__init__.py?
Whereby I could do something like:
from foo import MyClass
Or is is better if I were to put these classes and/or functions in foo/core.py?
Whereby I would do something like:
from foo.core import MyClass
What is intended use for __init__.py files?
Well, I found this: http://www.python.org/doc/essays/packages.html
import, but I would really like to see an example or situation that makes goodFrom what I can gather it is for initialization of the package when doing an
use of the __init__.py file.
Looking at the distutils __init__.py file, it only defines things like
__version__. However, looking at the logging __init__.py file, it is a
1196-line monster with functions and classes defined throughout.
What is the RightThing?
Should I only define things in __init__.py that need to be defined when
importing a subpackage and/or module of package foo?
Is it ok for me to define classes in foo/__init__.py?
Whereby I could do something like:
from foo import MyClass
Or is is better if I were to put these classes and/or functions in foo/core.py?
Whereby I would do something like:
from foo.core import MyClass