Skip to content

Instantly share code, notes, and snippets.

@melvinkcx
Last active Jun 30, 2019
Embed
What would you like to do?
Snippet for "Why Refactoring? How to Refactor/Restructure Python Package?" https://hackernoon.com/why-refactoring-how-to-restructure-python-package-51b89aa91987
"""
decorators.py
"""
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