Python Interview Questions
D'Arcy J.M. Cain
darcy at druid.net
Sun Nov 18 12:16:14 EST 2012
On 18 Nov 2012 16:50:52 GMT
Steven D'Aprano <steve+comp.lang.python at pearwood.info> 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"}
--
D'Arcy J.M. Cain <darcy at druid.net> | Democracy is three wolves
http://www.druid.net/darcy/ | and a sheep voting on
+1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner.
IM: darcy at Vex.Net
More information about the Python-list
mailing list