[Tutor] Leap years

Don Arnold Don Arnold" <darnold02@sprynet.com
Sun Jan 12 17:17:01 2003


----- Original Message -----
From: "Gerrit Holl" <gerrit@nl.linux.org>
To: <tutor@python.org>
Sent: Sunday, January 12, 2003 3:54 PM
Subject: Re: [Tutor] Leap years


> Don Arnold schreef op zondag 12 januari om 19:24:22 +0000:
> > def isLeapYear(year):
> >     if year passes test for a leap year:
> >         return 1
> >     else:
> >         return 0
>
> I think it's better to use True and False here.
> Instead of "return 1", "return True".
> Instead of "return 0", "return False".
>
> It's boolean what's being expected from this function; not an integer.
> It's not natural to return an integer, as it's not natural to return
> a empty or non-empty sequence.
>

That's true, but I believe True and False are recent additions to Python.
Regardless, they're currently defined as ints with the values 1 and 0
respectively, so the result is the same. I guess I'm just used to coding it
the old-fashioned way, a la the C language. However, since this was
(thinly-veiled) pseudocode, True and False would have probably been better
choices.

> yours,
> Gerrit.
>
> --
> Asperger Syndroom - een persoonlijke benadering:
> http://people.nl.linux.org/~gerrit/
> Het zijn tijden om je zelf met politiek te bemoeien:
> http://www.sp.nl/

Don