def timedelta_total_seconds(td):
 try:
  return td.total_seconds()
 except AttributeError:
  return ((((td.days * 24) * 3600) + td.seconds) + (td.microseconds / 1000000))

def timedelta_total_seconds ( td ) : try : return td . total_seconds ( ) except AttributeError : return ( ( ( ( td . days * 24 ) * 3600 ) + td . seconds ) + ( td . microseconds / 1000000 ) )
replaces python 2 .