[Alex]
>>> def __eq__(self, other):
>>>     n_self = self.replace(tzinfo=None)
>>>     n_other = other.replace(tzinfo=None)
>>>     if self.tzinfo is other.tzinfo:
>>>         return n_self == n_other

[Tim]
>> Well, that's infinite recursion - but I know what you mean ;-)

[Alox]
> No.  You've probably missed that n_ objects are naive and naive comparison
> is just your plain old fold-unaware compare-all-components -except-fold
> operation.

I assumed you were showing an implementation of datetime.__eq__.  Yes?
 In that case, `self` and `other` may both be naive on entry.  Then
the first two lines effectively make exactly copies of them.  Since
None is None, the `self.tzinfo is other.tzinfo` check succeeds, and so
goes on to compare n_self to n_other - which are exact copies of the
original inputs.  Lather, rinse, repeat.


>>>     u_self = n_self - self.utcoffset()
>>>     v_self = n_self - self.replace(fold=(1-self.fold)).utcoffset()
>>>     u_other = n_other - other.utcoffset()
>>>     v_other = n_other - other.replace(fold=(1-self.fold)).utcoffset()
>>>     return u_self == u_other == v_self == v_other

>> More infinite recursion.

> ditto

Ditto ;-)
_______________________________________________
Datetime-SIG mailing list
[email protected]
https://mail.python.org/mailman/listinfo/datetime-sig
The PSF Code of Conduct applies to this mailing list: 
https://www.python.org/psf/codeofconduct/

Reply via email to