[Python-Dev] package imports, sys.path and os.chdir()
pje at telecommunity.com
Sun Apr 29 05:41:09 CEST 2012
On Sat, Apr 28, 2012 at 12:16 PM, R. David Murray <rdmurray at bitdance.com>wrote:
> That said, could this insertion of '' only happen when the interactive
> prompt is actually posted, and otherwise use cwd?
That's already the case. Actually, sys.path is *always* the absolute
path of the script directory -- regardless of whether you invoked the
script by a relative path or an absolute one, and regardless of whether
you're importing 'site' -- at least on Linux and Cygwin and WIndows, for
all Python versions I've used regularly, and 3.2 besides.
It isn't the value of cwd unless you happen to run a script from the same
directory as the script itself. But even then, it's absolute, and not an
empty string: the empty string is only present for interactive sessions.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-Dev