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

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.

主站蜘蛛池模板: 临猗县| 勃利县| 潢川县| 河东区| 永和县| 盱眙县| 延寿县| 龙海市| 潞城市| 嫩江县| 陈巴尔虎旗| 简阳市| 仙桃市| 平和县| 香格里拉县| 施秉县| 特克斯县| 秦安县| 德州市| 社会| 威远县| 南汇区| 怀远县| 广宗县| 灵川县| 察雅县| 富裕县| 全南县| 云浮市| 襄城县| 达孜县| 布尔津县| 丹东市| 诸暨市| 荆门市| 子洲县| 太仆寺旗| 宁安市| 沅江市| 三亚市| 蓝山县|