Created
June 16, 2017 18:14
-
-
Save m-aciek/e45c912a1b4720f843635dfba3a50ad1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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