467,908 Members | 1,881 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,908 developers. It's quick & easy.

Importing modules from packages with relative imports

With the old import system, and a package that looks like this:


If I wanted to delay importing baz until it was actually used, I could
leave the __init__.py files empty and simply "import bar.baz".
However, with the new relative imports syntax, "from . import bar.baz"
causes a syntax error. I could use something like "from .bar import
baz as bar_baz", but that's long, annoying to write, and requires
changing all the uses of "bar.baz.spam" to "bar_baz.spam" through the
file. Is there any way to achieve the "bar.baz" name with relative
Jun 27 '08 #1
  • viewed: 618

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Christopher J. Bottaro | last post: by
10 posts views Thread by Derek van Vliet | last post: by
3 posts views Thread by Charles Krug | last post: by
2 posts views Thread by peter | last post: by
11 posts views Thread by fortepianissimo | last post: by
9 posts views Thread by rbygscrsepda | last post: by
reply views Thread by Martin P. Hellwig | last post: by
reply views Thread by Robert Kern | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.