On Sat, Dec 24, 2022 at 11:34:19AM -0500, Shironeko wrote:
> 
> Is the => syntax needed? as far as I can think of, the only time where 
> late evaluation is needed is when the expression references the other 
> arguments.

You are missing the most common case, the motivating case, for 
late-bound defaults: mutable defaults.

    def spam(x, y=>[]):
        pass

Here the intention is to have y's default be a *different* list each 
time you call spam(x), instead of the same list each time.

The ability for default values to refer to other parameters is a Nice To 
Have, not a Must Have. It has been a very long time since I have read 
the PEP, and I don't remember whether it reviews other languages to see 
what functionality they provide for defaults, but I don't think many 
other languages allow you to set the default of one parameter to be 
another parameter.


-- 
Steve
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/HS7WJGA4CROKOCVVIECEXBNKEFOBQ3LQ/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to