[Python-ideas] datetime.timedelta literals
chris.barker at noaa.gov
Mon Jun 4 17:50:43 EDT 2018
On Mon, Jun 4, 2018 at 1:59 PM, Pål Grønås Drange <paal.drange at gmail.com>
> For the general user-defined literals, here are some example use cases:
I kind of like the idea of user-defined literals, but:
> Yes, we could write all these as easily as function calls,
> center('my string') # or 'my string'.center(80)
> But somehow it seems nicer to write 42_km than 12 * pint.UnitRegistry().km
from pint import km
still not as nice as 42_km, though only by a bit....
So maybe you could propose adding:
to the datetime module, and then we could write:
60*seconds == 1*minutes
Without any changes to the language at all.
> - Pål
> Python-ideas mailing list
> Python-ideas at python.org
> Code of Conduct: http://python.org/psf/codeofconduct/
Christopher Barker, Ph.D.
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker at noaa.gov
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-ideas