Why does not Python accept functions with no names?

Eryk Sun eryksun at gmail.com
Mon Feb 21 02:35:17 EST 2022


On 2/20/22, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
>
> BTW, this is not what is usually meant by the term "anonymous
> function". An anonymous function is one that is not bound
> to *any* name. The thing you're proposing wouldn't be
> anonymous -- it would have a name, that name being the empty
> string.

Sorry. I read Avi's reply first, scanned the original post and didn't
consider the literal question. I doubt that Python would have become a
popular language if it allowed the empty string as an identifier. That
would let common syntax errors slip past the compiler with useless
results, e.g `= 1`, `c. = 1`. It's no less absurd in a `def`
statement.


More information about the Python-list mailing list