print("calling { with { and { }formatfunc __name__argskwargs)return_value func(*args**kwargsprint("executed { in { }msformatfunc __name__time time(now)return return_value return wrapper def test ( , , )print("\ttest called"def test ( , )print("\ttest called"def test ( , )print("\ttest called"time sleep( test log_calls(test test log_calls(test test log_calls(test test ( , , test ( , = test ( , this decorator function is very similar to the example we explored earlierin those casesthe decorator took socket-like object and created socket-like object this timeour decorator takes function object and returns new function object this code is comprised of three separate tasksa functionlog_callsthat accepts another function this function defines (internallya new functionnamed wrapperthat does some extra work before calling the original function this new function is returned three sample functions demonstrate the decorator in use the third one includes sleep call to demonstrate the timing test we pass each function into the decoratorwhich returns new function we assign this new function to the original variable nameeffectively replacing the original function with decorated one