PEP 328 update

Dieter Maurer dieter at handshake.de
Fri May 7 14:41:01 EDT 2004


Aahz <aahz at pythoncraft.com> writes on Sun, 2 May 2004 15:20:32 -0400:
> PEP 328 (``import`` changes) has been updated and is available at
> http://www.python.org/peps/pep-0328.html
> 
> Comments on the revised version are welcome.  One area where feedback is
> particularly desired is on the frequency of relative imports inside
> packages in current code, both in absolute terms and as a percentage of
> all imports.

When people do not like the PEP, it is almost always because
of the backward incompatibilty.

Fortunately, importing is a purely local affair.
Why not allow to importing module to specify whether it
wants to have the new or the old import semantics?
E.g. by some kind of declaration...

It would still be necessary for a module which relies
on the old import semantics to get changed. But this
change could be automated, a simple "os.walker" script
could visit the complete package structure and add these
declarations in all modules.


Without such a declaration, lots of stupid work is necessary
to bring old style modules in line with the new semantics.
This is especially painful for modules that use local(!) imports
of the form

        import a....x

I fear, this must become something like

        from .a.... import x as x_rename
        from . import a

In order to be able to access it later in the form "a....x".

How horrible!


Dieter



More information about the Python-list mailing list