Fix isinstance error and replace lambdas with list comprehensions

svn: r10838
This commit is contained in:
Gerald Britton 2008-07-03 18:30:00 +00:00
parent 6926f71869
commit 2e4d57ea28

View File

@ -322,12 +322,13 @@ class Date:
if isinstance(other, int): # Date - value -> Date if isinstance(other, int): # Date - value -> Date
return self.copy_offset_ymd(-other) return self.copy_offset_ymd(-other)
elif isinstance(other, (tuple, list)): # Date - (y, m, d) -> Date elif isinstance(other, (tuple, list)): # Date - (y, m, d) -> Date
return self.copy_offset_ymd(*map(lambda x: -x, other)) return self.copy_offset_ymd(*[-i for i in other])
elif isinstance(other, self): # Date1 - Date2 -> tuple elif isinstance(other, type(self)): # Date1 - Date2 -> tuple
# We should make sure that Date2 + tuple -> Date1 and # We should make sure that Date2 + tuple -> Date1 and
# Date1 - tuple -> Date2 # Date1 - tuple -> Date2
d1 = map(lambda i: i or 1, self.get_ymd()) d1 = [i or 1 for i in self.get_ymd()]
d2 = map(lambda i: i or 1, other.get_ymd()) d2 = [i or 1 for i in other.get_ymd()]
date1 = self date1 = self
date2 = other date2 = other
if d1 < d2: if d1 < d2: