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

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.

主站蜘蛛池模板: 沾化县| 湘乡市| 威远县| 鄂托克旗| 唐海县| 九寨沟县| 资中县| 青冈县| 张家口市| 沐川县| 怀柔区| 宜都市| 曲阳县| 资阳市| 长兴县| 德保县| 开远市| 安福县| 施秉县| 洪洞县| 桐庐县| 绵阳市| 玛曲县| 冀州市| 庄河市| 庆元县| 舒城县| 莒南县| 冕宁县| 安阳市| 东兴市| 定西市| 汝南县| 大悟县| 嘉荫县| 香港| 玉林市| 临桂县| 铁岭市| 都江堰市| 汝南县|