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

Thomas Heller theller at python.net
Tue Mar 9 02:41:15 EST 2004


aahz at pythoncraft.com (Aahz) writes:

> I'm a bit late with this, but better late than never...
>
> PEP: 328
> Title: Imports: Multi-Line and Absolute/Relative

There are commas missing imo:

> Rationale for Parentheses
> =========================
>
> Currently, if you want to import a lot of names from a module or
> package, you have to choose one of several unpalatable options:
>
> * Write a long line with backslash continuations::
>
>       from Tkinter import Tk, Frame, Button, Entry, Canvas, Text \
>           LEFT, DISABLED, NORMAL, RIDGE, END
      from Tkinter import Tk, Frame, Button, Entry, Canvas, Text, \
          LEFT, DISABLED, NORMAL, RIDGE, END

> * Write multiple ``import`` statements::
>
>       from Tkinter import Tk, Frame, Button, Entry, Canvas, Text
>       from Tkinter import LEFT, DISABLED, NORMAL, RIDGE, END
>
> (``import *`` is *not* an option ;-)
>
> Instead, it should be possible to use Python's standard grouping
> mechanism (parentheses) to write the ``import`` statement::
>
>     from Tkinter import (Tk, Frame, Button, Entry, Canvas, Text
>         LEFT, DISABLED, NORMAL, RIDGE, END)
    from Tkinter import (Tk, Frame, Button, Entry, Canvas, Text,
        LEFT, DISABLED, NORMAL, RIDGE, END)
>
> This part of the proposal already has BDFL approval.

Thomas





More information about the Python-list mailing list