Dave Baum <[EMAIL PROTECTED]> writes: > In article <[EMAIL PROTECTED]>, > Shafik <[EMAIL PROTECTED]> wrote: > > > what exactly is the difference between a tuple and a list? I'm > > sure there are some, but I can't seem to find a situation where I > > can use one but not the other. > > Lists and tuples are both sequences, and can be used interchangeably > in many situations. The big difference is that lists are mutable > (can be modified), and tuples are immutable (cannot be modified). > Lists also have a richer API (for example the index and count > methods).
This common misconception falls foul of only considering the implementation details. The choice of when to use one or the other is more one of intent: A tuple is best for heterogeneous sequences, a list is best for homogeneous sequences. Here's a better explanation: <URL:http://jtauber.com/blog/2006/04/15/python_tuples_are_not_just_constant_lists> -- \ "No matter how cynical I get, I can't seem to keep up." -- | `\ Lily Tomlin | _o__) | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list