From: Richard Cooper firstname.lastname@example.org Date: Wed May 19, 2004 1:34:12 pm Europe/London To: email@example.com Subject: Re: .pth files in current or script directory
Seems this message got lost somewhere. So subscribing and resending.
Greg Ewing wrote:
Richard Cooper <anon at server15.ukservers.net>:
When a module is imported, its import search path includes
does now PLUS the directory that is the top of the module's
I don't see how that changes anything, since in order to get imported in the first place, the module's top-level package has to already be on the module search path somehow.
Sorry, slip of the brain. I meant "When a module is executed ..."
What's wrong with PEP 328?
Nothing, I think it's great. However it talks about making import statement absolute by default (searching sys.path only) without worrying about how a package gets on sys.path in the first place.
Currently a module can't import (absolutely) from it's own package unless: 1) Its package is in one of a few special places (like site-packages) 2) The package is in PYTHONPATH 3) The module does some sys.path tinkering before the import
None of these are great solutions. My initial problem was that I picked the PYTHONPATH solution which (as you all know) turns out to be a real pain when working on cvs branches.
If the top of the containing package got added to sys.path when a module is executed then importing (absolutely) from your own package would (I think) just work. And given that PEP 328 is going to encourage absolute imports and is going to be changing import semantics anyway, I think this would be a nice feature to have.