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

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.

主站蜘蛛池模板: 德江县| 东光县| 商丘市| 德安县| 平山县| 嘉定区| 江永县| 瓮安县| 雷波县| 镇坪县| 修文县| 麻江县| 郁南县| 綦江县| 确山县| 金门县| 温州市| 农安县| 泾阳县| 江津市| 甘谷县| 彩票| 从江县| 井冈山市| 两当县| 南和县| 洪湖市| 寿阳县| 益阳市| 阿克| 乌审旗| 亳州市| 蓬莱市| 济源市| 长乐市| 永吉县| 河东区| 萝北县| 永川市| 玛曲县| 汕尾市|