[Level 3] More decorator samples.
There is a good website to demo decorator sample codes. here ''' Usage: @deprecated def func(): ... ''' class deprecated: def __init__(self, func): self.func = func self.__name__ = self.func.__name__ self.__doc__ = self.func.__doc__ self.__dict__.update(self.func.__dict__) pass """This is a decorator which can be used to mark functions as deprecated. It will result in a warning being emitted when the function is used.""" def __call__(self, *args, **kwargs): msg = "Call to deprecated function %s()." % self.func.__name__ ## Suppressing Warnings warnings.simplefilter("ignore") warnings.warn(msg, category=DeprecationWarning) ## Delete ignore filter del warnings.filters[0] (tmpDebug2Console, libcommon.bDebug2Console) = (libcommon.bDebug2Console, False) libcommon.debug(msg, logfile='de...