bool and int

MRAB python at mrabarnett.plus.com
Tue Jan 24 16:17:48 EST 2023


On 2023-01-24 20:32, Weatherby,Gerard wrote:
> https://peps.python.org/pep-0285/
> 
> From: Python-list <python-list-bounces+gweatherby=uchc.edu at python.org> on behalf of rbowman <bowman at montana.com>
> Date: Tuesday, January 24, 2023 at 3:01 PM
> To: python-list at python.org <python-list at python.org>
> Subject: Re: bool and int
> 
> 
> 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.
> 
bool was introduced early in Python 2. Before then 0 and 1 were used for 
false and true, like in C, which also gained 'false' and 'true'.

For backwards compatibility, bool was made a subclass of int.

> C# is pickier, which I guess is a good thing.



More information about the Python-list mailing list