Super Tuples
Paul Prescod
paul at prescod.net
Tue Dec 28 04:02:04 EST 1999
Skip Montanaro wrote:
>
> ...
>
> Hmm. Attributes, but no methods? Why doesn't the current class notion
> solve the problem?
Class instances are not tuples. If you use tuples in your code then you
know that they have virtues that instances do not.
> In fact, I'm not sure what the problem you're trying to
> solve is.
Unreadable tuple-based code like this:
j = mytuple[11]
Of course the usual way to work around this is to do this:
j = mytuple[someconstantpool.someconstant]
But now you have to memorize the location of the constant pool (if
available!) and your execution is slowed by all of the lookups.
> What's the result of
>
> time = (hour=24, minute=00, second=00)
> point = (x=1, y=2, z=3)
>
> time = point
"time" is an alias for "point"! Python doesn't do type checking of
assignments. It doesn't matter whether time and point are tuples,
super-tuples, classes or integers.
Paul Prescod
More information about the Python-list
mailing list