首页| JavaScript| HTML/CSS| Matlab| PHP| Python| Java| C/C++/VC++| C#| ASP| 其他|
购买积分 购买会员 激活码充值

您现在的位置是:虫虫源码 > Python > 一个目录名称相对Python导入使用根导入命名空间

一个目录名称相对Python导入使用根导入命名空间

资 源 简 介

Introduction When you have a large package that contains nested submodules this allows the nested submodules to refer to one another without having to pull in or know much about or explicitly import entire top-level tree. In contrast to Python"s relative imports, we don"t care if a file is invoked as a main program or as part of a module in the collection. Synopsis ``` from importrelative import importrelative, get_srcdir # Below "trepan" is my top-level namespace # "io" is the directory this file is in. Mbase = import_relative("base", ".", "trepan") # Adds trepan.io.base # The following adds trepan.lib.bytecode Mbytecode = import_relative("bytecode", "..lib", "trepan") class MyClass(Mbase.InputBase): # Use name from Mbase ... NOTE; if your module name is "io" import like this: Mio = import_relative("trepan.io", "..") # rather than Mio = import_relative("io", "..trepan") like os.pat

文 件 列 表

import_relative-0.2.3
MANIFEST.in
README.txt
NEWS
COPYING
setup.cfg
setup.py
test
import_relative.egg-info
VERSION.py
Makefile
import_relative.py
PKG-INFO
__pkginfo__.py
make-check-filter.py

相 关 资 源

您 可 能 感 兴 趣 的

同 类 别 推 荐

VIP VIP
0.206857s