dictionary_switches / code / PythonDecorators /

# PythonDecorators/
class decorator_without_arguments(object):

    def __init__(self, f):
        If there are no decorator arguments, the function
        to be decorated is passed to the constructor.
        print("Inside __init__()")
        self.f = f

    def __call__(self, *args):
        The __call__ method is not called until the
        decorated function is called.
        print("Inside __call__()")
        print("After self.f(*args)")

def sayHello(a1, a2, a3, a4):
    print('sayHello arguments:', a1, a2, a3, a4)

print("After decoration")

print("Preparing to call sayHello()")
sayHello("say", "hello", "argument", "list")
print("After first sayHello() call")
sayHello("a", "different", "set of", "arguments")
print("After second sayHello() call")