[New-bugs-announce] [issue46865] *() Invalid Syntax: iterable unpacking of empty tuple
Robert Spralja
report at bugs.python.org
Sat Feb 26 04:04:32 EST 2022
New submission from Robert Spralja <robert.spralja at gmail.com>:
`
>>> def foo(num=1):
... return num
...
>>> foo(*(bool,) is bool else *())
File "<stdin>", line 1
foo(*(bool,) is bool else *())
^
SyntaxError: invalid syntax
>>> foo(*(bool,) if bool else *())
File "<stdin>", line 1
foo(*(bool,) if bool else *())
^
SyntaxError: invalid syntax
>>> def foo(num=1):
... return num
...
>>> stri = ''
>>> foo(*(stri,) if stri else *())
File "<stdin>", line 1
foo(*(stri,) if stri else *())
^
SyntaxError: invalid syntax
>>> foo(*((stri,) if stri else ()))
1
>>>
`
Iterable unpacking of empty tuple seems to not work in one example but does in another.
----------
messages: 414085
nosy: spralja
priority: normal
severity: normal
status: open
title: *() Invalid Syntax: iterable unpacking of empty tuple
versions: Python 3.9
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue46865>
_______________________________________
More information about the New-bugs-announce
mailing list