[issue4291] Allow Division of datetime.timedelta Objects

Jeremy Banks report at bugs.python.org
Mon Nov 10 01:16:56 CET 2008


Jeremy Banks <jeremy at jeremybanks.ca> added the comment:

Sorry, allowing for conversion to int/float is probably a more sensible
solution.

This idea was brought to my mind when I was making a very very simple
script for a friend to display how far through a time range we currently
are. For example:

	elapsed = datetime.timedelta(hours=4, days=3)
	duration = datetime.timedelta(days=30)
	
	percentage = (100 * elapsed / duration)

In my case, precision wasn't important so I just divided elapsed.days by
duration.days, but it would be continent to have an accurate result by
just writing what I did above.

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue4291>
_______________________________________


More information about the Python-bugs-list mailing list