Super Tuples
Skip Montanaro
skip at mojam.com
Tue Dec 28 09:08:56 EST 1999
Paul> Unreadable tuple-based code like this:
Paul> j = mytuple[11]
Paul> Of course the usual way to work around this is to do this:
Paul> j = mytuple[someconstantpool.someconstant]
Paul> But now you have to memorize the location of the constant pool (if
Paul> available!) and your execution is slowed by all of the lookups.
Ah, what you want are the equivalent of C's enumerated types. Why not
abstract that into a distinct feature so you can use the same technique with
lists and dicts?
>> What's the result of
>>
>> time = (hour=24, minute=00, second=00)
>> point = (x=1, y=2, z=3)
>>
>> time = point
Paul> "time" is an alias for "point"! Python doesn't do type checking of
Paul> assignments. It doesn't matter whether time and point are tuples,
Paul> super-tuples, classes or integers.
Yes, I realized that shortly after hitting "send".
Skip Montanaro | http://www.mojam.com/
skip at mojam.com | http://www.musi-cal.com/
847-971-7098 | Python: Programming the way Guido indented...
More information about the Python-list
mailing list