From 2e4d57ea288dff271e7a109badf87acc5ff36191 Mon Sep 17 00:00:00 2001 From: Gerald Britton Date: Thu, 3 Jul 2008 18:30:00 +0000 Subject: [PATCH] Fix isinstance error and replace lambdas with list comprehensions svn: r10838 --- src/gen/lib/date.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/gen/lib/date.py b/src/gen/lib/date.py index a848bc9ee..3b65ccb85 100644 --- a/src/gen/lib/date.py +++ b/src/gen/lib/date.py @@ -322,12 +322,13 @@ class Date: if isinstance(other, int): # Date - value -> Date return self.copy_offset_ymd(-other) elif isinstance(other, (tuple, list)): # Date - (y, m, d) -> Date - return self.copy_offset_ymd(*map(lambda x: -x, other)) - elif isinstance(other, self): # Date1 - Date2 -> tuple + return self.copy_offset_ymd(*[-i for i in other]) + elif isinstance(other, type(self)): # Date1 - Date2 -> tuple # We should make sure that Date2 + tuple -> Date1 and # Date1 - tuple -> Date2 - d1 = map(lambda i: i or 1, self.get_ymd()) - d2 = map(lambda i: i or 1, other.get_ymd()) + d1 = [i or 1 for i in self.get_ymd()] + d2 = [i or 1 for i in other.get_ymd()] + date1 = self date2 = other if d1 < d2: