Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
is vs in
#1
i am doing testing for exactly the same as opposed to equivalent. this means using the is keyword for comparison. comparing 1 to True (for example) i want to be False. but i have cases in a new project where i need to test if a variable is (or is not) the same as any of a few values. the in keyword does not compare like is. it compares more like ==. is there a way to do an is-like comparison against a list (or tuple) of values? i tried this in the hope there was a way but that is not implemented.
if this is in that:
    print('yes')
else:
    print('no')
if this cannot be done, then that syntax is my suggested addition.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Messages In This Thread
is vs in - by Skaperen - Dec-20-2020, 01:56 AM
RE: is vs in - by bowlofred - Dec-20-2020, 03:00 AM
RE: is vs in - by Skaperen - Dec-20-2020, 05:19 AM

Forum Jump:

User Panel Messages

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