官术网_书友最值得收藏!

How to create and reference module packages

We have talked about modules and packages, using the terms interchangeably. However, there is a difference between a module and a package: packages are actually collections of modules and they include a __init__.py file, which can just be an empty file.

The dot-nomenclature used in modules to access specific functions or variables is also used in packages. This time, dotted names allow multiple modules within a package to be accessed without having name conflicts; each package creates its own namespace, and all the modules have their own namespaces.

When packages contain sub-packages (as in the following example), importing modules can be done with either absolute or relative paths. For example, to import the sepia.py module, one could import it with an absolute path: from video.effects.specialFX import sepia.

主站蜘蛛池模板: 宣化县| 乌拉特中旗| 清流县| 阿克| 伊春市| 宁蒗| 华亭县| 武功县| 金川县| 庄河市| 哈巴河县| 丰都县| 邳州市| 梅河口市| 涿州市| 增城市| 应用必备| 新乡县| 达州市| 温州市| 祁连县| 盐山县| 江阴市| 淮阳县| 曲麻莱县| 霞浦县| 高密市| 济源市| 长沙市| 荥经县| 五常市| 来安县| 襄樊市| 颍上县| 锡林浩特市| 玉环县| 漳州市| 舒城县| 乌什县| 仁寿县| 武义县|