PEP 285: Adding a bool type

phil hunt philh at comuno.freeserve.co.uk
Mon Apr 8 06:49:21 EDT 2002


On Sat, 06 Apr 2002 20:39:41 +0200, Laura Creighton <lac at strakt.com> wrote:
>Mark McEahern writes:
>> [Laura Creighton]
>> > [...]  I am rejecting the existence of booleans in the language
>> > because it is too hard to teach how to use them properly.
>> 
>> How do you use them properly?
>> 
>> Suppose I want to validate users.  I might write something like this:
>> 
>> 	def isValid(user, password):
>> 		if ...:
>> 			return True
>> 		else:
>> 			return False
>
>My pleasure, especially since this is such a cool example.  You have
>just shot yourself in the foot, and do not know it.  When you have
>shipped your isValid function, across the world to your 10,000 clients,
>you will discover this.
>
>Your boss comes in and says, oh, Mark, we need a change to that
>isValid function.  We need to return 3 states, Valid, Invalid, and
>Valid-but-You-Don't-Have-Access-Because-You-Didn't-Pay-Your-Bill.
>
>What do you do now?  

You need 2 functions: isUserValid(user, password) and
hasUserPaidUpToDate(user).



-- 
<"><"><"> Philip Hunt <philh at comuno.freeserve.co.uk> <"><"><">
"I would guess that he really believes whatever is politically 
advantageous for him to believe." 
                        -- Alison Brooks, referring to Michael
                              Portillo, on soc.history.what-if



More information about the Python-list mailing list