Super Tuples

Paul Prescod paul at prescod.net
Tue Dec 28 03:38:31 EST 1999


"Magnus L. Hetland" wrote:
> 
> Yes... Cleaner than
> 
>   time = {'hour':24, 'minute':00, 'second':00}
> 
> Not *much* cleaner, but a bit. Of course, the tuple would be
> immutable, though...

It is the *unpacking* that is much, much cleaner.

> >  * it aligns better with the mathematical notion of tuple
> 
> Really? I don't think so... The mathematical notion of a tuple is that
> it is an ordered set, i.e. a set where the elements each have an
> index. What does that have to do with your version?

In my experience, mathematical texts refer to the elements of a tuple by
symbolic names, not by numeric index:

"A datatype is defined as a 3-tuple, consisting of a) a set of distinct
values, called its value space, b) a set of lexical representations,
called its lexical space, and c) a set of facets that characterize
properties of the value space, individual values or lexical items." (not
exactly a mathematical text but there aren't many of them on the web)

"In this specification, a datatype is defined as a 3-tuple, consisting
of a) a set of distinct values, called its value space, b) a set of
lexical representations, called its lexical space, and c) a set of
facets that characterize properties of the value space, individual
values or lexical items. "
http://www.non.com/news.answers/larch-faq.html

Any author that says: "referring back to the 8th element in our tuple
and its relationship to the 9th (as per our discussion of the 7th)"
should be shot.

> Immutable object instances? Doesn't that go against some quite basic
> tenets of object oriented programming? <wink>

Immutability is another interesting issue. I think that the immutability
of tuples is something of a bug. If I want to change the minute in my
second tuple, I should be able to do it easily. If I want to make an
immutable *list* I should also be able to do that easily. Immutability
should be orthogonal to data structure type.

 Paul Prescod






More information about the Python-list mailing list