Decorators/wrappers
Decorators/wrappers What is it? 1 Related concepts 2 First class function (FCC) 3 References 4 Closure 4 When do we have a closure? 5 References 5 Videos 5 Blogs 5 What is it? In object-oriented programming , the decorator pattern (also known as Wrapper, an alternative naming shared with the Adapter pattern ) is a design pattern that allows behavior to be added to an individual object , either statically or dynamically, without affecting the behavior of other objects from the same class . For example and motivation see: https://en.wikipedia.org/wiki/Decorator_pattern#Motivation Example for my case: # Decorators from functools import wraps def my_logger(orig_func): import logging logging.basicConfig(filename='{}.log'.format(orig_func.__name__), level=logging.INFO) @wraps(orig_func) def wrapper(*args, **kwargs): logging.in...