[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Syntax for one-line "nonymous" functions in "declaration style"

On Sat, Mar 30, 2019, 5:32 AM Alexey Muranov <alexey.muranov at>

> On ven., Mar 29, 2019 at 4:51 PM, python-list-request at wrote:
> >
> > There could perhaps be a special case for lambda expressions such
> >  that,
> > when they are directly assigned to a variable, Python would use the
> > variable name as the function name. I expect this could be
> >  accomplished by
> > a straightforward transformation of the AST, perhaps even by just
> >  replacing
> > the assignment with a def statement.
> If this will happen, that is, if in Python assigning a lambda-defined
> function to a variable will mutate the function's attributes, or else,
> if is some "random" syntactically-determined cases
>     f = ...
> will stop being the same as evaluating the right-hand side and
> assigning the result to "f" variable, it will be a fairly good extra
> reason for me to go away from Python.

Is there a particular reason you don't like this? It's not too different
from the syntactic magic Python already employs to support the 0-argument
form of super().