Skip to content

Instantly share code, notes, and snippets.

@m-aciek
Created June 16, 2017 18:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save m-aciek/e45c912a1b4720f843635dfba3a50ad1 to your computer and use it in GitHub Desktop.
Save m-aciek/e45c912a1b4720f843635dfba3a50ad1 to your computer and use it in GitHub Desktop.
from functools import update_wrapper
class Operation:
@classmethod
def register(cls, code):
"""Registration"""
def inner(func):
result = cls(func, code)
update_wrapper(result, func)
return result
return inner
def __init__(self, func, code):
# …
print('initializing ' + func.__name__ + ' ' + code)
@Operation.register('foo')
def func(arg):
"""Documentation of decorated function"""
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment