<div dir="auto">second, minute, hour (singular) timedelta objects in the module are a good idea, one could do 5 * minute to get a timedelta or one could do value / minute to get a float.<div dir="auto"><br></div><div dir="auto">a = datetime.now()</div><div dir="auto">b = datetime(2018, 2, 3) + 5 * minute</div><div dir="auto">print((a - b).total_seconds())</div><div dir="auto"><div dir="auto" style="font-family:sans-serif">print((a - b) / minute)</div><br></div><div dir="auto"><br></div></div><br><div class="gmail_quote"><div dir="ltr">Le mar. 5 juin 2018 à 10:23, Jacco van Dorp <<a href="mailto:j.van.dorp@deonet.nl">j.van.dorp@deonet.nl</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">2018-06-05 10:08 GMT+02:00 Pål Grønås Drange <<a href="mailto:paal.drange@gmail.com" target="_blank" rel="noreferrer">paal.drange@gmail.com</a>>:<br>
>> You can't import literals. They're syntax, not just bound names.<br>
><br>
> I'm way out of my comfort zone now, but the parser could for<br>
> `123.45_f`<br>
> give<br>
> `__literal_f__(123.45)`<br>
> and then that function should be imported.<br>
><br>
> I'm sure this idea has many shortcomings that I don't see, but that was the<br>
> reason why I wanted to import stuff.<br>
><br>
> Pål<br>
<br>
Before your code is executed, python scans your entire file for syntax<br>
errors. Since 123.45_f is currently not a valid literal, it'll just<br>
print a syntax error without even looking at your imports.<br>
<br>
To change that, the very core of python would need to look completely<br>
different. It'd be a metric fuckton of work for a whole lot of people.<br>
Im not a core dev myself or anything, but i'm pretty confident that<br>
this isn't going to happen for a rather minor need like this.<br>
_______________________________________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org" target="_blank" rel="noreferrer">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" rel="noreferrer noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" rel="noreferrer noreferrer" target="_blank">http://python.org/psf/codeofconduct/</a><br>
</blockquote></div>