[Python-Dev] Return type of datetime subclasses added to timedelta
alexander.belopolsky at gmail.com
Sat Jan 5 03:55:44 EST 2019
On Wed, Jan 2, 2019 at 10:18 PM Paul Ganssle <paul at ganssle.io> wrote:
> .. the original objection was that this implementation assumes that the
> datetime subclass has a constructor with the same (or a sufficiently
> similar) signature as datetime.
While this was used as a possible rationale for the way standard types
behave, the main objection to changing datetime classes is that it will
make them behave differently from builtins. For example:
>>> class F(float):
>>> type(F(1) + F(2))
This may be a legitimate gripe, but unfortunately that ship has sailed long
> ago. All of datetime's alternate constructors make this assumption. Any
> subclass that does not meet this requirement must have worked around it
> long ago (or they don't care about alternate constructors).
This is right, but the same argument is equally applicable to int, float,
etc. subclasses. If you want to limit your change to datetime types you
should explain what makes these types special.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-Dev