PEP 328: Imports: Multi-Line and Absolute/Relative

Andrew Clover and-google at
Tue Mar 9 11:12:43 CET 2004

aahz at (Aahz) wrote:

>     from Tkinter import (Tk, Frame, Button, Entry, Canvas, Text

+0. I don't see this as a particularly pressing problem, but the solution
is logical and readable.

> Because this represents a change in semantics, absolute imports will
> be optional in Python 2.4 through the use of ::

>     from __future__ import absolute_import

+1. (Can I have +2?)

Accidental relative imports are an annoying stumbling point for new users,
and a marginal security issue for everyone else. I'd like to see
absolute_import introduced and made default as quickly as possible.

>       from .foo import
>       from import

-1. Agree on the 'explicit is better...' criticism. This is just unclear.

>       from __pkg__.__pkg__ import

+1. I don't think it's *that* ugly, or no more ugly than what it's trying
to express. Nested parent-package-references should in any case not be that

I assume you can also do a simple:

  import __pkg__.localmodule

or just:

  import __pkg__

to get the package itself (__init__ module).

I *much* prefer this to the existing implicit syntax. I'm not convinced
I prefer the shortness of __pkg__ over __parent__ or __package__, but I
don't really care much either way.

> * Finally, some people dislike the way you have to change ``import``
>   to ``from ... import`` when you want to dig inside a package.  They
>   suggest completely rewriting the ``import`` syntax

-0. Seems of extremely marginal benefit.

Andrew Clover
mailto:and at

More information about the Python-list mailing list