我正在完成我一直在编写的 Python 包。但是,在发布之前,我想获得一些有关该包的整体结构以及 __init__.py
的反馈。文件。
这应该可以让我了解我的 __init__.py
文件看起来像。
'''
A docsting describing the package.
'''
__author__ = myname
__copyright__ = mycopyright
__credits__ = listofcredits
__license__ = mylicense
__version__ = 0.0
__maintainer__ = me
__email__ = myemail
__status__ = indevelopment
# This contains a module with directories as strings (for file reference)
import mypath
# some modules
import this
import that
# some gui widget classes
from windowmodule import windowwidget
from widgetmodule import someguiwidget
from someothermodule import someotherguiwidget, andanotherguiwidget
def __demo__ () :
# a demo of the package
if __name__ == '__main__' :
__demo__()
这应该可以让您对整体包结构有一个不错的了解。
mypackage/
mypath.py
__init__.py
license.txt
readme.txt
modules/
this.py
that.py
windows/
windowmodule.py
widgets/
widgetmodule.py
images/
imagefiles.whatever
tools/
tools.py
最佳答案
您应该使用绝对导入而不是相对导入,例如将 mypackage.mypath 导入为 mypath
。
关于python - 批评我的 Python 包结构,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7577651/