Python Interview Questions

Roy Smith roy at
Sun Nov 18 14:53:25 CET 2012

In article <50a8acdc$0$29978$c3e8da3$5496439d at>,
 Steven D'Aprano <steve+comp.lang.python at> wrote:

> Use a list when you want a list of items that should all be treated the 
> same way [...] or when you need a collection of items where the order they are in is 
> important:
> Use a tuple when you want a collection of items that mean different 
> things, a bit like a C struct or Pascal record:

That is certainly the right answer according to the One True Church Of 
Pythonic Orthodoxy And Theoretical Correctness.  But, let me give an 
alternative answer which works for The Unwashed Masses Who Live In The 
Trenches And Write Python Code For A Living:

Use a list when you need an ordered collection which is mutable (i.e. 
can be altered after being created).  Use a tuple when you need an 
immutable list (such as for a dictionary key).

More information about the Python-list mailing list