On Mon, Jul 4, 2016 at 9:56 PM, Danny Yoo <d...@hashcollision.org> wrote:
> So the extra trailing comma in a 1-tuple parenthesized expression is
> just there to make it different looking, to disambiguate it from the
> use of parentheses for expression grouping.

The comma is the distinguishing element of non-empty tuple literals.
It's always required in order to create a non-empty tuple, with or
without brackets. For example:

    >>> 27,
    (27,)

The parentheses are optional for a non-empty tuple, but they're often
required because a comma has low precedence. For example, with the
expression `x in y, z`, Python first evaluates `x in y`. If the goal
is to check whether x is in the the tuple `y, z`, then it has to be
written `x in (y, z)`.
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to