PEP 328 update

Michael Hudson mwh at python.net
Tue May 4 07:14:09 EDT 2004


aahz at pythoncraft.com (Aahz) writes:

> In article <40967109$1 at nntp0.pdx.net>,
> Scott David Daniels  <Scott.Daniels at Acm.Org> wrote:
> >Aahz wrote:
> >>
> >> 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.
> >
> >I am unclear as to why "import ..moduleA as A" is not allowed.  The only
> >rationale given for disallowing relative imports like "import .foo" is 
> >that .foo is unacceptable as a name.  I'd propose a mandatory AS-clause
> >if the MODULE begins with a period.
> >
> >This would allow me to do something like "import . as mypackage" -- a 
> >case which is perhaps unnecessary.  I just found the "must use the
> >from-style imports" surprising (I agree the change is not vital).
> 
> I'm no expert, but I'd bet that Python's grammar can't support this.
> Someone will be by to correct me if I'm wrong.  ;-)

I think you can do this via the usual 'accept too much in the grammar
and throw things out in the compiler' dance.

Cheers,
mwh

-- 
  ARTHUR:  But which is probably incapable of drinking the coffee.
                    -- The Hitch-Hikers Guide to the Galaxy, Episode 6



More information about the Python-list mailing list