Brian van den Broek wrote:
I've begun to wonder if I am overlooking a
improvement similar to that in DogWalker's suggestion. As an example of
the sort of thing I have been doing:
import datetime
def is_leap_year(year):
'''-> boolean
Returns True or False as year is, or is not, a leap year.
'''
is_leap = True
try:
datetime.date(year, 2, 29)
except ValueError:
is_leap = False
return is_leap
I would write
def is_leap_year(year):
try:
datetime.date(year, 2, 29)
return True
except ValueError:
return False
Kent
_______________________________________________
Tutor maillist - [EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/tutor