Path: csiph.com!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!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.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:Python': 0.05; '(except': 0.05; 'bug.': 0.07; 'problem?': 0.07; 'url:blog': 0.09; 'python': 0.09; 'if,': 0.09; 'keyed': 0.09; 'received:mail- vb0-f46.google.com': 0.09; "wouldn't": 0.11; 'dictionary.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'hypothetical': 0.16; 'key?': 0.16; 'luck,': 0.16; 'misfeature': 0.16; 'sheer': 0.16; 'subject:dictionaries': 0.16; 'wrote:': 0.17; 'received:209.85.212.46': 0.18; 'sort': 0.21; 'header:In-Reply- To:1': 0.25; 'possibly': 0.27; 'wonder': 0.27; 'designer': 0.27; 'message-id:@mail.gmail.com': 0.27; 'received:209.85.212': 0.28; "d'aprano": 0.29; 'dictionary': 0.29; 'steven': 0.29; 'unlikely': 0.29; 'you\x92re': 0.29; 'that.': 0.30; 'implement': 0.32; 'could': 0.32; 'crazy': 0.33; 'to:addr:python-list': 0.33; 'languages': 0.33; "can't": 0.34; 'received:google.com': 0.34; 'nov': 0.35; 'especially': 0.35; 'pm,': 0.35; 'received:209.85': 0.35; 'really': 0.36; 'but': 0.36; 'problems': 0.36; 'received:209': 0.37; 'subject:: ': 0.38; 'store': 0.38; 'some': 0.38; 'instead': 0.39; 'to:addr:python.org': 0.39; 'skip:" 10': 0.40; 'header:Received:5': 0.40; 'course.': 0.62; 'url:p': 0.63; 'making': 0.64; 'charset:windows-1252': 0.65; 'adobe': 0.65; 'flash': 0.72; 'hey,': 0.72; 'much,': 0.84; 'profiles,': 0.84 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:content-transfer-encoding; bh=m8jCE3pUbcyXsest74xUfCFC+9KbGL4hfiwPE0eieY4=; b=E+EXcWPDv2nPbPzSvzPdCvN83rxAF602AT9Zn62aBt0tB1Jdk+5uJ4najQX9f8E35w 65i6z7QXUEXjLMnFJ3LpJXqWLOgRUI6co78nhzA5s/sOeOfQe41k6FXiCGFfs/4et7M2 Urugm+K9jzz/wYt0DWzEKs1+b1qGVmR2DaYhASqv7ttz1w/nZJ0yEq+9Csb0koEOVQAL 7chk/bMxEeWftmWz2O22K06Qc+9M/A3IreBMYZWyytwEuE822NkWFlQlNVsNvvkWuYU1 eO5G+Ow3XfWEpsKIzeN6u2PnkDKQ6rtIrV8KTCqdYnBQnSE13W6ZtElG716m3W47I0fe NxiA== MIME-Version: 1.0 In-Reply-To: <50b4262a$0$21875$c3e8da3$76491128@news.astraweb.com> References: <50b4262a$0$21875$c3e8da3$76491128@news.astraweb.com> Date: Tue, 27 Nov 2012 17:16:32 +1100 Subject: Re: Python dictionaries are awesome From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable 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: 27 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1353996997 news.xs4all.nl 6936 [2001:888:2000:d::a6]:48511 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:33967 On Tue, Nov 27, 2012 at 1:32 PM, Steven D'Aprano wrote: > ... especially when you consider how some other languages implement them. > > > http://twistedoakgames.com/blog/?p=3D925 > > [quote] > Here=92s the hypothetical situation: you=92re making a flash game. In tha= t > game users can create named profiles. You store the profiles, keyed by > their name, so that you ca- OOPS, you just introduced a bug. What=92s the > problem? The dictionary. > [end quote] Here's a crazy possibility. What if, instead of just the name, you use "dictkey_"+name as the key? That's unlikely to conflict with anything. Hey, I wonder if Adobe might even have been able to do that under the covers! That would have been really easy, wouldn't have cost much, and would have given full functionality! (Except that you now can't have a property named "dictkey_foo", but that could be considered a misfeature - you can use a dictionary as a sort of jump table.) Python just happened to get it right by sheer luck, of course. No designer could possibly foresee problems like that. ChrisA