On Mon, 26 Dec 2022 at 10:02, <shironeko.pyt...@tesaguri.club> wrote:
>
> I didn't realize def foo(x, y=[]) had this strange artifact but it totally 
> makes sense, TIL. I did not get the right idea reading the PEP though, since 
> currently the motivation reads:
>
> > Optional function arguments, if omitted, often have some sort of logical 
> > default value. When this value depends on other arguments, or needs to be 
> > reevaluated each function call, there is currently no clean way to state 
> > this in the function header.
>
> and I kinda glossed over the second use-case. I feel like more emphasis can 
> be added since that part is what necessitates the new syntax.
>
> I do think that being able to reference other arguments is very useful in 
> it's own right and would go a long way in helping to solve the None check 
> problem brought up in PEP 505 even more cleanly.

Yeah, they're both useful features, and both handled by the simple
rule of "evaluate late-bound defaults in the context of the function
body".

ChrisA
_______________________________________________
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/5A5UGJDLHW66VJXWUE4S6TSFLMFZIIDC/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to