Tom Clark
Mar 2, 2024

--

You can't possibly be under the impresssion that "person = next((item for item in list_of_dicts if item.get('name') == 'Bob'), "person not found." )

" is clearer than the for loop you replaced, which was crystal clear at a glance. This one-liner would give an aspirin a headache!!!

--

--

Tom Clark
Tom Clark

Written by Tom Clark

Fluid Dynamicist at the core, lover of chaos theory. Experienced scientist, developer and team lead working in wind energy — from startups to heavy industry.

No responses yet