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

Paul Moore p.f.moore at gmail.com
Wed Nov 29 08:06:14 EST 2017


On 29 November 2017 at 12:41, Nick Coghlan <ncoghlan at gmail.com> wrote:
> On 29 November 2017 at 22:38, Stephan Houben <stephanh42 at gmail.com> wrote:
>> What about more English-like syntax:
>>
>> X or else Y
>
> The problem with constructs like this is that they look like they
> should mean the same thing as "X or Y".

Keyword based and multi-word approaches also break down much faster
when you get more terms.

    X or else Y

looks OK (ignoring Nick's comment - I could pick another keyword-based
proposal, but I'm too lazy to look for one I like), but when you have
4 options,

    X or else Y or else Z or else W

the benefit isn't as obvious. Use lower-case and longer names

    item_one or else item_two or else list_one[the_index] or dict_one['key_one']

and it becomes just a muddle of words.

Conversely, punctuation-based examples look worse with shorter
variables and with expressions rather than identifiers:

    item_one ?? item_two ?? another_item ?? one_more_possibility

vs

    x ?? y[2] ?? kw['id'] ?? 3 + 7

IMO, this is a case where artificial examples are unusually bad at
conveying the actual feel of a proposal. It's pretty easy to turn
someone's acceptable-looking example into an incomprehensible mess,
just by changing variable names and example terms. So I think it's
critically important for any proposal along these lines (even just
posts to the mailing list, and definitely for a PEP), that it's argued
in terms of actual code examples in current projects that would
reasonably be modified to use the proposed syntax. And people wanting
to be particularly honest in their proposals should probably include
both best-case and worst-case examples of readability.

Paul

PS Also, I want a pony. (I really do understand that the above is not
realistic, but maybe I can hope that at least anyone writing a PEP
take it into consideration :-))


More information about the Python-ideas mailing list