Overriding UserList methods

Chris Gonnerman chris.gonnerman at usa.net
Mon Mar 5 06:35:31 CET 2001


----- Original Message -----
From: "Daniel Klein" <danielk at aracnet.com>
Subject: Overriding UserList methods


> I must be missing something, cos I can't figure out how to override a
method
> using the UserList module. Here is some code:
>
> import UserList
> class MyList(UserList.UserList):
>       __def __init__(self):
>         UserList.UserList.__init__(self)
>
>     def append(self, object):
>         self.append(object)
>
> Understandably, this goes into a recursive frenzy until it hits the stack
> limit. :-(

Like this:

import UserList
class MyList(UserList.UserList):
    def __init__(self):
        UserList.UserList.__init__(self)

    def append(self, object):
        UserList.UserList.append(self, object)

I think, anyway.  Good luck :-)






More information about the Python-list mailing list