
July 31, 2015
12:24 a.m.
On 07/30/2015 03:10 PM, Chris Barker wrote:
By the way -- which __add__ actually does the implementation? datetime's or timedelta's ?
class timedelta: def __add__(self, other): if isinstance(other, timedelta): # for CPython compatibility, we cannot use # our __class__ here, but need a real timedelta return timedelta(self._days + other._days, self._seconds + other._seconds, self._microseconds + other._microseconds) return NotImplemented timedelta only adds directly to other timedeltas; so datetime is doing the actual addition. -- ~Ethan~