Death to tuples!
mwm at mired.org
Wed Nov 30 00:27:55 CET 2005
Duncan Booth <duncan.booth at invalid.invalid> writes:
> Dan Bishop wrote:
>>> 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):
> Don't forget the exception specification in a try..catch statement:
>> An object is compatible with an exception if it is either the object
>> that identifies the exception, or (for exceptions that are classes) it
>> is a base class of the exception, or it is a tuple containing an item
>> that is compatible with the exception.
> Requiring a tuple here means that the code doesn't have to worry about a
> possible recursive data structure.
except ExceptType1, (ExceptType2, ExceptType3, (ExceptType4, ExceptType5):
I suspect this won't work, but meets the description.
Lists could be used here with the same restrictions as tuples.
Mike Meyer <mwm at mired.org> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
More information about the Python-list