On Tue, May 26, 2020 at 8:06 AM Paul Sokolovsky <pmis...@gmail.com> wrote:
>
> Hello,
>
> The more worrying sounds the idea to have a special evaluation context
> for specially marked default arguments. Just imagine - *everywhere* (#1)
> in the language the evaluation is eager, while for specially marked
> default arguments it's deferred. Which leads to the situation that:
>
>         def foo(x := a + b)
>
> vs
>
>         c = a + b
>         def foo(x := c)
>
> can lead to different results.

def foo(x = None):
    if x is None: x = a + b

c = a + b
def foo(x = None):
    if x is None: x = c

Is it surprising that these behave differently? You are refactoring
something from a late-bound default argument value into a global
variable. Surely it's obvious that it will now be evaluated once?

> I'd suggest that people should love "explicit is better than implicit"
> principle of the language.

Explicit meaning that you need to use a specific symbol that means
"this is to be late-bound"?

Or explicit meaning "something that I like", as opposed to implicit
meaning "something that I don't like", which is how most people seem
to interpret that line of the Zen?

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

Reply via email to