Contains/equals

Hrvoje Niksic hniksic at xemacs.org
Tue Aug 24 15:16:12 CEST 2010


Lawrence D'Oliveiro <ldo at geek-central.gen.new_zealand> writes:

> In message <mailman.2311.1282230005.1673.python-list at python.org>, Alex Hall 
> wrote:
>
>>  def __eq__(self, obj):
>>   if self.a==obj.a and self.b==obj.b: return True
>>   return False
>
> Is there a “Useless Use Of ...” award category for these “if <boolean> then 
> return True; else return False” constructs?

Well, remember that self.a == obj.a can return something other than
bool, and the and operator will evaluate to either False or the last
value.  Maybe he doesn't want to propagate the non-bools out of his
__eq__. :)

what's-next-"useless-use-of-"useless-use-of...""-ly y'rs



More information about the Python-list mailing list