What is the syntax rule for having trailing commas in tuple definitions?

前端 未结 10 1467
被撕碎了的回忆
被撕碎了的回忆 2020-11-22 05:54

In the case of a single element tuple, the trailing comma is required.

a = (\'foo\',)

What about a tuple with multiple elements? It seems t

10条回答
  •  旧巷少年郎
    2020-11-22 06:42

    Coding style is your taste, If you think coding standard matters there is a PEP-8 That can guide you.

    What do you think of the result of following expression?

    x = (3)
    x = (3+2)
    x = 2*(3+2)
    

    Yep, x is just an number.

提交回复
热议问题