Why not real anonymous functions?

The one use-case that I would have for this is UI creation. This is something that has ALWAYS been horribly clunky in Python, no matter which UI library is involved. Most often, it requires a lot of completely unnecessary intermediate variables, solely because Python’s syntactic structure requires it. That means naming things that don’t really need names.

With inline multi-statement functions, the structure of the code could directly mirror the structure of the window, instead of having to define a bunch of terms and then use them, forcing you to read up and down and all over the place to figure out what’s going on.

That said, though: this is NOT a strong use-case. Even with multi-statement inline functions, this kind of code would be awful and clunky. There are probably better ways than building a UI in code. It’s just that I’ve never found any that I’m happy with.

7 Likes