How to determine the bool between the strings and ints?

Steven D'Aprano steve at
Sat Sep 8 03:10:44 CEST 2007

On Fri, 07 Sep 2007 17:40:44 +0200, Jorgen Bodde wrote:

> is the bool derived from 'int' in some way? 


>>> issubclass(bool, int)

> What is the best way to
> check if the config I want to write is an int or a bool ?

if isinstance(value, bool):
    print "it's a bool, or a subclass of bool"
elif isinstance(value, int):
    print "it's an int, or a subclass of int other than bool"


More information about the Python-list mailing list