[Datetime-SIG] PEP-0500 (Alternative datetime arithmetic) Was: PEP 495 ... is ready ...

Alexander Belopolsky alexander.belopolsky at gmail.com
Wed Aug 19 19:22:31 CEST 2015


On Wed, Aug 19, 2015 at 12:53 PM, Guido van Rossum <guido at python.org> wrote:

> On Wed, Aug 19, 2015 at 9:15 AM, Alexander Belopolsky <
> alexander.belopolsky at gmail.com> wrote:
>
>> On Wed, Aug 19, 2015 at 11:55 AM, Guido van Rossum <guido at python.org>
>> wrote:
>> >>[...]
>> > That does not sound like what I was proposing (as a hack) -- it simply
>> > exchanges one bug for another.
>>
>> No, it is not a bug.
>>
>
> That's a ridiculously narrow point of view.
>
>

Well,

>>> print(lt)
2015-03-07 12:00:00-05:00
>>> print(lt + timedelta(1))
2015-03-08 12:00:00-05:00

Is as much a bug as

>>> sum([0.1] * 10) == 1
False

The code works exactly as designed and documented.  The fact that it can be
used to write buggy programs does not mean that there is a bug in the
library.   The same library can be used to write correct programs and I
have shown how.  I don't see what is so "narrow" in my point of view.  Can
you elaborate?

Regardless of the software involved, if I give you an ISO 8601 string
"2015-03-07 12:00:00-0500" and ask you: What time will be 24 hours after
that?  I bet your answer will be "2015-03-08 12:00:00-0500."  And I don't
think you will appreciate being ridiculed for not knowing that the
"correct" answer is  "2015-03-08 13:00:00-0400."  After all, Python does
not really care:

>>> fmt = "%Y-%m-%d %H:%M:%S%z"
>>> datetime.strptime("2015-03-08 13:00:00-0400", fmt) ==
datetime.strptime("2015-03-08 12:00:00-0500", fmt)
True
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/datetime-sig/attachments/20150819/f435c399/attachment.html>


More information about the Datetime-SIG mailing list