Skip to content

Instantly share code, notes, and snippets.

@matobaa
Last active July 17, 2023 15:13
Show Gist options
  • Save matobaa/5074499 to your computer and use it in GitHub Desktop.
Save matobaa/5074499 to your computer and use it in GitHub Desktop.
decolator
try:
from functools import wraps
except:
wraps = lambda w: lambda f: f
def wrap(func):
@wraps(func)
def wrapper(*args, **kw):
return "[%s]" % func(*args, **kw)
if getattr(func, 'im_self', None):
setattr(func.im_self or {}, func.__name__, wrapper)
return wrapper
class Clazz:
@wrap
def echo(self, param):
return param
e = Clazz()
print e.echo('Hello')
print e.echo.func_name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment