def monkeypatch_method(cls):
 def decorator(func):
  setattr(cls, func.__name__, func)
  return func
 return decorator

def monkeypatch_method ( cls ) : def decorator ( func ) : setattr ( cls , func . __name__ , func ) return func return decorator
a decorator to add a single method to an existing class:: @monkeypatch_method def <newmethod>: pass .