Table of Contents

Constructor

Decorator

Null object

Observer

Proxy

Singleton

Aka Borg pattern

class Singleton:
    __shared_state = {}
    def __init__(self):
        self.__dict__ = self.__shared_state
 
s1 = Singleton()
s1.x = 1
s2 = Singleton()
s2.x # 1