1

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

pathlib

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

9
  • Any class in there. You can browse the docs on your own. Commented Jan 1, 2021 at 3:31
  • I did but I can't find other except for the 2 examples I listed. Commented Jan 1, 2021 at 3:35
  • In Python 3, everything is a class. See, for example, str, list, tuple, etc. Commented Jan 1, 2021 at 3:39
  • 1
    OK I will make my question be specific. I know what OO is but I want to know the example of inheritance. Commented Jan 1, 2021 at 3:50
  • 1
    @Qiulang are you interested on best OOP practices in python, or somewthing else? Commented Jan 1, 2021 at 3:59

1 Answer 1

3

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:

enter image description here

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.

enter image description here

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.