Why tuples use parentheses ()'s instead of something else like <>'s?

John Roth newsgroups at jhrothjr.com
Wed Dec 29 09:05:32 EST 2004


<seberino at spawar.navy.mil> wrote in message 
news:1104299822.394489.161500 at z14g2000cwz.googlegroups.com...
> Tuples are defined with regards to parentheses ()'s as everyone knows.

To expand on what Alex Martelli said:

Tuples don't use parentheses except for the special case of the
empty tuple. Those are expression parentheses. The two most
obvious cases of this are in the return statement and sequence
unpacking in assignment statements.

Grouping syntax is used for both unary operators and operands.
Parentheses are used for expressions (operands) and
function/method parameter lists (operators). Brackets ([])
are used for lists (operands) and subscripts/slices (operators).
Braces ({}) are used for dictionarys (operands). They aren't
currently used for unary operators.

John Roth

> Please enlighten me as I really want to know.
> Chris
>
> P.S. I love Python!
> 




More information about the Python-list mailing list