[Python-Dev] Re: PEP 328 -- relative and multi-line import (original) (raw)
Shane Holloway (IEEE) shane.holloway at ieee.org
Mon Apr 5 03:07:10 EDT 2004
- Previous message: [Python-Dev] Re: PEP 328 -- relative and multi-line import
- Next message: [Python-Dev] Re: PEP 328 -- relative and multi-line import
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Good point. Here's what I think the semantics are; as soon as I get agreement, I'll update the PEP. Given a package layout::
package subpackage1 moduleX moduleY subpackage2 moduleZ moduleA
Each leading "." refers to one level of parent. Assuming that the current file is
moduleX.py
, following are correct usages of the new syntax::from .moduleY import spam from ..subpackage1 import moduleY from ..subpackage2.moduleZ import eggs from ..moduleA import foo from ...package import bar
What about names inside package init?
from .. import bar
Is this also valid?
- Previous message: [Python-Dev] Re: PEP 328 -- relative and multi-line import
- Next message: [Python-Dev] Re: PEP 328 -- relative and multi-line import
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]