[Tutor] function return values
Sibylle Koczian
nulla.epistola at web.de
Sat Dec 4 07:46:40 EST 2021
Am 03.12.2021 um 21:46 schrieb Cameron Simpson:
>
> Fascinating. I did not expect this!
>
> On consideration, this will only confuse people coming from C, who might
> think "oh I need brackets around the condition" and write:
>
> >>> if (1, 2 == 3, 4):
> ... print(1)
> ...
> 1
>
> In Python 3.8 I get this:
>
> >>> if 1, 2 == 3, 4:
> File "<stdin>", line 1
> if 1, 2 == 3, 4:
> ^
> SyntaxError: invalid syntax
>
> which does suggest the commas as the issue, not a missing opening
> bracket, but still...
>
Still shorter:
>>> if 1, 2: print("ja")
File "<stdin>", line 1
if 1, 2: print("ja")
^
SyntaxError: invalid syntax
>>> if (1, 2): print("ja")
...
ja
Python 3.10, that's probably unimportant.
More information about the Tutor
mailing list