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

Summary

In this chapter, we introduced the concept of Python modules and saw how Python modules are simply Python source files, which are imported and used by another source file. We then took a look at Python packages and saw that these are collections of modules identified by a package initialization file named __init__.py.

We explored how modules and packages can be used to organize your program's source code and why the use of these modular techniques is so important for the development of large systems. We also explored what spaghetti code looks like and discovered some of the other pitfalls that can occur if you don't modularize your programs.

Next, we looked at programming as a process of constant change and evolution and how modular programming can help deal with a changing codebase in the best possible way. We then learned that the Python Standard Library is an excellent example of a large collection of modules and packages, and finished by creating our own simple Python module that demonstrates effective modular programming techniques. In implementing this module, we learned how a module can use leading underscores in variable and function names to mark them as private to the module, while making the remaining functions and other definitions available for other parts of the system to use.

In the next chapter, we will apply modular techniques to the development of a more sophisticated program consisting of several modules working together to solve a more complex programming problem.

主站蜘蛛池模板: 松溪县| 田林县| 武义县| 特克斯县| 准格尔旗| 西昌市| 清原| 杭州市| 田东县| 临江市| 新营市| 天水市| 股票| 延川县| 荆门市| 民丰县| 磴口县| 会宁县| 饶平县| 随州市| 钦州市| 玉龙| 准格尔旗| 沛县| 虞城县| 长沙市| 娄底市| 海口市| 榆树市| 定州市| 株洲县| 枣庄市| 辽阳市| 遂宁市| 延津县| 同德县| 沂源县| 张家口市| 吉木萨尔县| 阿克苏市| 荆州市|