M
mk
Hello everyone,
I rewrote an example someone posted here recently from:
def new_meth(*args, **kwargs):
print method.func_name
return method(*args, **kwargs)
return new_meth
def f2():
pass
self.name = func.func_name
self.func = func
def __call__(self):
print self.name
return self.func
def f():
pass
f
<function f at 0x017CDA70>
Note that function decorator returned None, while class decorator
returned function.
Why the difference in behavior? After all, print_method_name decorator
also returns a function (well it's a new function but still a function)?
Regards,
mk
I rewrote an example someone posted here recently from:
def new_meth(*args, **kwargs):
print method.func_name
return method(*args, **kwargs)
return new_meth
def f2():
pass
def __init__(self, func):f2
...to:
self.name = func.func_name
self.func = func
def __call__(self):
print self.name
return self.func
def f():
pass
f
<function f at 0x017CDA70>
Note that function decorator returned None, while class decorator
returned function.
Why the difference in behavior? After all, print_method_name decorator
also returns a function (well it's a new function but still a function)?
Regards,
mk