简体   繁体   中英

Object Oriented design example using inheritance in Python Standard Library, e.g. pathlib?

pathlib is a typical Object Oriented design in Python Standard Library using inheritance. collections.abc is another one.

路径库

I would like know other example (better involve abstract base class and concrete sub-class) in Standard Library .

I recommend two other well-written, well-designed, and easy-to-understand standard library modules that one could study its OOP design (with inheritance, of course).

First one is logging . The OOP diagram is shown below:

在此处输入图像描述

logging is one of most widely used, pure python, and to be honest, rather simple, standard library modules so it'd be worthwhile to study its design since the module's source code is not that long, and well documented.

Second one is argparse .

在此处输入图像描述

Another widely used library module, implemented almost all in pure python, and quite easy to understand. However if you are looking to study its design I still recommend the former one as it is a much shorter module for you to read through.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM