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

John Roth newsgroups at jhrothjr.com
Wed Mar 10 08:13:46 EST 2004


"Gerrit" <gerrit at nl.linux.org> wrote in message
news:mailman.217.1078918903.19534.python-list at python.org...
Aahz wrote:
> * Long ``import`` statements can be difficult to write, requiring
>   various contortions to fit Pythonic style guidelines.

> 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)
>
> This part of the proposal already has BDFL approval.

Why are the parentheses necessary?
What's wrong with:

from Tkinter import Tk, Frame, Button,
    Entry, Canvas, Text,
    LEFT, DISABLED, NORMAL

...where Python's normal indentation mechanism provides the grouping?


[response]
Because it's a deviation from the syntax elsewhere in Python.
It's not clear that the trailing comma means the statement is
to be continued. I'm not sure whether the trailing comma is
valid or whether it causes an error, but in neither case is it
regarded as an indication that the statment is to be continued.

It might be interesting to do it that way, but if so it should be
accepted as a continuation indicator in all contexts.

John Roth
[/response]


Gerrit.

-- 
Weather in Twenthe, Netherlands 10/03 11:25 UTC:
2.0°C light snow overcast wind 5.4 m/s NE (57 m above NAP)
-- 
Asperger's Syndrome - a personal approach:
http://people.nl.linux.org/~gerrit/english/





More information about the Python-list mailing list