- Modular Programming with Python
- Erik Westra
- 411字
- 2021-07-16 10:47:17
The Python Standard Library
One of the buzzwords used to describe Python is that it is a batteries included language, that is, it comes with a rich collection of built-in modules and packages called the Python Standard Library. If you've written any non-trivial Python program, you've almost certainly used modules from the Python Standard Library to do so. To get an idea of how vast the Python Standard Library is, here are a few example modules from this library:

These are just a few of the over 300 modules available in the Python Standard Library. As you can see, there is a vast range of functionality provided, and all of this is built in to every Python distribution.
Because of the huge range of functionality provided, the Python Standard Library is an excellent example of modular programming. For example, the math
standard library module provides a range of mathematical functions that make it easier to work with integer and floating-point numbers. If you look through the documentation for this module (http://docs.python.org/3/library/math.html), you will find a large collection of functions and constants, all defined within the math
module, that perform almost any mathematical operation you could imagine. In this example, the various functions and constants are all defined within a single module, making it easy to refer to them when you need to.
In contrast, the xmlrpc
package allows you to make and respond to remote procedure calls that use the XML protocol to send and receive data. The xmlrpc
package is made up of two modules: xmlrpc.server
and xmlrpc.client
, where the server
module allows you to create an XML-RPC server, and the client
module includes code to access and use an XML-RPC server. This is an example of where a hierarchy of modules is used to logically group related functionality together (in this case, within the xmlrpc
package), while using sub-modules to separate out the particular parts of the package.
If you haven't already done so, it is worth spending some time to review the documentation for the Python Standard Library. This can be found at https://docs.python.org/3/library/. It is worth studying this documentation to see how Python has organized such a vast collection of features into modules and packages.
The Python Standard Library is not perfect, but it has been improved over time, and the library as it is today makes a great example of modular programming techniques applied to a comprehensive library, covering a wide range of features and functions.
- Learning Neo4j
- 垃圾回收的算法與實現
- 前端跨界開發指南:JavaScript工具庫原理解析與實戰
- Python進階編程:編寫更高效、優雅的Python代碼
- Kali Linux Wireless Penetration Testing Beginner's Guide(Third Edition)
- 深入分布式緩存:從原理到實踐
- R數據科學實戰:工具詳解與案例分析
- 計算機應用基礎教程(Windows 7+Office 2010)
- Python+Office:輕松實現Python辦公自動化
- 零基礎學SQL(升級版)
- Learn Linux Quickly
- Python Penetration Testing Essentials
- C語言程序設計實驗指導
- Spring MVC Blueprints
- VMware vRealize Orchestrator Essentials