Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'string.': 0.04; 'subject:Python': 0.05; 'things.': 0.05; 'key.': 0.07; 'immutable': 0.09; 'integers': 0.09; 'mutable': 0.09; 'structure,': 0.09; 'tuple': 0.09; '*you*': 0.16; 'altered': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'roy': 0.16; 'sorts': 0.16; 'then...': 0.16; 'values:': 0.16; 'mon,': 0.16; 'wrote:': 0.17; 'example.': 0.17; '>>>': 0.18; 'received:209.85.214.174': 0.21; 'subject:Questions': 0.22; "i've": 0.23; 'header:In-Reply-To:1': 0.25; 'am,': 0.27; '(such': 0.27; 'message-id:@mail.gmail.com': 0.27; 'this?': 0.28; "d'aprano": 0.29; 'dictionary': 0.29; 'steven': 0.29; 'covered': 0.29; 'keyword': 0.30; 'lists': 0.31; 'consist': 0.33; 'ordered': 0.33; 'to:addr:python-list': 0.33; 'received:google.com': 0.34; 'list': 0.35; 'needed': 0.35; 'nov': 0.35; 'received:209.85': 0.35; 'list.': 0.35; 'created': 0.36; 'but': 0.36; '(i.e.': 0.36; 'one,': 0.37; 'does': 0.37; 'two': 0.37; 'being': 0.37; 'previous': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'received:209.85.214': 0.39; 'header:Received:5': 0.40; 'hearing': 0.61; 'on...': 0.65; 'phone': 0.68; 'smith': 0.71; 'prisoner': 0.84; 'subject:Interview': 0.84; 'many,': 0.93 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=M63kqpoassgBxO3eXj8eHAPNgKD8a7SeTyWC8yOVuV4=; b=IvOvRADEYzm5UalEoL6cOKTF23yk7Unsol/VELqti4Jb18u2jLog+FJQO2gXmpRWs1 Kuf8FunWvUyGzXgJxYftSFq0MINRaCrDJWJTeaHg5IkMEb/HLe3pwi/IoBCSJVYjAZMp t3TzswYtVfbNSXYsLv2z09JOApfXtfhGCwY8kXqwwHq0I7PHtHdB41Cu+uKw69hY5qxI dkc4cslmDGhRoQwN8w/jXDotAHtFVpJTLhJJ7n+eSg+hB0WURkl8RThnUekUH7afK8UD 2i+Xz0IKkncTL5e01tLFGFTdVQSId99LSmfxVIgAa4HqOZYLoUeXCIjQDd8f2zfms3Ei owfQ== MIME-Version: 1.0 In-Reply-To: <20121118121614.24d2416d@dilbert> References: <1193768041.349129.26350@v3g2000hsg.googlegroups.com> <55443eb7-847c-4f4c-8d04-1e6b507aac00@googlegroups.com> <50a8acdc$0$29978$c3e8da3$5496439d@news.astraweb.com> <50a911ec$0$29978$c3e8da3$5496439d@news.astraweb.com> <20121118121614.24d2416d@dilbert> Date: Mon, 19 Nov 2012 07:02:49 +1100 Subject: Re: Python Interview Questions From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 26 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1353268978 news.xs4all.nl 6933 [2001:888:2000:d::a6]:40469 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:33512 On Mon, Nov 19, 2012 at 4:16 AM, D'Arcy J.M. Cain wrote: > On 18 Nov 2012 16:50:52 GMT > Steven D'Aprano 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. ChrisA