
I don’t like the => syntax for delayed default argument. It looks like a lambda and it’s confusing. The @ symbol is more readable. Like this @var=len(a) or even var@=len(a). The function decorator changes the behavior of the function. Similarly this @ default argument will change the argument value to this assignment if a value is not supplied. Abdulla Sent from my iPhone
On 25 Oct 2021, at 1:03 PM, Chris Angelico <rosuav@gmail.com> wrote:
On Mon, Oct 25, 2021 at 7:51 PM Barry Scott <barry@barrys-emacs.org> wrote:
Clarification please:
What is the bytecode that will be generated?
Equivalent to:
if argument not provided: argument = <expr>
except that we don't have a way of saying "not provided".
Does the bytecode only run the default code if the argument is missing?
Yes. It is for default values, not for transforming.
And missing is not the same as is None?
Most assuredly not - that's part of the point. The semantics are closer to the "dedicated sentinel" idiom, but there is no value which can be passed which triggers this.
Also have you add the @var=default suggestion from Stephen to the syntax options. I'm +1 on the @ syntax as it is easier to pick up on and the other reasons that Stephen provided.
Not really a fan, but I guess I can add it as an alternative.
ChrisA _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-leave@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/NLAYWM... Code of Conduct: http://python.org/psf/codeofconduct/