How to import nested package using the "as" shorthand?
This question is similar to importing a module in nested packages only the nesting is within the same .py file, not across folders.
In foo.py (All python files are in the same package, and are version 3.4):
class Foo:
class Bar:
...
I can access these subclasses in another .py file:
from . import foo
...
bar = foo.Foo.Bar()
What I would like to do:
from . import foo.Foo.Bar as Bar # DOES NOT WORK: "unresolved reference" error.
...
bar = Bar() # saves typing.
bar2 = Bar()
...
Is there a way to do this?