[Tutor] wrap methods for logging purposes

Jojo Mwebaze jojo.mwebaze at gmail.com
Thu Oct 7 13:41:58 CEST 2010


I used a the recipe
(http://aspn.activestate.com/ASPN/Coo.../Recipe/198078<http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/198078>)
used to wrap methods for logging purposes. logging classes. But it does seem
to work well with classes inherit form other classes -  i get recursion
errors!

Here is an example of the classes ..

class Base(MetaClass):

class BFrame(BaseFrame):
    def __init__(self, pathname=''):
        Base.__init__(self, pathname = pathname)

When i instatiate BiasFrame()

below is the  OUTPUT

logmethod <BFrame object at 0x9c32d90> __init__ () {}
logmethod <BFrame object at 0x9c32d90> __init__ () {'pathname': ''}
logmethod <BFrame object at 0x9c32d90> __init__ () {'pathname': ''}
logmethod <BFrame object at 0x9c32d90> __init__ () {'pathname': ''}
logmethod <BFrame object at 0x9c32d90> __init__ () {'pathname': ''}
.
.
RuntimeError: maximum recursion depth exceeded in cmp

It starts with the __init__ of BFrame, that's correct. In the __init__ of
BFrame is a call to Base.__init__ with the pathname as argument. That is the
second call to __init__ in the output, but the class is wrong ! Instead of
the __init__ of Base the __init__ of BFrame is called.

is there any way i can correct this?

-- 
+= Johnson
--------------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20101007/9b3216eb/attachment.html>


More information about the Tutor mailing list