← Back to team overview

lazr-developers team mailing list archive

[Bug 331919] Re: delegates() should provide __eq__ and __ne__ operators.

 

IIUC, this bug is only about making a delegated object compare equally
to another delegated object (when both have the same context)?

I ask that because I've been tempted to make delegated objects compare
equally to their raw counterpart (delegated_bug == bug), and I even
implemented __eq__ and __ne__ for lazr.delegates, but before I submitted
that for review I realized it would also be nice to have them be
identical so that they could be used interchangeably as, let's say, keys
in dictionaries.  Also, some other changes were necessary to fool Storm
into thinking that a delegated_bug was a Bug, so that we could pass in
delegated objects to storm.  I kept encountering problems as I
progressed, and at one point I finally realized it certainly wasn't a
good idea to promote delegated objects to be used interchangeably with
raw ones, so I backed out my changes and went with a completely
different approach.

So, to summarize, I think it's a good idea to implement __eq__ and
__ne__ as in the bug's description, but I'm not sure making
delegated_bug compares equally to bug is a good idea.

-- 
delegates() should provide __eq__  and __ne__ operators.
https://bugs.launchpad.net/bugs/331919
You received this bug notification because you are a member of LAZR
Developers, which is the registrant for lazr.delegates.

Status in lazr.delegates: Triaged

Bug description:
It would be very useful if delegates would add these to a class:

    def __eq__(self, other):
        return (self.context == other.context)

    def __ne__(self, other):
        return not (self == other)





References