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

Brett Cannon brett at python.org
Sat Apr 28 21:20:58 CEST 2012


On Sat, Apr 28, 2012 at 12:16, R. David Murray <rdmurray at bitdance.com>wrote:

> On Sat, 28 Apr 2012 18:08:08 +1000, Nick Coghlan <ncoghlan at gmail.com>
> wrote:
> > On Sat, Apr 28, 2012 at 6:00 AM, Brett Cannon <brett at python.org> wrote:
> > > I'm personally in favour of changing the insertion of '' to sys.path to
> > > inserting the cwd when the interpreter is launched.
> >
> > I'm not, because it breaks importing from the interactive prompt if
> > you change directory after starting the session.
>
> Heh.  I've never thought of doing that.  I would not have expected it
> to work (change directory from the interactive prompt and be able to
> import something located in the new cwd).  I don't know why I wouldn't
> have expected it to work, I just didn't.
>
> That said, could this insertion of '' only happen when the interactive
> prompt is actually posted, and otherwise use cwd?


If the decision to keep this entry around stands, can we consider changing
it to '.' instead of the empty string? It mucks up stuff if you are not
careful (e.g. ``os.listdir('')`` or ``"/".join(['', 'filename.py'])``).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20120428/192c212d/attachment.html>


More information about the Python-Dev mailing list