ACCEPTED: PEP 285

Guido van Rossum guido at python.org
Fri Apr 5 13:38:55 EST 2002


James Logajan wrote:
> When I looked at it I saw a "class bool(int)" definition, so I
> wasn't sure how instances of such a (pseudo?) class would be handled in a
> dictionary.

It wasn't a pseudo class.  It was working code, and designed to answer
such questions precisely, without having to use ambiguous English words.

> The statement "The values False and True will be singletons,
> like None," further added to my confusion, since None is a valid dictionary
> key, distinct from all other values, which when combined with the class
> definition pretty much sealed the confusion. I assumed the "ACCEPTED: PEP
> 285" posting would have subsumed previous discussions, including any
> concerning the class instances as dictionary keys. I couldn't find a clear
> answer there, hence my question.

The PEP specifies the answer, by stating that True==1 and False==0.  The
answer really *does* follow from that (and even this statement is redundant,
as it follows from the way True and False are created in the code block).
You could have typed the code in to Python 2.2 and gotten your answer.

> My apologies to those who have sent me angry e-mails for not realizing that
> PEPs do not stand alone from the lengthy discussion threads on Usenet. The
> fault is entirely mine.

A PEP's specification *does* stand alone (besides dependence on the Python
spec) but it doesn't have to be a tutorial.

--Guido van Rossum (home page: http://www.python.org/~guido/)



More information about the Python-list mailing list