(no title)
hermitdev | 10 months ago
This has not been true since around 2.4 or 2.5. The oldest Python I have available to me currently is 2.7, and this holds then, as it does now in 3.13:
>>> type(True)
<class 'bool'>
>>> type(1)
<class 'int'>
Prior to having a bool type, Python didn't even have True/False keywords.The reason something silly like `4 + True` works is because the bool type implements `tp_as_number` [0]. The reason it works this way is intentional because it would been a Python 3 str-style debacle if ints and bools were not interchangeable.
[0] https://github.com/python/cpython/blob/main/Objects/boolobje...
No comments yet.