提交 2b9fbc3e 编写于 作者: HansBug's avatar HansBug 😆

add dm.py into global libs

上级 7c4baed8
import importlib.util
import os
from types import ModuleType
def get_module(filename) -> ModuleType:
_, _simple_filename = os.path.split(filename)
_module_name, _ = _simple_filename.split('.', maxsplit=1)
spec = importlib.util.spec_from_file_location(_module_name, filename)
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
return module
import importlib.util
import os
from functools import lru_cache
_FILE_NAME = 'create_a_complex_tree.demo.py'
_, _SIMPLE_FILE_NAME = os.path.split(_FILE_NAME)
_MODULE_NAME, _ = _SIMPLE_FILE_NAME.split('.', maxsplit=1)
from dm import get_module
@lru_cache()
def _get_module():
spec = importlib.util.spec_from_file_location(_MODULE_NAME, _FILE_NAME)
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
return module
_module = _get_module()
_module = get_module(os.path.abspath('create_a_complex_tree.demo.py'))
t1, t2, t3 = _module.t1, _module.t2, _module.t3
import importlib.util
import os
from functools import lru_cache
_FILE_NAME = 'create_a_tree.demo.py'
_, _SIMPLE_FILE_NAME = os.path.split(_FILE_NAME)
_MODULE_NAME, _ = _SIMPLE_FILE_NAME.split('.', maxsplit=1)
from dm import get_module
@lru_cache()
def _get_module():
spec = importlib.util.spec_from_file_location(_MODULE_NAME, _FILE_NAME)
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
return module
_module = _get_module()
_module = get_module(os.path.abspath('create_a_tree.demo.py'))
t = _module.t
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册