tuples, index method, Python's design

Hendrik van Rooyen mail at microcorp.co.za
Sat Apr 14 02:19:36 EDT 2007


 "Donn Cave" <donn at u.washington.edu> wrote:

> 
> Well, yes - consider for example the "tm" tuple returned
> from time.localtime() - it's all integers, but heterogeneous
> as could be - tm[0] is Year, tm[1] is Month, etc., and it
> turns out that not one of them is alike.  The point is exactly
> that we can't discover these differences from the items itself -
> so it isn't about Python types - but rather from the position
> of the item in the struct/tuple.  (For the person who is about
> to write to me that localtime() doesn't exactly return a tuple:  QED)

This is the point where the whole thing falls apart in my head and 
I get real confused - I can't find a reason why, list or tuple, the first
item can't be something, the second something else, etc...

About the only reason you would use a tuple is if you want to
use it as a key to a dict - and then only because you have to, 
you can't use a list as the language stands.

- Hendrik




More information about the Python-list mailing list