3 ms·
There is another Python feature that saves you from this trap however - the nested function. I have lots of code that looks like this: def txform_item(x):
by tragomaskhalos 8y ago
There is another Python feature that saves you from this trap however - the nested function. I have lots of code that looks like this:
def txform_item(x):
<maybe many lines, as complex as needed, + can see vars in outer scope>
# right below, for optimal locality of ref for human reader
new_list = [ txform_item(item) for item in old_list ]