Newbie packages Q
MarkyMarc
marcsgbrevkonto at gmail.com
Sun Oct 7 12:18:00 EDT 2007
On Oct 7, 6:04 pm, Bruno Desthuilliers <bruno.
42.desthuilli... at wtf.websiteburo.oops.com> wrote:
> MarkyMarc a écrit :
> (snip)
>
> > It was simply to make a point. But then lets say the to files looks
> > like this:
>
> > *******************************
> > atest.py:
>
> > def printA():
> > print "This is Atest from Apack"
> > *******************************
> > btest.py:
> > from Test.apack import atest
>
> FWIW, better to stick to all_lower names for packages and modules.
>
>
>
> > def printB():
> > print "This is Btest from Bpack"
>
> > def printatest():
> > print atest.printA()
>
> > print printB()
> > print printatest()
> > *******************************
>
> > Now only one of them imports the other, and this most be the simplest
> > way of illustrating the intra-package references.
>
> > But how do I get this to work?
>
> You failed to specify how your files are organized, and what is "not
> working".
>
> But anyway, if
> - atest.py is in <wherever>/Test/apack,
> - both Test and apack have a __init__.py
> - <wherever> is in the sys.path,
>
> then this should just work AFAICT.
If you se me first post you will see have me files are organized. But
like this:
Test/
__init__.py (a empty file)
apack/
__init__.py (a empty file)
atest.py
bpack/
__init__.py (a empty file)
btest.py
And also in me first post(and others),
all I get is an import error: ImportError: cannot import name apack.
And sys.path is /python/Test/bpack
More information about the Python-list
mailing list