allowing braces around suites

Roy Smith roy at
Sat Aug 28 17:14:14 CEST 2004

In article <41309d32$0$65611$a1866201 at>,
 Grant Edwards <grante at> wrote:

> Because so many people at first think that parens construct
> tuples the way square-brackets and curly-brackets construct
> lists. When in reality it's commas that construct tuples, but
> only in certain contexts because commas are used for about
> three other purposes as well.
> [...]
> IMO, the only non-ugly, non-hack solution would be to have
> another set of delimters that are used as tuple-constructors so
> that the syntax for a literal tuple, a literal list, and a
> literal dictionary are consistent.

I agree.  It's even uglier that "," doesn't form a zero-length tuple.  
Thus you get:

tuple0 = ()
tuple1 = 1,

So, is it parens that form tuples, or commas?  I guess There's More Than 
One Way To Do It :-)

My personal choice would have been angle brackets, i.e. <1, 2, 3>.  
Then, <1> would have been a length-1 tuple with no ambiguity.

tuple0 = <>
tuple1 = <1>
tuple2 = <1, 2>

But it's way too late for that now.  Maybe in P3K?

More information about the Python-list mailing list