Why does not Python accept functions with no names?

Barry barry at barrys-emacs.org
Sun Feb 20 11:21:33 EST 2022



> On 20 Feb 2022, at 15:35, Abdur-Rahmaan Janhangeer <arj.python at gmail.com> wrote:
> 
> Greetings list.
> 
> Out of curiosity, why doesn't Python accept
> def ():
>    return '---'
> 
> ()
> 
> Where the function name is ''?

Because there is no variable that is holding a ref to the code.
So it’s pointless.


Barry

> 
> Kind Regards,
> 
> Abdur-Rahmaan Janhangeer
> about <https://compileralchemy.github.io/> | blog
> <https://www.pythonkitchen.com>
> github <https://github.com/Abdur-RahmaanJ>
> Mauritius
> -- 
> https://mail.python.org/mailman/listinfo/python-list
> 



More information about the Python-list mailing list