|
|
|
|
|
by bionoid
1796 days ago
|
|
Python also has "shorthand ternary" which uses and/or: a = bar and foo # "or None" is implied
b = bar and foo or baz
It does almost the same but not quite. In the latter example, if foo is falsey, it evaluates to "b = baz": b = bar ? (foo ? foo : baz) : baz
|
|
https://docs.python.org/3/reference/datamodel.html#emulating...
It's not made clear here that I can see. Grr, needs type annotations!