- Modular Programming with Python
- Erik Westra
- 247字
- 2021-07-16 10:47:17
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.
- Vue 3移動Web開發(fā)與性能調(diào)優(yōu)實(shí)戰(zhàn)
- scikit-learn Cookbook
- Vue.js 3.0源碼解析(微課視頻版)
- Podman實(shí)戰(zhàn)
- Quarkus實(shí)踐指南:構(gòu)建新一代的Kubernetes原生Java微服務(wù)
- The Complete Coding Interview Guide in Java
- 微服務(wù)架構(gòu)深度解析:原理、實(shí)踐與進(jìn)階
- Linux C編程:一站式學(xué)習(xí)
- HTML5從入門到精通(第4版)
- 基于ARM Cortex-M4F內(nèi)核的MSP432 MCU開發(fā)實(shí)踐
- Hacking Android
- Hack與HHVM權(quán)威指南
- Node.js實(shí)戰(zhàn):分布式系統(tǒng)中的后端服務(wù)開發(fā)
- Java Web開發(fā)教程:基于Struts2+Hibernate+Spring
- XML程序設(shè)計(第二版)