[Python-ideas] PEP 531: Existence checking operators

Nick Coghlan ncoghlan at gmail.com
Sat Oct 29 01:03:22 EDT 2016


On 29 October 2016 at 01:46, Ryan Gonzalez <rymg19 at gmail.com> wrote:
> On Oct 28, 2016 3:30 AM, "Nick Coghlan" <ncoghlan at gmail.com> wrote:
>> *snip*
>> 4. Do we collectively agree that "?then" and "?else" would be
>> reasonable spellings for such operators?
>
> Personally, I find that kind of ugly. What's wrong with just ? instead of
> ?else?

When you see the expression "LHS ? RHS", there's zero indication of
how to read it other than naming the symbol: "LHS question mark RHS".

By contrast, "LHS ?then RHS" and "LHS ?else RHS" suggest the
pronunciations "LHS then RHS" and "LHS else RHS", which in turn are
potentially useful mnemonics for the full expansions "if LHS exists
then RHS else LHS" and "LHS if LHS exists else RHS". (Knowing that "?"
indicates an existence check is still something you'd have to learn,
but even without knowing that, the keywords could get you quite some
way towards correctly understanding what the construct means)

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia


More information about the Python-ideas mailing list