Skip to content Skip to sidebar Skip to footer

Python: Lazy Import Of Modules

I earlier researched lazy import of modules and found this way of doing it: def some_funk(): lazy_module = __import__('lazy_module') lazy_obj = lazy_module.LazyClass()

Solution 1:

You might want to check the documentation for import out. import lazy_module is internally calling __import__("lazy_module").

The lazy part of the import comes from both of them being done in a function, and not in the top of the class/script.

Post a Comment for "Python: Lazy Import Of Modules"