PEP 285: Adding a bool type

Toby Dickenson tdickenson at devmail.geminidataloggers.co.uk
Mon Apr 8 06:42:59 EDT 2002


Laura Creighton <lac at strakt.com> wrote:

>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 objects do you return for those three states? You didnt say, but
from your previous posts I would guess you were intending something
like invalid: 0, valid: 1, unpaid:  2

Changing the old two-values function into this new three-valued
function would be a disservice to any code that previously used
"if user.isValid():" but wants to treat unpaid users like invalid
ones.

>If you don't need a third value, somebody 
>else will, later. 

You have to pray that, when they do, the third state is a subdivision
of the original 1/true/something state, rather than a subdivision of
the old 0/false/nothing state.

Toby Dickenson
tdickenson at geminidataloggers.com



More information about the Python-list mailing list