[Python-ideas] PEP 505: None-aware operators
Rhodri James
rhodri at kynesim.co.uk
Mon Jul 30 09:54:04 EDT 2018
On 28/07/18 21:07, Abe Dillon wrote:
[>> = Me]
>> We could argue about how intuitive or not these operators are, but they
>> are used in other languages, so they clearly aren't completely unintuitive.
>
> Other languages are other languages. Other languages use the "<condition> ?
> <expr_a> : <expr_b>" form of the the ternary operator. That doesn't mean we
> should adopt that into Python.
But it does and did mean that we should consider it when coming up with
Python's version of the ternary operator. *It isn't unintuitive* and
neither is ?? None-aware operators may be bad for other reasons, but
that argument doesn't wash.
>> Really? Quick straw poll: how often do people care how in-place operators
>> are implemented?
>
> The point I was trying to make is that it doesn't behave or compose like
> other expressions.
(This was about ??=, for context.) Pardon? It composes exactly like
any other in-place operator.
[Abe previously wrote:]
>>> val = person[0]?
>>> val = person.name?
>>
>> Um. How is that supposed to parse? "person[0]" has already been evaluated
>> by the time the "?" operator gets anywhere near it.
>
> It parses by placing the '?' operator high in the order of operations; like
> I said. Do I really need to explain how order of operations works?
Apology elsewhere accepted, but yes, you do need to explain how merely
being high precedence helps here. Let's start small; please explain
programmatically what
name?
does as an expression. Once we have that down, we can move on to
person.(name?)
(parentheses for emphasis.) Short of actual magic, I can't see how this
is going to work.
--
Rhodri James *-* Kynesim Ltd
More information about the Python-ideas
mailing list