Patterns in Python – structural

Structural patterns concern themselves with the intricacies of combining classes or objects to form larger structures that are more than the sum of their parts.

Structural patterns implement this in these two distinct ways:

  • By using class Inheritance to compose classes into one. This is the static approach.
  • By using object composition at runtime to achieve combined functionality. This approach is more dynamic and flexible.

Python, by virtue of supporting multiple inheritance, can implement both of these very well. Being a language with dynamic attributes and using the power of magic methods, Python can also do object composition and the resultant method wrapping pretty well also. So, with Python, a programmer is indeed ...

Get Software Architecture with Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.