Python Decorators
Definition A decorator takes in a function, adds some functionality and returns it. This is similar to packing a gift. The decorator acts as a wrapper. The nature of the object that got decorated (actual gift inside) does not alter. We can use the @ symbol along with the name of the decorator function and place it above the definition of the function to be decorated. def make_pretty(func): def inner(): print("I got decorated") func() return inner def ordinary(): print("I am odinary") >>> ordinary() I am ordinary >>> # let's decorate this ordinary function >>> pretty = make_pretty(ordinary) >>> pretty() I got decorated I am ordinary In the example shown above, make_pretty() is a decorator. @make_pretty def ordinary(): print("I am ordinary") is equivalent to def ord...