On Wed, Aug 1, 2018 at 5:29 PM, Jonathan Fine <jfine2...@gmail.com> wrote:
> Hi All
>
> I have two further questions. I'm keen to clarify what is the
> behaviour specified by PEP 505. I'm not, at this time, interested in
> why and how PEP 505 specifies behaviour. I just wish, through explicit
> examples, to clarify the behaviour that is specified.
>
> Here 'a' is an identifier. Consider the following 12 expressions (I
> use the word loosely).
>
> 1) a . b . c
> 2) (a . b) . c
> 3) a . (b . c)
>
> 4) a ?. b . c
> 5) (a ?. b) . c
> 6) a ?. (b . c)
>
> 7) a . b ?. c
> 8) (a . b) ?. c
> 9) a . (b ?. c)
>
> 10) a ?. b ?. c
> 11) (a .? b) ?. c
> 12) a ?. (b ?. c)
>
> Question A: Which of the expressions are NOT valid (Python + PEP 505) syntax?
> Question B: Which of the valid (Python + PEP 505) expressions are
> equivalent, for all possible values of 'a'.
>
> The answer depends, of course, on the exact text of PEP 505. I've not
> read PEP 505 that closely. My expectations, based on my Python
> experience, are that PEP 505 would be written so that:
>
> Answer A: Expressions 3, 6, 9 and 12 are invalid. The others are valid.

Correct. After a dot (whether ?. or plain . ), you need a NAME, not
any form of expression (test, expr, etc).

> Answer B: 1 and 2 are equivalent. Similarly 4 and 5. Similarly 7 and
> 8. Similarly 10 and 11. There are no other equivalences (for all
> values of 'a').

Incorrect. The short-circuiting behaviour ends at any sort of
grouping. It's like how "a < b < c" is not equivalent to "(a < b) <
c", nor to "a < (b < c)".

ChrisA
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to