divtdi = datetime.timedelta.__div__

def divtd(td1, td2):
    if isinstance(td2, int):
        return divtdi(td1, td2)
us1 = td1.microseconds + 1000000 * (td1.seconds + 86400 * td1.days)
us2 = td2.microseconds + 1000000 * (td2.seconds + 86400 * td2.days)
return us1 / us2
How can I perform divison on a datetime.timedelta in python?