Search code examples
pythonhigher-order-functions

Please what does func() mean in python when used inside a function


Please what does func() mean in python when used inside a function,For example in the code below.

def identity_decorator(func):
    def wrapper():
        func()
    return wrapper

Solution

  • func is an argument given to the function identity_decorator().

    The expression func() means "call the function assigned to the variable func."

    The decorator is taking another function as an argument, and returning a new function (defined as wrapper) which executes the given function func when it is run.

    Here is some information about decorators.