The two comprehensions: all((srt(n, m) in c_np) == (srt(a, b) in c_ap) for (m, b) in na) all( srt(n, m) in c_np == srt(a, b) in c_ap for (m, b) in na) parse differently but I am unclear what the second one produces since I thought it would be the same as the first. Any ideas how the second one parses?