20 Sep
2015
20 Sep
'15
9:38 a.m.
On Sun, Sep 20, 2015 at 5:31 PM, Steven D'Aprano
Technically, x.y x[y] and x(y) aren't operators, but for the sake of convenience I'll call them such. Even though these are binary operators, the ? only shortcuts according to the x, not the y. So we can call these ?. ?[] ?() operators "pseudo-unary" operators rather than binary operators.
That's how all Python's short-circuiting works - based on the value of what's on the left, decide whether or not to evaluate what's on the right. (Well, nearly all - if/else evaluates the middle first, but same difference.) This is another form of short-circuiting; "x[y]" evaluates x, then if that's None, doesn't bother evaluating y because it can't affect the result. ChrisA