Python: Lambda Function

Start with the keyword “lambda”. Then put the list of parameters, which are separated by commas. Put colon(:) after that. Finally, write the return value or expression. Only one expression can be here, which is returned.

Design Pattern: Decorator Pattern in Python

Decorator pattern is used to add some additional responsibilities to an object dynamically. We can add some new tasks, checking, etc. before and/or after the original functionality of the the object. Using the Decorator pattern we can extend the behavior, with property transparency, and without affecting other objects. In this article, we discuss the implementation of the Decorator Pattern in Python.

Python: Decorator

A decorator is a function that accepts a function and returns a function. We can perform the additional steps of operation(that we want to add before/after the original function), in the implementation of the decorator.