__init__.py and package help
TechieInsights
GDoermann at gmail.com
Mon Jan 5 15:05:45 EST 2009
Thanks
J. Cliff Dyer wrote:
> On Mon, 2009-01-05 at 11:49 -0800, TechieInsights wrote:
> > 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...
> > Structure-
> >
> > 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,
> > Greg
>
> You want
>
> >>> sys.path.append(r'E:\dev\test')
>
> unless your code is in E:\dev\test\pytest\pytest\folder\hello.py
>
>
> > --
> > http://mail.python.org/mailman/listinfo/python-list
> >
More information about the Python-list
mailing list