Import a callable and invoke it with the provided kwargs. :param import_name: A dotted string of the form ``package.module.Callable``. :type import_name: string :param kwargs: kwargs to pass to the callable once it's imported. :type kwargs: dict
(import_name, **kwargs)
| 14 | |
| 15 | |
| 16 | def lazy_call(import_name, **kwargs): |
| 17 | """Import a callable and invoke it with the provided kwargs. |
| 18 | |
| 19 | :param import_name: A dotted string of the form ``package.module.Callable``. |
| 20 | :type import_name: string |
| 21 | :param kwargs: kwargs to pass to the callable once it's imported. |
| 22 | :type kwargs: dict |
| 23 | |
| 24 | """ |
| 25 | module_name, callable_name = import_name.rsplit('.', 1) |
| 26 | __import__(module_name) |
| 27 | module = sys.modules[module_name] |
| 28 | return getattr(module, callable_name)(**kwargs) |
| 29 | |
| 30 | |
| 31 | class LazyClientCreator: |