Feb-22-2017, 05:16 AM
(Feb-22-2017, 02:34 AM)ichabod801 Wrote: Or you want to check against actual boolean values, use is:
if value is False: handle_false() elif value is True: handle_true()True and False are singletons, like None. I don't know why everyone finds bools as ints so surprising. Did no one take discrete math?
booleans implemented as ints is what i learned (way way back in my mainframe assembler days) it was so in c because things must be implemented somehow or they don't exist (for what is implemented in c). that and in the language i designed ages ago booleans were not ints but could be coerced to become an int or even a float. i need to get more used to python not being the same that and i need to get used to other python features and subtle differences. i'm still in learning mode. i will be for years even if i do big projects in python.
Output:>>> 0 == False
True
>>> 0 is False
False
>>>
i already knew i could use is
, but i had a misunderstanding of it being the same as =
. thanks!
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.