Death to tuples!

Bengt Richter bokr at oz.net
Tue Nov 29 05:41:13 EST 2005


On 27 Nov 2005 23:33:27 -0800, "Dan Bishop" <danb_83 at yahoo.com> wrote:

>Mike Meyer wrote:
>> It seems that the distinction between tuples and lists has slowly been
>> fading away. What we call "tuple unpacking" works fine with lists on
>> either side of the assignment, and iterators on the values side. IIRC,
>> "apply" used to require that the second argument be a tuple; it now
>> accepts sequences, and has been depreciated in favor of *args, which
>> accepts not only sequences but iterators.
>>
>> Is there any place in the language that still requires tuples instead
>> of sequences, except for use as dictionary keys?
>
>The % operator for strings.  And in argument lists.
>
>def __setitem__(self, (row, column), value):
>   ...
>
Seems like str.__mod__ could take an arbitary (BTW, matching length, necessarily?
Or just long enough?) iterable in place of a tuple, just like it can take
an arbitrary mapping object in place of a dict for e.g. '%(name)s'% {'name':'<name value>'}

Regards,
Bengt Richter



More information about the Python-list mailing list