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

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.

主站蜘蛛池模板: 河西区| 应城市| 舒兰市| 连云港市| 凤翔县| 潜山县| 贡觉县| 漳浦县| 桃园县| 鞍山市| 金门县| 拜城县| 台江县| 新晃| 开原市| 平果县| 三门县| 墨脱县| 清徐县| 化德县| 卫辉市| 高州市| 田东县| 十堰市| 钟祥市| 福州市| 文登市| 清河县| 开封市| 台州市| 花莲县| 安阳市| 繁峙县| 白玉县| 大余县| 长丰县| 维西| 吴川市| 集安市| 蓬溪县| 桦甸市|