News for hackers. Stuff that matters.
Re:Writing good code: how to reduce the cognitive load of yo... by graton on Tuesday March 07, 2017 @07:17PM (#13816616)
Or:

validated_items = [x for x in items if is_validated(x)]

Re:Writing good code: how to reduce the cognitive load of yo... by im3w1l on Wednesday March 08, 2017 @12:13AM (#13818073)
I prefer the other one, because then I don't have to consider whether there is an outer variable 'x' that is being clobbered.
Re:Writing good code: how to reduce the cognitive load of yo... by aidos on Wednesday March 08, 2017 @05:20AM (#13819286)
In python 3, x is locally scoped to the comprehension :-)
Re:Writing good code: how to reduce the cognitive load of yo... by Singletoned on Wednesday March 08, 2017 @01:43AM (#13818462)
Most linters would have suggested correcting it to:

validated_items = [_ for _ in items if is_validated(x)]

where _ is used as a safe variable that can always be clobbered. (Though this does also clash with its use as a gettext function for strings).