Re: Elegant compare

2013-08-11 Thread Jason Friedman
> This is a hard question to answer, because your code snippet isn't > clearly extensible to the case where you have ten attributes. What's the > rule for combining them? If instance A has five attributes less than > those of instance B, and five attributes greater than those of instance > B, which

Re: Elegant compare

2013-08-11 Thread Steven D'Aprano
On Sat, 10 Aug 2013 21:41:00 -0600, Jason Friedman wrote: > class my_class: > def __init__(self, attr1, attr2): > self.attr1 = attr1 #string > self.attr2 = attr2 #string > def __lt__(self, other): > if self.attr1 < other.attr1: > return True > el

Re: Elegant compare

2013-08-10 Thread Chris Angelico
On Sun, Aug 11, 2013 at 4:41 AM, Jason Friedman wrote: > class my_class: > def __init__(self, attr1, attr2): > self.attr1 = attr1 #string > self.attr2 = attr2 #string > def __lt__(self, other): > if self.attr1 < other.attr1: > return True > else: