[Python-ideas] Pseudo-package for current directory

Joseph Martinot-Lagarde contrebasse at gmail.com
Wed Mar 9 05:30:51 EST 2016


Nick Coghlan <ncoghlan at ...> writes:

> Accordingly, the proposal I'm most amenable to is the one to simply
> change the default precedence of the current directory on sys.path by
> moving it to the end of the filesystem search (after the standard
> library, site-packages, user site-packages, etc). This wouldn't affect
> the -m switch (or the runpy module in general), since that manipulates
> sys.path directly, and would mean creating a "socket.py" script to
> experiment with the socket modules would "just work".
> 

That would mean that any addition of a module in the standard libary is a
compatibility break, because the new module in the standard library would
shadow any module in the local directory.

To me the cleanest (from a user point of view) way would be to enable "from
. import xxx" in scripts outside packages. When I learned about relative
imports I was really surprised by this limitation. If it was possible I'd
use it everywhere.

Joseph



More information about the Python-ideas mailing list