Style qeustion: Multiple return values
Dan Stromberg
drsalists at gmail.com
Mon Apr 12 12:54:13 EDT 2021
On Mon, Apr 12, 2021 at 1:30 AM Steve Keller <keller.steve at gmx.de> wrote:
> Just a short style question: When returning multiple return values, do
> you use parenthesis?
>
> E.g. would you write
>
> def foo():
> return 1, 2
>
> a, b = foo()
>
> or do you prefer
>
> def foo():
> return (1, 2)
>
> (a, b) = foo()
>
I prefer the parens; it's too easy to miss a comma when reading. The
parentheses make it more clear that you're looking at a tuple.
pycodestyle and pylint don't appear to care one way or the other.
More information about the Python-list
mailing list