In article <[EMAIL PROTECTED]>, Grant Edwards <[EMAIL PROTECTED]> wrote:
> On 2004-12-29, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > > Tuples are defined with regards to parentheses ()'s as everyone knows. > > Except they're not. > > >>> x = 1,2,3,4 > >>> type(x) > <type 'tuple'> > >>> > > Tuples are defined by the infix comma "operator". Well, the syntax is a little more complicated than that. Commas don't form tuples in a lot of places: f (1, 2, 3) # function call gets three scalar arguments [1, 2, 3] # list of three integers, not list of tuple [x, 1 for x in blah] # syntax error, needs to be [(x, 1) for ...] I'm sure there are others. The meaning of "," depends on the context in which it appears. In most cases, the parens around tuples are optional except when necessary to disambiguate, but there's one degenerate special case, the empty tuple (zerople?), where the parens are always required. It's just one of those little warts you have to live with. If Python had originally been invented in a unicode world, I suppose we wouldn't have this problem. We'd just be using guillemots for tuples (and have keyboards which made it easy to type them). -- http://mail.python.org/mailman/listinfo/python-list