Elektrine lite

← Feed

@orman@furry.engineer

Post #2975021

2025-11-12 00:44 UTC

@apmasell@mastodon.social @Gankra@toot.cat TIL that's not the type checker people making things hard, it's stated in the documentation of `bool`

Replies (1)

  • @catgirl_so@tech.lgbt 2025-11-12 10:12

    @orman@furry.engineer @apmasell@mastodon.social @Gankra@toot.cat issubclass(bool, int) has been true for the entire time that bool has been a class; in fact, isinstance(True, int) and isinstance(False, int) has been true (or rather, 1) since before bool even existed! in python 2.0 and 2.0.1, there was no bool in the global namespace, and True and False were just the ints 0 and 1 respectively. python 2.1 introduced bool as this function (defined in Lib/symtable.py): def bool(x): """Helper to force boolean result to 1 or 0""" if x: return 1 return 0 only in python 2.3 did bool become its own class (defined in Objects/boolobject.c), and from that point onward bool has always subclassed int. type checkers treating bool as a subtype of int just reflects how python has worked since long before the type checkers existed. (source: poking around source tarballs downloaded from https://www.python.org/ftp/python/)

    Open ##2975022