
On Wed, Sep 30, 2015 at 12:49 PM, Eric V. Smith <eric@trueblade.com> wrote:
self.x = x if x is not None else [] self.x = x otherwise []
I'm -1 on needing syntax for this, but if we're going to do it, this is my favorite version I've seen so far. The usual caveats about adding a keyword apply.
Also feel this is the most intuitive... every other syntax seems really hard to read, however, the caveat I am thinking here is synonym of else and otherwise. We really should go any more complex. Those ? and null with/without exception seems awfully complex to reason. I'd spell out 10 lines if I had to. If fact, is it bad if we make else working for such brevity? BTW, this syntax just defeats the example in the PEP: [PEP 0505 - https://www.python.org/dev/peps/pep-0505/] This particular formulation has the undesirable effect of putting the
operands in an unintuitive order: the brain thinks, "use data if possible and use [] as a fallback," but the code puts the fallback * before * the preferred value.
John