>>> import datetime
>>> now1 = datetime.datetime.now()
>>> now2 = datetime.datetime.now()
>>> timedelta = now2-now1
>>> halfdt = timedelta/2 #This works just fine
>>> halfdt = timedelta/2. #TypeError: unsupported operand type(s) for /: 'datetime.timedelta' and 'float'
Does anybody know the rational for only allowing timedeltas to be divisible by integers?
It’s actually pretty simple – it was a missing feature.
The upside of this is that it’s been added as a feature in Python 3.x.
Note the difference between the supported operation tables in 2.x and 3.x.