[Python-Dev] PEP 285: Adding a bool type (original) (raw)
Patrick K. O'Brien pobrien@orbtech.com
Wed, 3 Apr 2002 13:34:37 -0600
- Previous message: [Python-Dev] PEP 285: Adding a bool type
- Next message: [Python-Dev] PEP 285: Adding a bool type
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
The issue of dictionary keys has been raised, and is a bit perplexing, but not overly so, IMO. However, I'd like confirmation that this is indeed the intended behavior:
>>> d = {} >>> d[0] = 'First' >>> d {0: 'First'} >>> d[False] = 'Second' >>> d {0: 'Second'} >>> d[0.0] = 'Third' >>> d {0: 'Third'} >>> d[()] = 'Fourth' >>> d {0: 'Third', (): 'Fourth'} >>> d[None] = 'Fifth' >>> d {0: 'Third', (): 'Fourth', None: 'Fifth'} Or are there any situations like this where you would want True and False to be a bit more like None and a bit less like ints? Meaning True and False could be dictionary keys separate from 0 and 1.
I see that you just addressed this and confirmed that True==1 and False==0 in all contexts. That's fine by me. I just wanted confirmation.
Patrick K. O'Brien Orbtech
- Previous message: [Python-Dev] PEP 285: Adding a bool type
- Next message: [Python-Dev] PEP 285: Adding a bool type
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]