def matches(self, date):
return ((self.year and self.year == date.year or True) and
(self.month and self.month == date.month or True) and
(self.day and self.day == date.day or True) and
(self.weekday and self.weekday == date.weekday() or True))
testMatchesFalse test because
== binds more tightly than "or."
>>> c and c == 2 or True
>>> c and c == (2 or True)
I agree that the explicit code is cleaner.
I'm just learning Python, and it's interesting that laziness is one of the three virtues in the Perl world yet is decried in Python circles.