Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!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.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'subject:Python': 0.05; 'things.': 0.05; 'key.': 0.07; '425': 0.09; 'immutable': 0.09; 'mutable': 0.09; 'tuple': 0.09; 'cc:addr:python-list': 0.10; '*you*': 0.16; 'altered': 0.16; 'im:': 0.16; 'roy': 0.16; 'sorts': 0.16; 'then...': 0.16; 'to:addr:pearwood.info': 0.16; 'to:addr:steve+comp.lang.python': 0.16; "to:name:steven d'aprano": 0.16; 'wrote:': 0.17; 'subject:Questions': 0.22; 'voting': 0.22; 'cc:2**0': 0.23; "i've": 0.23; 'cc:no real name:2**0': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; '(such': 0.27; 'this?': 0.28; "d'aprano": 0.29; 'dictionary': 0.29; 'steven': 0.29; 'lists': 0.31; 'ordered': 0.33; 'list': 0.35; 'needed': 0.35; 'nov': 0.35; 'created': 0.36; 'but': 0.36; '(i.e.': 0.36; 'charset:us-ascii': 0.36; 'one,': 0.37; 'does': 0.37; 'being': 0.37; 'subject:: ': 0.38; 'hearing': 0.61; 'on...': 0.65; 'phone': 0.68; 'smith': 0.71; 'democracy': 0.84; 'prisoner': 0.84; 'received:98.158': 0.84; 'subject:Interview': 0.84; 'many,': 0.93 Date: Sun, 18 Nov 2012 12:16:14 -0500 From: "D'Arcy J.M. Cain" To: Steven D'Aprano Subject: Re: Python Interview Questions In-Reply-To: <50a911ec$0$29978$c3e8da3$5496439d@news.astraweb.com> 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> X-Mailer: Claws Mail 3.8.1 (GTK+ 2.24.13; x86_64--netbsd) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: python-list@python.org 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: 25 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1353259507 news.xs4all.nl 6902 [2001:888:2000:d::a6]:39922 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:33508 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"} -- D'Arcy J.M. Cain | 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@Vex.Net