PEP 285: Adding a bool type

James Althoff jamescalthoff at yahoo.com
Sat Apr 6 14:12:18 EST 2002


[Laura Creighton]
> 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?

Returning a third value from isValid, "-1 indicates that an account has been
suspended", for example, seems like a bad idea because all code that tests
"if isValid" (as you recommend) would still allow suspended accounts to work
since -1 passes the "is something" test.  Since the calling code has to be
changed anyway, why not design it better?

Personally, I'm not a big fan of special codes: 0 means this, 1 means
that, -1 means something else, 999 means yet another thing, etc.

Jim








More information about the Python-list mailing list