Eric Walstad wrote:
> Hey Matt,
> 
> Skirting your question that looks like a modulo issue[1]...
> 
> Maybe isleapyear[2] will work for you:
> 
> import calendar
> 
> calendar.isleap(2007)  -> False
> calendar.isleap(2008)  -> True

And one of the nice things about Python, as well as having lots of 
useful stuff built in, much of the useful stuff is itself written in 
Python making it very easy to look under the hood and see what is going 
on. Here is the implementation of calendar.isleap():

def isleap(year):
     """Return 1 for leap years, 0 for non-leap years."""
     return year % 4 == 0 and (year % 100 != 0 or year % 400 == 0)

Kent
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to