I have a rule for comprehensions that I try not to break: they should only have two phrases in them. Whether that’s two “for x in y” or one “for” and one “if”. Anything more becomes confusing and illegible.
Complicated comprehensions are not clever or impressive, they’re annoying.
Complicated comprehensions are not clever or impressive, they’re annoying.