[Python-ideas] PEP 505: None-aware operators

Jonathan Fine jfine2358 at gmail.com
Wed Aug 1 03:29:41 EDT 2018


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.
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').

I would like to know if my answers to my questions are correct, and if
not please may I be given correct answers. Thank you in advance.

-- 
Jonathan


More information about the Python-ideas mailing list