Inheriting methods’ docstrings in Python

This is a variation on Paul McGuire’s DocStringInheritor metaclass. It inherits a parent member’s docstring if the child member’s docstring is empty. It inherits a parent class docstring if the child class docstring is empty. It can inherit the docstring from any class in any of the base classes’s MROs, just like regular attribute inheritance. …

Read more

What is the difference between the template method and the strategy patterns?

The template pattern is used when a particular operation has some invariant behavior(s) that can be defined in terms of other varying primitive behaviors. The abstract class defines the invariant behavior(s), while the implementing classes defined the dependent methods. In a strategy, the behavior implementations are independent — each implementing class defines the behavior and …

Read more