def total_seconds(timedelta):
    if not isinstance(timedelta, datetime.timedelta):
        raise TypeError('expected a datetime.timedelta, not ' +
                        repr(timedelta))
    elif hasattr(timedelta, 'total_microseconds'):
        return timedelta.total_microseconds()
    microsec = timedelta.microseconds
    sec = timedelta.seconds
    days = timedelta.days
    return (microsec + (sec + days * 24 * 3600) * 10 ** 6) / 10 ** 6
For Python 2.6 compatibility.  Equivalent to
dataset/ETHPy150Open dahlia/sider/sider/datetime.py/total_seconds