Xif wrote: > Hi > > I want to have control over all items added to a list. > > The first attempt was to subclass list and override its .append() > method. > > Problem is, there are plenty of other ways the list can have items > added to it - e.g. extend, insert - and theyr'e not at all affected by > the changes I made to append. > > Is there some "base" item-adding method that all other item-adding > methods use, so I can override it and have the changes affect all > item-adding functions? >
If you subclass list then you will need to override all methods that can set items. This is because the built in methods work directly with the internal structure and are implemented in C. It's a bit of a pain... but not that much. Regards, Fuzzy http://www.voidspace.org.uk/python/index.shtml > Thanks, > Xif -- http://mail.python.org/mailman/listinfo/python-list