unorderable error: less ok, equal ok, less-or-equal gives unorderable error!

Peter Otten __peter__ at web.de
Tue Jul 1 08:43:48 EDT 2014


Ethan Furman wrote:

> On 06/30/2014 12:34 PM, Peter Otten wrote:
>> RainyDay wrote:
>>>
>>>      def __eq__(self, other):
>>>          return self._loc == getattr(other, "_loc", None)
>>
>> Note that None is not a good default when _loc is expected to be a tuple:
> 
> In this case None is not being returned, but will be comparid with
> self._loc, so RainyDay is good there.

RainyDay wrote:

> I'm only using None in equality comparison, it's never a default value of
> _loc itself, so this should be ok because it'll compare to all other
> object types and correctly say they're unequal.

Yes, sorry. I read what I expected rather than what was there.




More information about the Python-list mailing list