(Serious?) package namespace problem (and a proposal)
Gordon McMillan
gmcm at hypernet.com
Wed Jun 28 19:27:26 EDT 2000
Sean Blakey wrote:
>On Wed, Jun 28, 2000 at 09:56:27PM +0000, Huaiyu Zhu wrote:
[snip]
>OK, I think I see what you mean. You are objecting to the way that
>python searches first for modules in the local directory before
>searching the normal PYTHONPATH, correct?
>If you don't want python to search the current directory for imports,
>there is a very simple solution: put this snippet above all of your
>other imports: import sys
>sys.path.remove('.')
Not a real solution. If module x is part of a package, and does an "import
y", then the package is searched first. This has nothing to do with '.'
being on sys.path. It's called a "relative import", and it means that if
you have "package.os", then the real "os" is unavailable anywhere in
"package". Period.
I think the "relative import" feature should be shot in the head (2 posts
today), but unfortunately most packages rely heavily on it.
- Gordon
More information about the Python-list
mailing list