I have a nodelist object that yields a bunch of node objects on iteration. I need to increment these nodes based on some random condition (like node.x > 17). Here's what I'm doing right now:
for node in nodelist:
if node.x > 17:
node.x += 1
I can't do map(lambda node: node.x += 1, nodelist) because lambda can't contain assignment. I cannot do nodelist = [node.x + 1 for node in nodelist if...] because a nodelist object consists of more than just its child nodes.
Is there a way to make this shorter/cleaner?