Overriding UserList methods
Daniel Klein
danielk at aracnet.com
Sun Mar 4 23:54:02 EST 2001
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. :-(
The only way I could get this to work was to give the method another name, ie
def add(self,object): ## This works but I would rather use 'append'
self.append(object) ## as the method name.
So how can I override the append() method so that I can add my specialized code
to it?
Daniel Klein
More information about the Python-list
mailing list