On 4/12/2021 4:29 AM, Steve Keller 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()

No.  Parentheses are for grouping (and separation from surrounding code).
() and (1,) (can be though of as) group(ing) the a zero-width space and one-comma pair respectively and separate them from the rest of the code.

--
Terry Jan Reedy

--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to