Newbie packages Q

MarkyMarc marcsgbrevkonto at gmail.com
Sun Oct 7 16:58:44 EDT 2007


On Oct 7, 10:31 pm, al... at mac.com (Alex Martelli) wrote:
> MarkyMarc <marcsgbrevko... at gmail.com> wrote:
>
>    ...
>
> > > > > > And sys.path is  /python/Test/bpack
>
> > > sys.path must be a LIST.  Are you saying you set yours to NOT be a list,
> > > but, e.g., a STRING?!  (It's hard to tell, as you show no quotes there).
>    ...
> > > > I also tried to put /python/ and /python/Test in the sys.path same
> > > > result.
>
> > > If the only ITEM in the list that is sys.path is the string '/python',
> > > then any Python code you execute will be able to import Test.apack (as
> > > well as Test.bpack, or just Test).
>
> > Of course I have more than just the /python string in the sys.path.
> > I have a list of paths, depending on which system the code run on.
>
> As long as '/python' comes in the list before any other directory that
> might interfere (by dint of having a Test.py or Test/__init__.py), and
> in particular in the non-pathological case where there are no such
> possible interferences, my assertion here quoted still holds.
>
> If you're having problems in this case, run with python -v to get
> information about all that's being imported, print sys.path and
> sys.modules just before the import statement that you think is failing,
> and copy and paste all the output here, incuding the traceback from said
> failing import.
>
> Alex

OK thank you, with some help from the -v option and debugging I found
a test package in some package. I now renamed it and load it with
sys.path.append.
And now the btest.py works.

BUT does this mean I have to set the path too the package in every
__init__.py class?
Or have do I tell a subpackage that it is part of a big package ?




More information about the Python-list mailing list