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

Nick Timkovich prometheus235 at gmail.com
Thu Nov 30 15:34:51 EST 2017

On Thu, Nov 30, 2017 at 12:24 PM, Brett Cannon <brett at python.org> wrote:

> On Wed, 29 Nov 2017 at 13:28 Greg Ewing <greg.ewing at canterbury.ac.nz>
> wrote:
>> Nick Coghlan 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".
>> How about:
>>     x otherwise y
>> It looks different enough from "or" that you're not going
>> to accidentally read it that way when skimming.
>> The meaning is something you'll have to learn if you don't
>> know, but at least it's a word that can be googled for.
>  In terms of syntax, this is my favourite one so far.

Was the issue that "or else" looks too similar or looks too similar but
acts very different? I'm interpreting the behavior like a(n ab)use of "or",
just where it's looking for None. Am I overlooking some conditions?

x = False
y = 'something'
x or y # 'something'

x or else y # False
x = None
x or else y # 'something'

Overlooking 'else' when reading would be surprising, though might be a
source of confusion for newcomers when "x or else y" and "x or y" usually
act identically, kinda like "x == y" and "x is y" (for small integers).

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20171130/c0854add/attachment.html>

More information about the Python-ideas mailing list