[Python-Dev] Re: PEP 328 -- relative and multi-line import
Stephan Richter
srichter at cosmos.phy.tufts.edu
Sat Apr 3 08:35:20 EST 2004
On Saturday 03 April 2004 07:52, David Goodger wrote:
> Guido van Rossum wrote:
> > At least "from . import X" and "from .. import X" are completely
> > clear and more levels up are not likely to occur in practice...
>
> I have Aahz's revision ready to check in, but I'm unclear on one
> point. Is the accepted/pronounced relative import syntax dots only,
> or can there be a branch too? In other words, is the "Y" here
> acceptable (where Y is a sibling to the current module's package)?
>
> from ..Y import X
>
> I think the PEP needs a clear statement (and examples) of which syntax
> **and semantics** have been chosen.
If Y would not be allowed, the new syntax would be cumbersome and only half as
productive. In Zope 3 we often have the following case:
packageX
utilities.py (contains a bunch of helper functions)
browser (package containing browser presentation code)
someview.py (a specific browser view)
We often want to reach utilities from someview. So the ideal import for me
would be:
from .utilities import somefunc
Also, as mentioned by Jim before, we have used this type of syntax for
specifying Python objects in ZCML for a while, and it works well for us.
Regards,
Stephan
--
Stephan Richter
CBU Physics & Chemistry (B.S.) / Tufts Physics (Ph.D. student)
Web2k - Web Software Design, Development and Training
More information about the Python-Dev
mailing list