[BangPypers] Favorite tips/techniques

Dhananjay Nene dhananjay.nene at gmail.com
Fri Sep 13 09:27:09 CEST 2013


On Fri, Sep 13, 2013 at 12:49 PM, Saju M <sajuptpm at gmail.com> wrote:
> Import sub-modules with alias.
> Is it a bug ?
>
>>>>
>>>> import json
>>>> from json import tool
>>>>
>
> --------
>
>>>>
>>>> import json as sjson
>>>> from sjson import tool
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> ImportError: No module named sjson
>>>>

import and from serve to import packages using their canonical package
names into the appropriate module name spaces.

The alias is applied as a part of the importing process and the target
of this is the module name space.

Since from looks at the canonical names (in the virtualenv etc.) from
sjson means it should look up a package on the disk called sjson (not
locate sjson out of module namespace)

Dhananjay


More information about the BangPypers mailing list