Proxy

Proxy structural software pattern.

This module contains boiler-plate code to supply the Proxy structural software design pattern, to the client code.

class software_patterns.proxy.Proxy(runtime_proxy: T)[source]

The Proxy has an interface identical to the ProxySubject.

Example

>>> from software_patterns import Proxy
>>> class PlusTen(Proxy):
...  def __call__(self, x: int):
...   result = self._proxy_subject(x + 10)
...   return result
>>> def plus_one(x: int):
...  return x + 1
>>> plus_one(2)
3
>>> proxy = PlusTen(plus_one)
>>> proxy(2)
13