Fancy Reverse Syntax for If and For Statements
<p>I often see code similar to this: </p>

<pre><code>return [(var, val) for val in self.domains[var]
                    if self.nconflicts(var, val, assignment) == 0]
</code></pre>

<p>and I'm like DAMN that's sexy. But then I try to drop it sometimes and I get syntax errors. Are there any particular rules for this nice form of code writing that reverses  the typical placement of <code>for</code> and <code>if</code> statements? </p>
