I am doing an assignment to compile a subset of Pascal and in the initial program there is a line of code like this:
if x.tp == y.tp in {Bool, Int}:
some other code ...
This makes me really confused as x.tp == y.tp
returns a boolean value True
or False
and thus True/False in {Bool, Int}
will always return False
.
The definition of Bool
and Int
is the following:
class Int: pass
class Bool: pass
Then, I set a breakpoint at that line, and play around in VSCode's debugger:
>> x.tp
<class 'ST.Int'>
>> y.tp
<class 'ST.Int'>
>> x.tp == y.tp
True
>> a = (x.tp == y.tp)
None
>> a
True
>> a in {Bool, Int}
False
>> x.tp == y.tp in {Bool, Int}
True <----------------------- why does it return True?
Why does x.tp == y.tp in {Bool, Int}
return True
here?