Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
gotcha
#10
(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 Pray   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.
Reply


Messages In This Thread
gotcha - by Skaperen - Feb-21-2017, 09:14 AM
RE: gotcha - by Larz60+ - Feb-21-2017, 10:12 AM
RE: gotcha - by zivoni - Feb-21-2017, 10:46 AM
RE: gotcha - by micseydel - Feb-21-2017, 04:50 PM
RE: gotcha - by Ofnuts - Feb-21-2017, 09:30 PM
RE: gotcha - by micseydel - Feb-21-2017, 09:33 PM
gotcha 2.0 - by Skaperen - Feb-22-2017, 02:28 AM
RE: gotcha - by ichabod801 - Feb-22-2017, 02:34 AM
RE: gotcha - by Skaperen - Feb-22-2017, 05:16 AM
RE: gotcha - by micseydel - Feb-22-2017, 04:59 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020