[Python-Dev] Relative import (original) (raw)

Kevin Jacobs jacobs at penguin.theopalgroup.com
Tue Dec 16 13:35:14 EST 2003


On Tue, 16 Dec 2003, Guido van Rossum wrote:

There is the remaining issue of what exactly the syntax would be. I propose to extend the from clause to allow one or more dots before the dotted name, and to make the dotted name optional if at least one leading dot is found. I propose not to change from-less import. Examples:

from .foo import bar from .foo.bar import xxx from . import foobar as barfoo from ..foo.bar import * from ... import foobar, barfoo Grammar change (see Grammar/Grammar): dottedname: NAME ('.' NAME)* | '.'+ [NAME ('.' NAME)*]

On a related and minor note, can we please expand the grammar to allow from...import statements to continue to the next line after a trailing comma? For those of us with large, complex, and componentized projects, it would be very nice. e.g.:

from OPAL.Modules.Financial.Reports.COGS import generate, webOptions, normalize, row_ops, summary

instead of:

from OPAL.Modules.Financial.Reports.COGS import generate, webOptions,
normalize, row_ops,
summary

This has been a minor nit that bothers just under the threshold of fixing it myself. ;)

Thanks, -Kevin

--

Kevin Jacobs The OPAL Group - Enterprise Systems Architect Voice: (440) 871-6725 x 19 E-mail: jacobs at theopalgroup.com Fax: (440) 871-6722 WWW: http://www.theopalgroup.com/



More information about the Python-Dev mailing list