Python Forum
How to exclude bools from integers?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to exclude bools from integers?
#1
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.
Reply
#2
Booleans are a subtype of integers. Distinction between integers and bools can be made:

>>> type(False) is bool
True
>>> type(0) is bool
False
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Reply
#3
thanks, now i know what i have to change Smile
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Regex Include and Exclude patterns in Same Expression starzar 2 807 May-23-2023, 09:12 AM
Last Post: Gribouillis
  [SOLVED] [loop] Exclude ranges in… range? Winfried 2 1,475 May-14-2023, 04:29 PM
Last Post: Winfried
  Telegram Users Scrapper - Exclude UserPrivacyRestricted graphite2015 0 2,611 Oct-23-2020, 05:43 AM
Last Post: graphite2015
  loop through range until reach size and exclude specific symbol pino88 3 2,388 Sep-23-2019, 02:32 AM
Last Post: perfringo
  List Comprehension to exclude first row tkj80 5 4,964 Jun-11-2018, 09:24 AM
Last Post: volcano63
  Exclude words with specific endings from list Epileptiker 5 4,228 Apr-06-2018, 02:40 PM
Last Post: nilamo
  Twitter scraping exclude some data Robbert 6 5,163 Sep-02-2017, 09:44 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020