Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
str in str == True
#4
Haven't had a chance yet to review this but my very smart roommate said something I imagine is helpful:
Mikel Wrote:According to dis.dis(lambda: 'a' in 'ab' == True), ('a' in 'ab' == True) is equivalent to ('a' in 'ab' and 'ab' == True)
I think I know why: comparisons in Python are allowed to written similar to what we do naturally
So x < y < z is valid and equivalent to x < y and y < z
The 'in' operator is treated equivalently to '<', '==', etc.
So x in y == z is equivalent to x in y and y == z
Mystery solved
Reply


Messages In This Thread
str in str == True - by speedskis777 - Mar-26-2019, 08:15 AM
RE: str in str == True - by buran - Mar-26-2019, 08:32 AM
RE: str in str == True - by micseydel - Mar-26-2019, 11:25 PM
RE: str in str == True - by micseydel - Mar-27-2019, 12:37 AM
RE: str in str == True - by micseydel - Mar-27-2019, 01:41 AM
RE: str in str == True - by micseydel - Mar-27-2019, 01:45 AM
RE: str in str == True - by buran - Mar-27-2019, 08:01 AM
RE: str in str == True - by snippsat - Mar-27-2019, 12:15 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Returning True or False vs. True or None trevorkavanaugh 6 9,337 Apr-04-2019, 08:42 AM
Last Post: DeaD_EyE

Forum Jump:

User Panel Messages

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