批评我的 Python 包结构
我正在完成我一直在编写的 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
I'm in the process of finishing up a Python package I've been writing. However, before I release it I'd like to get some feedback on the overall structure of the package as well as the __init__.py
file.
This should give an idea of what my __init__.py
file looks like.
'''
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__()
This should give a decent idea of the overall package structure.
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该使用绝对导入而不是相对导入,例如
import mypackage.mypath as mypath
。You should use absolute imports instead of relative imports, e.g.
import mypackage.mypath as mypath
.