[issue43021] Unpacking tuple argument in combination with inline if statement
Steven D'Aprano
report at bugs.python.org
Mon Jan 25 04:31:35 EST 2021
Steven D'Aprano <steve+python at pearwood.info> added the comment:
This is a operation precedence issue.
The line:
t0, t1 = t if t is not None else [], []
is parsed as:
(t if t is not None else []), []
so you need brackets around the "else" operand to get the effect you want.
t0, t1 = t if t is not None else ([], [])
----------
nosy: +steven.daprano
resolution: -> not a bug
stage: -> resolved
status: open -> closed
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue43021>
_______________________________________
More information about the Python-bugs-list
mailing list