Python Forum

Full Version: How to exclude bools from integers?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi , for excluding everything, but integers i have found this code

isinstance(n,int)
. My Problem is, if i write
isinstance(n,int) == True and n!= True or False
, 0 and 1 will not remain in my code. Is there any possibility, just to remove True and False, because i want to avoid that python gives an answer for True/n or False/n.
Booleans are a subtype of integers. Distinction between integers and bools can be made:

>>> type(False) is bool
True
>>> type(0) is bool
False
thanks, now i know what i have to change Smile