So my boss came up with this (by accident) after a quick search and replace on the code and opening a Pull Request, where tag is always a string:
if "team_" in tag in tag:
To my surprise, that actually works! Not really sure why. I was expecting to parse it from left to right and get an error, like this
>>> ("team_" in "something") in "something"
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'in <string>' requires string as left operand, not bool
or even in the worst case, parse it from right to left (which I find it odd, but let's assume it works that way)
>>> "team_" in ("something" in "something")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: argument of type 'bool' is not iterable
but what I got instead was
>>> "team_" in "something" in "something"
False
>>>
>>> "some" in "something" in "something"
True
>>>
can someone explain to me how/why does that work?