[Python-Dev] For review: PEP 285: Adding a bool type (original) (raw)
Guido van Rossum guido@python.org
Fri, 08 Mar 2002 11:58:11 -0500
- Previous message: [Python-Dev] For review: PEP 285: Adding a bool type
- Next message: [Python-Dev] For review: PEP 285: Adding a bool type
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
>> One question: do True/False behave like None, particularly WRT "is"?
Guido> That depends on what the meaning of "is" is. (*) Guido> Yes, there will be only one True and one False. That's what the Guido> create flag on the new method was trying to suggest. Hmmm... A boolean type can only take on two values. I presume you will expose True and False through builtins.
Yes.
Why would you need a new method or any notiong of "creation"?
new must exist in order to support writing
bool(some_expression)
new returns a reference to the existing False or True object, except when it is called in the special internal-only mode that is needed to bootstrap False and True. The new code should really be just this:
def __new__(cls, val=0, _create=0):
if val:
return True
else:
return False
except the Python version must be able to create the instances True and False. (Hm, there's another way to create them:
False = int.__new__(bool, 0)
True = int.__new__(bool, 1)
I'll change the PEP to use this.)
--Guido van Rossum (home page: http://www.python.org/~guido/)
- Previous message: [Python-Dev] For review: PEP 285: Adding a bool type
- Next message: [Python-Dev] For review: PEP 285: Adding a bool type
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]