__init__.py and package help

TechieInsights GDoermann at gmail.com
Mon Jan 5 20:49:09 CET 2009

Ok I have read all of the tutorials and documents I could find.  I am
running Python 2.6 on windows.  The problem I am having with packages
is that they don't show up!

Simple example of what isn't working...

pytest/ Root directory of package
    __init__.py-  code: __all__ = ['folder']
    folder/   Another folder in the package
        __init__.py- code: __all__ = ['hello']
        hello.py- code: print('Hello World')

Then I append the path to sys.path, and try and import...

>>> sys.path.append(r'E:\dev\test\pytest')
>>> from pytest.folder import hello
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named pytest.folder

What am I doing wrong!  It's driving me crazy.
Thanks in advance,

More information about the Python-list mailing list