Pieces of Py #1: Decorator with arguments

Posted on Tue 09 July 2019 in Python • Tagged with Python, Pieces of Py, Decorator • 3 min read

This post is a simple example which explains how to create a decorator function that accepts and uses argument(s). A decorator that would accept an argument could look like this:

@mydecorator(my_argument)
def my_decorated_function(input):
    return input

A simple scenario could be that you would like to print something …


Continue reading