PEP 328 update

Carl Banks imbosol at aerojockey.com
Tue May 4 15:54:22 EDT 2004


"John Roth" <newsgroups at jhrothjr.com> wrote in message news:<109f147o3e1jm9d at news.supernews.com>...
> "Carl Banks" <imbosol at aerojockey.invalid> wrote in message
> news:yMClc.12854$Gq1.5974 at fe2.columbus.rr.com...
> > John Roth wrote:
> > >
> > >
> > >
> > > "Aahz" <aahz at pythoncraft.com> wrote in message
> > > news:c76k9g$rf0$1 at panix1.panix.com...
> > >> In article <109d87iiu30ct7a at news.supernews.com>,
> > >> John Roth <newsgroups at jhrothjr.com> wrote:
> > >> >
> > >> >I also don't particularly see the reason for banning the relative form
> > >> >from raw import statements.
> > >>
> > >> Did you see the rationale toward the end?
> > >
> > > Yes. From my point of view, the . is an operator or a
> > > decorator. It is not a part of the name; if it was, the
> > > system would be unable to find the module on disk,
> > > because that name does not have the dot.
> > >
> > > The rationale makes no sense whatsoever.
> >
> >
> > Look at it this way:
> >
> > If you do "import abc.def.ghi", then the module ghi gets imported
> > (along with packages abc and def); however, only the only symbol that
> > gets bound is "abc".
> >
> > If you try to do "import .ghi", well, it's obvious that you're
> > imporing a sister module, but it's not clear what symbol should be
> > bound.  (Do you bind "ghi" or "abc"?)
> 
> Why isn't it clear?

Because some people see the little dot there and mentally expand it to
an indeterminate package name.  This is a valid way to look at it. 
And, if you look at it like that, "import .ghi" binding "ghi" is
inconsistent with how import normally works.  Import never binds the
module name when there's a package present; why should it start now?

The point is, there is more than one way to conceive this.  Your way
of looking at it is valid, but your way is not the only way.  If you
are capable of accepting other viewpoints other than your own, then
maybe you can see why "import .ghi" is not clear.  OTOH, "from .
import ghi" is totally clear and unambiguous.

I say the PEP correctly opts for clarity and lack of reduncancy.


-- 
CARL BANKS



More information about the Python-list mailing list