Please read the discussions on *https://mail.python.org/pipermail//python-ideas/2016-August/041890.html <https://mail.python.org/pipermail//python-ideas/2016-August/041890.html>*, https://mail.python.org/pipermail//python-ideas/2016-August/041939.html, https://mail.python.org/pipermail//python-ideas/2016-August/042028.html, https://mail.python.org/pipermail//python-ideas/2016-August/041899.html
They are more general than your proposal but they still cover pitfalls that may affect yours. It would be better if you could expand your proposal to the concerns raised on those threads. On Sun, Jun 3, 2018 at 12:53 PM, Pål Grønås Drange <paal.dra...@gmail.com> wrote: > > What about > > > > 2.5*h - 14*min + 9300*ms * 2 > > That doesn't seem feasible to implement, however, that is essentially how > the > Pint [1] module works: > > import pint > u = pint.UnitRegistry() > (2.5*u.hour - 14*u.min + 9300*u.ms) * 2 > # <Quantity(4.5385, 'hour')> > > ((2.5*u.hour - 14*u.min + 9300*u.ms) * 2).to('sec') > # <Quantity(16338.6, 'second')> > > > However why be limited to time units ? One would want in certain > > application to define other units, like meter ? Would we want a litteral > > for that ? > > Pint works with all units imaginable: > > Q = u.Quantity > Q(u.c, (u.m/u.s)).to('km / hour') > # <Quantity(3.6 speed_of_light, 'kilometer / hour')> > > > However, the idea was just the six (h|min|s|ms|us|ns) time literals; I > believe > time units are used more often than other units, e.g. in constructs like > > while end - start < 1min: > poll() > sleep(1s) # TypeError > sleep(1s.total_seconds()) # works, but ugly > > > [1] https://pypi.org/project/Pint/ > > Best regards, > Pål Grønås Drange > > _______________________________________________ > Python-ideas mailing list > Python-ideas@python.org > https://mail.python.org/mailman/listinfo/python-ideas > Code of Conduct: http://python.org/psf/codeofconduct/ > > -- Sebastian Kreft
_______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/