Skip to content

Instantly share code, notes, and snippets.

Last active Jun 30, 2019
What would you like to do?
Snippet for "Why Refactoring? How to Refactor/Restructure Python Package?"
def refactored_class(message):
def cls_wrapper(cls):
class Wrapped(cls, object):
def __init__(self, *args, **kwargs):
warnings.warn(message, FutureWarning)
super(Wrapped, self).__init__(*args, **kwargs)
return Wrapped
return cls_wrapper
def refactored(message):
def decorator(func):
def emit_warning(*args, **kwargs):
warnings.warn(message, FutureWarning)
return func(*args, **kwargs)
return emit_warning
return decorator
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment