Package question
Hans Nowak
hnowak at cuci.nl
Tue Sep 26 00:51:05 EDT 2000
More information about the Python-list mailing list
Tue Sep 26 00:51:05 EDT 2000
- Previous message (by thread): Package question
- Next message (by thread): Package question
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 25 Sep 00, at 19:44, Bernhard Herzog wrote: > > > Hans Nowak <ivnowa at hvision.nl> writes: > > > > > > > myprogram.py > > > > MainPackage\ > > > > a.py > > > > SubPackage1\ > > > > b.py > > > > SubPackage2\ > > > > c.py > > > > > > > > In such cases, b.py cannot find a.py and thus it cannot use any > > > > general modules in MainPackage. Neither can it see c.py in > > > > SubPackage2. > > > > > > Just use > > > > > > import MainPackage.a > > > > > > and > > > import MainPackage.SubPackage2.b > > > > Yes, but that is exactly the problem... b.py cannot see MainPackage > > either. Unless I add it to sys.path, which I *don't* want to do. =( > > But in myprogram.py "import MainPackage.a" works? IOW, is the directory > containing myprogram.py and MainPackage in sys.path? In most cases it's > automatically put into sys.path by the interpreter. > > If that directory is in sys.path "import MainPackage.a" should work from > inside the package too. Hmm... it's visible, because it's in the current directory (= the same directory as myprogram.py)... This is not exactly what I had in mind, but it helps at least some. I knew that these (sub)packages can import each other as long as the top (MainPackage) is in sys.path, but I did not realize that starting myprogram.py would automatically make MainPackage visible thru that same sys.path. Anyway, the problem I had with this construct is that I like to test separate modules... e.g. going to MainPackage/SubPackage1 and start b.py... and that would not work, since in that case the MainPackage directory will not be implicitly added to sys.path. But it's not too important. This helps some. ^_^ Thanks, --Hans Nowak (zephyrfalcon at hvision.nl) You call me a masterless man. You are wrong. I am my own master. May a gardener introduce Tipper Gore to your little toe!
- Previous message (by thread): Package question
- Next message (by thread): Package question
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list