It is possible to name a python module using the __import__function

Asked

Viewed 72 times

2

I have the following code

__import__('some_module')

And I wanted to know if it was possible to do something like this:

__import__('some_module') as some_name

1 answer

3


As you have in question is not, but you can assign the return of __import__ to a var, ex:

mod_alias = __import__('string')

The equivalent of:

import string as mod_alias

In this case mod_alias is your alias.

DEMONSTRATION

Browser other questions tagged

You are not signed in. Login or sign up in order to post.