Kirby Urner wrote: >>Kirby >> >>PS: since you've been studying subclassing primitive types using __new__, >>maybe you could show us a user-defined floating point type that reports >>two numbers equal if their absolute value difference is less than e. >>Anyone? >> > Fuzzy redone a breath: class Fuzzy(float): tol = 1e-8 def __new__(cls, arg=0.0): return float.__new__(cls, arg) def __eq__(self, other): return abs(self - other) < self.tol > ...
Here's the problem: Your notion of equality is not transitive. That's tough -- it invalidates the assumptions of the float type (and all basic types). Also, you didn't tweak hash, so a dictionary with these things in them would not find entries that turn out to be equal. --Scott David Daniels [EMAIL PROTECTED] _______________________________________________ Edu-sig mailing list Edu-sig@python.org http://mail.python.org/mailman/listinfo/edu-sig