"Andy Salnikov" <[EMAIL PROTECTED]> writes: > "Aahz" <[EMAIL PROTECTED]> wrote: > > Antoon Pardon <[EMAIL PROTECTED]> wrote: > >>The problem is there is also ground for bugs if you don't use > >>"blah is True". If some application naturally seems to ask for a > >>variable that can be valued False, True or a positive integer then > >>things like "if var" or "if not var" may very well be a bug too. > > > > Anyone designing an app like that in Python deserves to lose. > > It's just another way of shooting yourself in the foot. > > OK, I guess nobody ever heard about three-valued logic before, > right?
Three-valued logic is fine for some purposes. Bending boolean two-valued constants to play the part of three-valued is confusing and wrong. > Of course it does not apply to the original post because has_key() > can only return True or False (I hope it will not ever return > DontKnow:) but in general if you implement something like 3-valued > logic choices like (False,True,None) are almost obvious. No. Using False and True is a strong signal to the reader that you're using *two* value logic. If you break that expectation, the reader should not be expected to sympathise. As another poster suggested, if you want to implement three-valued logic, use three new objects to represent the states, so the reader *knows* there's something going on other than two-value logic. Don't re-use False and True in three-valued logic and expect anyone to understand your code. -- \ "It is seldom that liberty of any kind is lost all at once." | `\ -- David Hume | _o__) | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list