Lists and Tuples

Andrew Bennetts andrew-pythonlist at puzzling.org
Fri Dec 5 00:59:57 EST 2003


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.






More information about the Python-list mailing list