On 27/10/2021 00:50, Chris Angelico wrote:
On Wed, Oct 27, 2021 at 10:38 AM Rob Cliffe <rob.cli...@btinternet.com> wrote:

There has been support for evaluating all early-bound defaults before
all late-bound defaults.  I have been persuaded that this is a
reasonable option.  AFAICS there would be little practical difference
from straight left-to-right evaluation of defaults, since assigning an
early-bound default should not have a side effect.  So it could even be
an implementation choice.
If it's an implementation choice, then it'll mean that code is legal
on some interpreters and not others. Whether that's a major problem or
not I don't know, but generally, when you can't depend on your code
working on all interpreters, it's not best practice (eg
"open(fn).read()" isn't recommended, even if it happens to close the
file promptly in CPython).

ChrisA
I guess I wasn't clear.  I'm not sure if you understood what I meant to say, or not.
First I should have said "binding" rather than "evaluating".
What I meant was that in cases like
    def f(a=earlydefault1, b:= latedefault2, c=earlydefault3, d:=latedefault4):
it makes no real difference if the bindings are done in the order
    a, c, b, d (early ones before late ones)
or
    a, b, c, d (strict left-to-right)
since binding an early default should have no side effects, so (I thought, wrongly) it could be an implementation detail. Of course there IS a difference: it allows late default values to refer to subsequent early default values, e.g. in the example above `latedefault2' could refer to `c`.  So yes, then that code would be legal on some interpreters and not others, as you said.  If you understood exactly what I meant, I apologise.
Rob Cliffe
_______________________________________________
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/7GKSZEUZG3O66T5CDU3YL67B6QYF2KHZ/
Code of Conduct: http://python.org/psf/codeofconduct/

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

Reply via email to