Issue with new-style classes and operators

Jan Decaluwe jan at jandecaluwe.com
Mon Nov 25 17:38:41 EST 2002


Alex Martelli wrote:
> 

> So, to wrap an arbitrary object X in such a way that X's special
> methods will be used by any operator, you need to ensure you do
> the wrapping with a _class_ that exposes said special methods.
> That's generally easiest to do with a factory function with a
> nested class that uses inheritance, but you have many other choices
> depending on what exactly you're trying to accomplish.

Mm, I think I see, thanks for that. (I'll try again to understand this 
from the documentation.) However, if I use inheritance from an immutable 
type, the subtype is automatically immutable also, right? So I wanted
mutability, I'm back to delegation ... and apparently stuck with
new-style classes ???

Jan

--
Jan Decaluwe
mailto:jan at jandecaluwe.com



More information about the Python-list mailing list