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

Introduction

Python modules are the highest-level components of Python programs. As suggested by their name, modules are modular, capable of being plugged in with other modules as part of an overall program to provide better separation of code while combining together to create a cohesive application.

Modules allow easy reuse of code, and provide separate namespaces to prevent variable shadowing between blocks of code. Variable shadowing involves having duplicate variables in different namespaces, possibly causing the interpreter to use an incorrect variable. Each Python file a developer creates is considered a separate module, allowing different files to be imported into a single, overall file that forms the final application.

Realistically, any Python file can be made a module by simply removing the .py extension; this is most commonly seen when importing libraries. Python packages are collections of modules; what makes a package special is the inclusion of an __init__.py file. We will cover the differences in detail later, so for now just recognize that there are several names for the same items.

主站蜘蛛池模板: 镶黄旗| 大石桥市| 五家渠市| 景宁| 汤阴县| 永昌县| 阳东县| 临泉县| 新泰市| 外汇| 周口市| 麟游县| 赣州市| 洱源县| 绥芬河市| 资阳市| 阳信县| 莱阳市| 墨竹工卡县| 大关县| 昌黎县| 涞源县| 鹰潭市| 克山县| 彭泽县| 黑山县| 遂川县| 巴马| 东莞市| 福鼎市| 商水县| 九寨沟县| 若羌县| 民勤县| 临湘市| 阳西县| 兴隆县| 襄城县| 准格尔旗| 崇州市| 海宁市|