Python Interview Questions

Chris Angelico rosuav at
Sun Nov 18 21:02:49 CET 2012

On Mon, Nov 19, 2012 at 4:16 AM, D'Arcy J.M. Cain <darcy at> wrote:
> On 18 Nov 2012 16:50:52 GMT
> Steven D'Aprano <steve+comp.lang.python at> wrote:
>> On Sun, 18 Nov 2012 08:53:25 -0500, Roy Smith wrote:
>>> > 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).
>> I keep hearing about this last one, but I wonder... who *actually*
>> does this? I've created many, many lists over the years -- lists of
>> names, lists of phone numbers, lists of directory search paths, all
>> sorts of things. I've never needed to use one as a dictionary key.
> Well, as long as *you* never needed it then...
> CellBlock = 9 # There's a riot going on...
> Cell = 17
> Bunk = "top"
> Prisoner = {(CellBlock, Cell, Bunk): "Bernie Madoff"}

That's a structure, not a list. Every key will consist of precisely
three values: two integers and one keyword string. Already covered by
a previous example.


More information about the Python-list mailing list