Re: [Python-Dev] package imports, sys.path and os.chdir()

2012年4月28日 20:43:09 -0700

On Sat, Apr 28, 2012 at 12:16 PM, R. David Murray <[email protected]>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[0] 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.
_______________________________________________
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to