Lists and Tuples

Dang Griffith noemail at noemail4u.com
Fri Dec 5 14:29:17 CET 2003


On Fri, 5 Dec 2003 16:59:57 +1100, Andrew Bennetts
<andrew-pythonlist at puzzling.org> wrote:

>On Fri, Dec 05, 2003 at 05:19:33AM +0000, Jeff Wagner wrote:
>> I've spent most of the day playing around with lists and tuples to get a really good grasp on what
>> you can do with them. I am still left with a question and that is, when should you choose a list or
>> a tuple? I understand that a tuple is immutable and a list is mutable but there has to be more to it
>> than just that.  Everything I tried with a list worked the same with a tuple. So, what's the
>> difference and why choose one over the other?
>
>What's the difference?
>
>>>> import sets
>>>> sets.Set(dir(list)).difference(sets.Set(dir(tuple)))
>Set(['sort', 'index', '__delslice__', 'reverse', 'extend', 'insert',
>'__setslice__', 'count', 'remove', '__setitem__', '__iadd__', 'pop',
>'__delitem__', 'append', '__imul__'])
>
>;)
>
>-Andrew.
>
I like that--ask a simple question, get a simple answer.  Why can't
they all be so straightforward.  :-)
   --dang




More information about the Python-list mailing list