5.2.3 Parenthesized forms
Keywords: ref

##
5.2.3 Parenthesized forms

A parenthesized form is an optional expression list enclosed in parentheses:

  `parenth_form` | ::= | `"(" [expression_list] ")"`

  Download entire grammar as text.

A parenthesized expression list yields whatever that expression list yields: if the list contains at least one comma, it yields a tuple; otherwise, it yields the single expression that makes up the expression list.

An empty pair of parentheses yields an empty tuple object. Since tuples are immutable, the rules for literals apply (i.e., two occurrences of the empty tuple may or may not yield the same object).

Note that tuples are not formed by the parentheses, but rather by use of the comma operator. The exception is the empty tuple, for which parentheses are required -- allowing unparenthesized ``nothing'' in expressions would cause ambiguities and allow common typos to pass uncaught.