[Python-Dev] What's the status of PEP 505: None-aware operators?

Steve Holden steve at holdenweb.com
Fri Dec 1 07:01:01 EST 2017


On Fri, Dec 1, 2017 at 10:31 AM, Steven D'Aprano <steve at pearwood.info>
wrote:

> On Thu, Nov 30, 2017 at 11:54:39PM -0500, Random832 wrote:
>
> > The OP isn't confusing anything; it's Eric who is confused. The quoted
> > paragraph of the PEP clearly and unambiguously claims that the sequence
> > is "arguments -> function -> call", meaning that something happens after
> > the "function" stage [i.e. a None check] cannot short-circuit the
> > "arguments" stage. But in fact the sequence is "function -> arguments ->
> > call".
>
> I'm more confused than ever. You seem to be arguing that Python
> functions CAN short-circuit their arguments and avoid evaluating them.
> Is that the case?
>
> If not, then I fail to see the difference between
>
> "arguments -> function -> call"
>
> "function -> arguments -> call"
>
> In *both cases* the arguments are fully evaluated before the function is
> called, and so there is nothing the function can do to delay evaluating
> its arguments.
>
> If this is merely about when the name "function" is looked up, then I
> don't see why that's relevant to the PEP.
>
> What am I missing?
>
> ​I guess it's possible that if computing the function (i.e., evaluating
the expression immediately to the left of the argument list) and/or the
argument has side effects​

​then the evaluation order will affect the outcome. Intuitively it seems
more straightforward to compute the function first. If this expression were
to raise an exception, of course, then the arguments would not then be
evaluated. Or vice versa. It would be best of the specification matches
current CPython bahviour.
​
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20171201/d6ff2f8c/attachment.html>


More information about the Python-Dev mailing list