On Nov 11, 2006, at 10:52 AM, Carl Karsten wrote:

> not to mention I still don't
> understand the difference between [1,2,3] and (1,2,3)  even though  
> I understand
> how to use them.

        On the practical side, one is mutable and the other is fixed. If you  
have a set of things that you need to add to, remove from, or  
otherwise manipulate, use a list. Otherwise, use a tuple. Tuples have  
much lower overhead.

        The theoretical difference is more of a mathematical distinction  
rather than a practical one. Remember, the BDFL is a mathematician.  
He sees it as the difference between well-defined groupings and ad- 
hoc collections of things. Consider a point in cartesian space: it is  
defined by x-y-z coordinates. That would be best represented as a 3- 
tuple. All such points have the same structure, and each position in  
the tuple has a defined meaning. It makes no sense for such a tuple  
to have an append() or remove() method, since by definition a point  
in space is defined by those three numbers. And it makes no sense to  
allow those values to change, because then it would no longer be the  
same point.

        However, a collection of things that is arbitrary is best  
represented as a list. Let's take the people who will be at next  
Tuesday's meeting. It is not defined in advance; people can show up  
late or leave early, so it is expected that at any time, that group  
will change. A list makes much more sense in this case.

        Again, this is mostly theoretical; if you're not sure, use a list -  
they are much more practical, and RAM and CPU cycles are cheap.

-- Ed Leafe
-- http://leafe.com
-- http://dabodev.com



_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users

Reply via email to