Cleaner assignment in for loop (python)
<p>I have a <code>nodelist</code> object that yields a bunch of <code>node</code> objects on iteration. I need to increment these nodes based on some random condition (like <code>node.x &gt; 17</code>). Here's what I'm doing right now:</p>

<pre><code>for node in nodelist: 
    if node.x &gt; 17: 
        node.x += 1 
</code></pre>

<p>I can't do <code>map(lambda node: node.x += 1, nodelist)</code> because lambda can't contain assignment. I cannot do <code>nodelist = [node.x + 1 for node in nodelist if...]</code> because a <code>nodelist</code> object consists of more than just its child nodes.</p>

<p>Is there a way to make this shorter/cleaner? </p>
