summaryrefslogtreecommitdiffstats
path: root/Lib/datetime.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/datetime.py')
-rw-r--r--Lib/datetime.py22
1 files changed, 10 insertions, 12 deletions
diff --git a/Lib/datetime.py b/Lib/datetime.py
index b95536f..76a6f95 100644
--- a/Lib/datetime.py
+++ b/Lib/datetime.py
@@ -454,20 +454,18 @@ class timedelta:
return self
def __repr__(self):
- if self._microseconds:
- return "%s.%s(%d, %d, %d)" % (self.__class__.__module__,
- self.__class__.__qualname__,
- self._days,
- self._seconds,
- self._microseconds)
+ args = []
+ if self._days:
+ args.append("days=%d" % self._days)
if self._seconds:
- return "%s.%s(%d, %d)" % (self.__class__.__module__,
- self.__class__.__qualname__,
- self._days,
- self._seconds)
- return "%s.%s(%d)" % (self.__class__.__module__,
+ args.append("seconds=%d" % self._seconds)
+ if self._microseconds:
+ args.append("microseconds=%d" % self._microseconds)
+ if not args:
+ args.append('0')
+ return "%s.%s(%s)" % (self.__class__.__module__,
self.__class__.__qualname__,
- self._days)
+ ', '.join(args))
def __str__(self):
mm, ss = divmod(self._seconds, 60)