Logging messages while entering and leaving a definition in python using a decorator for all definitions -


i not able print print("leaving definition : " + func._name_) in following code snippet

from functools import wraps def notification(func):     @wraps(func)     def with_logging(*args, **kwargs):         print("entering definition : " + func.__name__)         print("arguments passed : {0} {1}".format(args,kwargs))         d = func(*args, **kwargs)         print("leaving definition : " + func._name_) return d         return d     return with_logging  @notification def addition_func(x):    """"""    return x   result = addition_func(4) print(result) 


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -