It gets frustrating when people demand too much when strictly speaking, it
is not really needed or may cause new problems.

How often do you really think anyone out there NEEDS to define a function in
the context mentioned?

You provided a way to create an anonymous function and that was not enough.
I wonder if you could throw in the new := walrus operator to similarly make
a named lambda function in a similar way. 

And, in any case, you can make a function factory that returns a function
and call that function with appropriate arguments that might then create a
wide variety of functions by doing the def within.

Languages are tools and need not be the end-all for all people. You do not
want the language to get so complex that programmers do not have any idea
what valid code does. Consider the mess in multiple inheritance and trying
to figure out which of many classes will be the one where a method is
finally called using some diamond algorithm. It is both extremely powerful
but also silly to overuse such features.


-----Original Message-----
From: Python-list <> On
Behalf Of Chris Angelico via Python-list
Sent: Sunday, January 14, 2024 8:34 AM
Subject: Re: Extract lines from file, add to new files

On Mon, 15 Jan 2024 at 00:27, Left Right <> wrote:
> > What do you mean?
> >
> > for x in lambda: ...:
> >   ...
> >
> > Perfectly grammatical.
> 1. You put the lambda definition in the wrong place (it should be in
> the left-hand side, or as Python calls it "star_targets", but you put
> it into "star_expressions", which would be where the right-hand side
> is drawn from).
> 2. You used what Python calls "lambdadef" in place of what Python
> calls "function_def". I.e. lambda definition and function definition
> are two different things, at least as far as grammar is considered.
> So, you solved a different problem.

You said function. I made a function. You said "head of a for loop
clause". I put it there. Problem was underspecified.

But if you're trying to tell me that a def statement should be a valid
assignment target, I don't know what you're smoking, but I want you to
keep it a long way away from me. Can you name ANY language in which
that would make the slightest bit of sense?



Reply via email to