List vs tuples

Shalabh Chaturvedi shalabh at cafepy.com
Fri Apr 9 20:40:22 EDT 2004


John Roth wrote:

> 
> "Isaac To" <kkto at csis.hku.hk> wrote in message
> 
>> If getTime() give you a list instead, then [hours, minute, second] =
>> getTime() would still give you the hours, minute and second variables
>> assigned.
> 
> True. Again, so what? The basic conceptual issue, which
> Don Cave explained much better than I did, is that any
> subsequence of a list is of the same *conceptual* type as the
> list itself. A subset of the fields of a struct is not of the same
> conceptual type as the original struct. You cannot take the
> third element of that time tuple and claim it is the same type
> (a time of day) as the original.


Hmm...so lists are like ham. Slice it up, dice it up, and you still have
ham. Whereas tuples are more like eggs. Break it and you end up with some
pieces of shell, some yolk, some white and probably a big mess.

Also, if you wanted more ham in your sandwitch, just add another slice and
now you have a 'bigger' piece of ham. But if you wanted a bigger egg, you'd
have to start out.. oh well this is going too far :)

Enjoy!
Shalabh





More information about the Python-list mailing list