[Python-ideas] datetime.timedelta literals

Paul Moore p.f.moore at gmail.com
Mon Jun 4 04:58:08 EDT 2018


On 4 June 2018 at 09:44, Pål Grønås Drange <paal.drange at gmail.com> wrote:
>> Speaking for myself, not for Paul, I guess my big objection would be
>> that there would be too many collisions with other interpretations.
>> Eg, does "5m" mean "5 minutes", "5 meters", or "the number 0.005"?  Or
>> perhaps "5 minutes of arc"?
>
> Just to clarify, the proposition was actually `5min`, and that it would
> mean `datetime.timedelta(minutes=5)`.

... and the fact that it's easy to forget that it's 5min rather than
5m (is it 1h or 1hr, 2s or 2sec?) is a problem with the proposal. Of
course there's a similar problem with timedelta(minutes=5) or
timedelta(minute=5) (timedelta uses minutes, datetime uses minute, I
had to look in the docs to check), so it's not unique to the literal
notation, but it is an issue nevertheless.

Paul


More information about the Python-ideas mailing list