[Tutor] Overloading the assignment operator in a class
Kent Johnson
kent37 at tds.net
Thu Sep 21 04:29:04 CEST 2006
Carroll, Barry wrote:
> How do I overload the '=' operator to give the desired behavior?
This classic essay talks about the meaning of assignment in Python:
http://www.effbot.org/zone/python-objects.htm
Also I don't think there is any need to overload __lt__, etc.; just
__cmp__ is enough, it will be used if the others are omitted. Details of
why you might want to use the "rich" comparison operators are here:
http://www.amk.ca/python/2.1/index.html#SECTION000500000000000000000
Kent
More information about the Tutor
mailing list