When is it beneficial to use inline, single use importing in Python?
For example:
__import__("x").doSomething()
Is the above ever shorter than the below?
import x
x.doSomething()
Or
from x import*
doSomething()
|
This can be useful if you want to use a module just once in an anonymous lambda function, as it allows you to avoid writing a separate statement:
is one byte shorter than
If the code is a named function or program, then |
|||||||||||||||||||||
|