[Python-ideas] PEP 505 (None coalescing operators) thoughts
abarnert at yahoo.com
Wed Sep 30 20:39:04 CEST 2015
On Sep 30, 2015, at 09:41, Jeff Hardy <jdhardy at gmail.com> wrote:
> I actually really like 'otherwise', but it's certainly not brief:
> self.x = x if x is not None else 
> self.x = x otherwise 
> That said, it's not used *that* often either, so maybe it's acceptable.
The big problem with "otherwise", "orelse", or anything else that's a synonym of "or" is that it's a synonym of "or". There is nothing to tell the novice, or the sometime Python user who's just come back from 3 months with Ruby or Objective C or whatever, which one means a falsey check and which one means a None check. They both read the same in English, and the difference would be unique to Python rather than a general programming thing.
So you'd end up with hundreds of articles and blog posts explaining, often poorly, the difference and when to use each--just as you see for == vs. ===, eq vs. eql, etc. in other languages.
More information about the Python-ideas