[Python-ideas] from foo import bar.baz

5 views
Skip to first unread message

Devin Jeanpierre

unread,
May 25, 2012, 6:54:36 PM5/25/12
to Python-Ideas
Has it irritated anyone else that this syntax is invalid? I've wanted
it a couple of times, to be equivalent to:

import foo.bar.baz
from foo import bar
del foo # but only if we didn't import foo already before"

The idea being that one wants access to foo.bar.baz under the name
bar.baz , for readability purposes or what have you.

I played around with adding this, but I seem to have really bad luck
with extending CPython...

-- Devin
_______________________________________________
Python-ideas mailing list
Python...@python.org
http://mail.python.org/mailman/listinfo/python-ideas

Mathias Panzenböck

unread,
May 25, 2012, 7:53:26 PM5/25/12
to python...@python.org
+1 Indeed, I would have expected that "from foo import bar.baz" would work.

anatoly techtonik

unread,
May 29, 2012, 12:00:51 AM5/29/12
to Devin Jeanpierre, Python-Ideas
On Sat, May 26, 2012 at 1:54 AM, Devin Jeanpierre
<jeanpi...@gmail.com> wrote:
> Has it irritated anyone else that this syntax is invalid? I've wanted
> it a couple of times, to be equivalent to:
>
>    import foo.bar.baz
>    from foo import bar
>    del foo # but only if we didn't import foo already before"
>
> The idea being that one wants access to foo.bar.baz under the name
> bar.baz , for readability purposes or what have you.

+1

> I played around with adding this, but I seem to have really bad luck
> with extending CPython...

TryPyPy? =)

Reply all
Reply to author
Forward
0 new messages