Relative imports and "import X as Y"

O

OKB (not okblacke)

I was looking at PEP 328. It says that relative imports with the
dot syntax will only be allowed with the "from" import variety (e.g.,
"from ..somemodule import somename"). The reason given for this in the
PEP is that after import xxx.yyy, "xxx.yyy" is usable in an expression,
but the leading period syntax is inconsistent with this (you can't use
".somepackage.somemodule" in an expression).

However, this reasoning doesn't apply to "import X as Y", as long
as Y is an ordinary name. As a few recent posts here have touched on,
there are actual differences between the "import X (as Y)" and "from X
import name" varieties, most notably that the second form binds name in
the importing namespace whereas the first does not.

So, will relative imports in Python 3.0 allow things like "import
...relative.importing.path as prettyname"? If not, why not?

--
--OKB (not okblacke)
Brendan Barnwell
"Do not follow where the path may lead. Go, instead, where there is
no path, and leave a trail."
--author unknown
 
T

Terry Reedy

So, will relative imports in Python 3.0 allow things like "import
..relative.importing.path as prettyname"? If not, why not?

Download the latest beta for your system and give it a try.
 
O

OKB (not okblacke)

Terry said:
Download the latest beta for your system and give it a try.

Thanks for the advice, but I'd really rather not deal with
installing the entire thing alongside my existing version, possibly
causing conflicts in who knows what ways.

--
--OKB (not okblacke)
Brendan Barnwell
"Do not follow where the path may lead. Go, instead, where there is
no path, and leave a trail."
--author unknown
 
O

OKB (not okblacke)

Gabriel said:
En Sun, 31 Aug 2008 07:27:12 -0300, Wojtek Walczak


Or use a virtual machine, or a live CD.

Gosh, thanks, everyone, for being so helpful!

--
--OKB (not okblacke)
Brendan Barnwell
"Do not follow where the path may lead. Go, instead, where there is
no path, and leave a trail."
--author unknown
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,996
Messages
2,570,238
Members
46,826
Latest member
robinsontor

Latest Threads

Top