L
Lawrence Oluyede
I've never used metaclasses in real life before and while searching through
the online Cookbook I found this gorgeous example:
"Wrapping method calls (meta-class example)"
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/198078
What I want to do in my app is to log all method calls and seems that the
metaclass example above do this fine but it fails when it's needed to
instantiate the class I'm in in a method. So if I do:
class Test(object):
__metaclass__ = LogTheMethods
def foo(self):
return Test()
this generate a Runtime Error cause recursion never stops
Any hint to enhance the example?
the online Cookbook I found this gorgeous example:
"Wrapping method calls (meta-class example)"
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/198078
What I want to do in my app is to log all method calls and seems that the
metaclass example above do this fine but it fails when it's needed to
instantiate the class I'm in in a method. So if I do:
class Test(object):
__metaclass__ = LogTheMethods
def foo(self):
return Test()
this generate a Runtime Error cause recursion never stops
Any hint to enhance the example?