3 ms·
Now try including if statements, loops, structural pattern matches, context managers, etc.
by lvass 5y ago
Now try including if statements, loops, structural pattern matches, context managers, etc.
- jstx1 5y agoIf it's too complicated for a lambda, you shouldn't be using a lambda. Define a separate function if it takes you more than a line or it's harder to reason about.
- lvass 5y agoThe point is it's only complicated in Python. In other languages, like Rust, it's idiomatic.
- agumonkey 5y agoPeople all know lambdas are expressions only, it's not a biggie really. In all honesty you rarely inline complex lambdas with all you mentioned, it would become hard to read or debug.