<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<div dir="ltr">I found it fun to be able to write minutes(50) alongside with 50 * minutes so I did that :<br>
<div><br>
from datetime import date, time, datetime, timedelta<br>
<br>
class CallableTimedelta(timedelta):<br>
    def __call__(self, x):<br>
        return self * x<br>
    <br>
seconds, milliseconds, microseconds, days, hours, minutes, weeks = (CallableTimedelta(**{x:1}) for x in ('seconds', 'milliseconds', 'microseconds', 'days', 'hours', 'minutes', 'weeks'))<br>
<br>
</div>
<div>print(minutes(50) / seconds) # 3000.0<br>
</div>
<div>
<div>print(50 * minutes / seconds) # 3000.0<br>
</div>
<div>
<div>print(minutes(50).total_seconds()) # 3000.0<br>
</div>
<div><br>
</div>
<br>
</div>
<br>
</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">2018-06-07 13:34 GMT+02:00 Pål Grønås Drange <span dir="ltr">
<<a href="mailto:paal.drange@gmail.com" target="_blank">paal.drange@gmail.com</a>></span>:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<p dir="ltr">For closure, I've added a package, timeliterals</p>
<p dir="ltr">(env) [pgdr@hostname ~]$ pip install timeliterals<br>
(env) [pgdr@hostname ~]$ python<br>
>>> from timeliterals import *<br>
>>> 3*hours<br>
datetime.timedelta(0, 10800)<br>
>>> 3*minutes<br>
datetime.timedelta(0, 180)<br>
>>> 3*seconds<br>
datetime.timedelta(0, 3)</p>
<p dir="ltr">The source code is at <a href="https://github.com/pgdr/timeliterals" target="_blank">
https://github.com/pgdr/<wbr>timeliterals</a></p>
<p dir="ltr">I'm not going to submit a patch to datetime at this time, but I will if people<br>
would be interested.</p>
<span class="HOEnZb"><font color="#888888">
<p dir="ltr">- Pål</p>
</font></span>
<div class="HOEnZb">
<div class="h5">
<div class="gmail_extra"><br>
<div class="gmail_quote">On 5 Jun 2018 13:56, "Jacco van Dorp" <<a href="mailto:j.van.dorp@deonet.nl" target="_blank">j.van.dorp@deonet.nl</a>> wrote:<br type="attribution">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
i'd also be pretty simple to implement....<br>
<br>
Just list:<br>
minute = timedelta(minutes=1)<br>
hour = timedelta(hours=1)<br>
etc...<br>
<br>
and you could import and use them like that. Or if you really want to<br>
write 5*m, the just from datetime import minute as m<br>
______________________________<wbr>_________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org" target="_blank">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" rel="noreferrer" target="_blank">https://mail.python.org/mailma<wbr>n/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" rel="noreferrer" target="_blank">
http://python.org/psf/codeofco<wbr>nduct/</a><br>
</blockquote>
</div>
</div>
</div>
</div>
<br>
______________________________<wbr>_________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" rel="noreferrer" target="_blank">https://mail.python.org/<wbr>mailman/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" rel="noreferrer" target="_blank">
http://python.org/psf/<wbr>codeofconduct/</a><br>
<br>
</blockquote>
</div>
<br>
</div>
</body>
</html>