[Python-ideas] PEP 505 (None coalescing operators) thoughts

Andrew Barnert abarnert at yahoo.com
Mon Sep 28 19:24:43 CEST 2015


On Sep 28, 2015, at 09:47, Sven R. Kunze <srkunze at mail.de> wrote:
> 
>> On 28.09.2015 18:37, Steven D'Aprano wrote:
>>> On Mon, Sep 28, 2015 at 06:11:45PM +0200, Sven R. Kunze wrote:
>>> 
>>> That sums it all up for me as well, though I would rather use "else"
>>> instead of "or?" (see punctuation-heavy).
>> `else` is ambiguous. Consider:
>> 
>>     result = spam if eggs else cheese else aardvark
>> 
>> could be interpreted three ways:
>> 
>>     result = (spam if eggs else cheese) else aardvark
>>     result = spam if (eggs else cheese) else aardvark
>>     result = spam if eggs else (cheese else aardvark)
>> 
>> Whichever precedence you pick, some people will get it wrong and it will
>> silently do the wrong thing and lead to hard-to-diagnose bugs. Using
>> "else" for this will be a bug-magnet.
> 
> I wouldn't make a mountain out of a molehill. Other existing operators have the same issue.

Which other keywords or symbols may be either a binary operator or part of a ternary operator depending on context?
> 
> 
> Best,
> Sven
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/


More information about the Python-ideas mailing list