This seems like it should be simple:
I want a list
like any other list
, except it has a different .__str__
method.
- Trying to set
object.__str__ = foo
results in a read-only error - Trying to subclass
list
means you need some way to convert an existinglist
to an instance of the subclass. This requires either copying all attributes manually (a huge pain), or somehow copying them all automatically, which I don't know how to do. - Trying to write a wrapper around the
list
object means I have to figure out some way to send all messages to the wrapped object except.__str__
which I handle with my own method. Don't know how to do this.
Any alternatives, or solutions #2 or #3 greatly appreciated. Thanks!