Quoting Mathieu Bridon (2018-07-06 02:25:53) > On Thu, 2018-07-05 at 09:10 -0700, Dylan Baker wrote: > > Quoting Mathieu Bridon (2018-07-05 06:17:43) > > > + def __ne__(self, other): > > > + return not self.__eq__(other) > > > > This can be written as "not (self == other)", right? > > It can, yes. > > The `==` operator is going to end up calling the `__eq__` method > defined just above anyway, and we're already in the implementation > details of `__ne__`. > > So it felt more natural to me to have `__ne__` be the opposite of > `__eq__` rather than the opposite of `==`. > > Also, `not (\u2026 == \u2026)` feels weird, it screams "replace me by `\u2026 > != \u2026`". > Which I'm worried someone not paying attention might do in the future. > > I don't feel very strongly about it though, so I'll change it if you > do. > > > -- > Mathieu
I go back and forth on it. Calling dunder methods directly feels a little odd to me, they're more of a protocol than actual methods. For a lot of dunder methods I'd be very strongly against calling them directly (__iter__ and __next__ for example), I guess for the comparison methods I can go either way. Oh, I just noticed the commit message should say "inequality" instead of "unequality". Dylan
signature.asc
Description: signature
_______________________________________________ mesa-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/mesa-dev
