DEV Community

Discussion on: Write a function that shows off something unique or interesting about the language you're using

Collapse
 
pbouillon profile image
Pierre Bouillon • Edited

It's no longer an integer :)

Thread Thread
 
val_baca profile image
Valentin Baca

It still is. bool is a subclass of int:

$ python3
Python 3.6.5 (default, Mar 30 2018, 06:42:10)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> isinstance(True, int)
True
>>> isinstance(False, int)
True
Thread Thread
 
pbouillon profile image
Pierre Bouillon • Edited

Shameful mistake, thanks for clarifying ! I meant that they had their own type now, indeed from integer.

Full explanation

Initially, Python used to have no bool type 
(people used 0 for false and non-zero value like 1 for true). 
Then they added True, False, and a bool type, but, for backward
compatibility, they couldn't make True and False constants- they 
just were built-in variables.