Why not real anonymous functions?

When announcing Python 1 30 years ago, Guido gave ‘it is readable’ as a primary design goal and feature. This means naming intermediate objects when appropriate, even though this is not ‘economical’ with letters. The latter is not a goal of Python design.

Named functions have a name that is unique within its context and which can be printed in tracebacks. Non-nested functions can be tested. Lambda expressions work best when obvious enough to not need testing and when unlikely to be a direct cause of an exception. In practice, they seem expressive enough to cover most of the cases where they are most appropriate.

10 Likes