[New-bugs-announce] [issue45891] bool variable isinstance of int

noobie1000 report at bugs.python.org
Wed Nov 24 08:04:10 EST 2021


New submission from noobie1000 <balajesuri at gmail.com>:

Hello,

Recently I observed that isinstance(x, int) returns True, even when x is defined as a bool. While I understand that internally, a bool is treated as an int with values 0 and 1; to me, this is a bit misleading that the python interpreter returns True when we perform the isinstance() check. May be I'm missing some deeper explanation. Could someone please shed some light on this. Has this been discussed by the community in the past. Thank you very much for reading this ticket.

>>> x = True
>>> isinstance(x, int)
True

----------
components: IO
messages: 406926
nosy: noobie1000
priority: normal
severity: normal
status: open
title: bool variable isinstance of int
type: behavior
versions: Python 3.6

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue45891>
_______________________________________


More information about the New-bugs-announce mailing list