bool and int
Mike Baskin
mikebaskin6538 at yahoo.com
Tue Jan 24 20:16:31 EST 2023
Will all of you please stop sending me emails
Sent from my iPhone
> On Jan 24, 2023, at 2:59 PM, rbowman <bowman at montana.com> wrote:
>
> On Mon, 23 Jan 2023 23:22:00 -0500, Dino wrote:
>
>> $ python Python 3.8.10 (default, Mar 15 2022, 12:22:08)
>> [GCC 9.4.0] on linux Type "help", "copyright", "credits" or "license"
>> for more information.
>>>>> b = True isinstance(b,bool)
>> True
>>>>> isinstance(b,int)
>> True
>>>>>
>>>>>
>> WTF!
>
>
>>>> b = True
>>>> isinstance(b, bool)
> True
>>>> isinstance(b, int)
> True
>>>> c = b + 10
>>>> print(c)
> 11
>>>> b = False
>>>> c = b + 10
>>>> print(c)
> 10
>
>
> bool is a subtype of integer. I never dug that deep into Python's guts but
> I assume it goes back to boolean being an afterthought in C. Some people
> fancy it up with #defines but I always use int. 0 is false, anything else
> is true.
>
> C# is pickier, which I guess is a good thing.
> --
> https://mail.python.org/mailman/listinfo/python-list
More information about the Python-list
mailing list