Can you define aliases for imported modules in Python?

Jordan Parmer picture Jordan Parmer · Apr 1, 2009 · Viewed 83.9k times · Source

In Python, is it possible to define an alias for an imported module?

For instance:

import a_ridiculously_long_module_name

...so that is has an alias of 'short_name'.

Answer

vartec picture vartec · Apr 1, 2009
import a_ridiculously_long_module_name as short_name

also works for

import module.submodule.subsubmodule as short_name