[Import-SIG] Updated PEP 395 ("Qualified Names for Modules" aka "Implicit Relative Imports Must Die!")
Nick Coghlan
ncoghlan at gmail.com
Thu Nov 24 00:05:53 CET 2011
On Sat, Nov 19, 2011 at 10:59 PM, Nick Coghlan <ncoghlan at gmail.com> wrote:
> The updated version is includes below and has also been updated on
> python.org if you prefer a nicely formatted version:
> http://www.python.org/dev/peps/pep-0395/
>
> The recent discussion regarding imports from main really crystallised
> for me what I think is currently wrong with imports from main modules
> - I was cheering when the Django folks updated their default site
> template to avoid putting a package directory on sys.path (due to all
> the problems it causes), but that thread made me realise how easy we
> make it for beginners to do that by accident, with no real payoff of
> any kind to justify it.
>
> So the PEP now spends a lot of time talking about the fact that our
> current system for initialising sys.path[0] is almost always just
> plain wrong as soon as packages are involved, but the explicit markers
> on package directories make it possible for us to do the right thing
> instead of being dumb about it.
*crickets*
No feedback at all on the prospect of changing the way we initialise
sys.path[0] to respect the package information available on the
filesystem?
Also, Éric Araujo raised an interesting point [1], automatically
initialising sys.path[0] *at all* can be a problem in some
circumstances, especially when symlinks are involved. PEP 395 won't
really help with that (it may change some of the symptoms, but it
won't fix the general problem), but it does make me wonder if the
interpreter should have a flag to switch off sys.path[0]
initialisation (similar to the existing flags to disable site
processing, user site processing and processing of the PYTHONHOME and
PYTHONPATH environment variables).
[1] http://bugs.python.org/issue10318 (last couple of comments)
Cheers,
Nick.
--
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
More information about the Import-SIG
mailing list