I have a list as an attribute of a class. I need to be able to intercept any add/remove of objects to the list, so that I can perform cleanup on other attributes of the class.
Currently, I'm making the list "private" with the horrid __, and then having a slew of accessor functions to iterate, add/remove, etc. without giving true access to the list. As such the class seems kludgey.
Is there a more pythonic way of doing this? Possibly by sub-classing list? How will this effect the performance of list operations?
Every time I google this all I get is results about python mailing lists.
Thanks,
/jon
Currently, I'm making the list "private" with the horrid __, and then having a slew of accessor functions to iterate, add/remove, etc. without giving true access to the list. As such the class seems kludgey.
Is there a more pythonic way of doing this? Possibly by sub-classing list? How will this effect the performance of list operations?
Every time I google this all I get is results about python mailing lists.
Thanks,
/jon
Comment