Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3.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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python,': 0.02; 'subject:Python': 0.06; 'attribute': 0.07; 'attributes': 0.09; 'feature.': 0.09; 'key.': 0.09; 'references.': 0.09; 'typed': 0.09; 'undefined': 0.09; 'cc:addr:python-list': 0.11; 'before.': 0.16; 'from:addr:pobox.com': 0.16; 'from:addr:skip': 0.16; 'keys.': 0.16; 'mildly': 0.16; 'notation': 0.16; 'pause': 0.16; 'typeerror:': 0.16; 'usage,': 0.16; '{};': 0.16; 'index': 0.16; 'sender:addr:gmail.com': 0.17; 'wrote:': 0.18; 'aug': 0.22; 'proposed': 0.22; 'cc:addr:python.org': 0.22; 'skip': 0.24; 'tend': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'am,': 0.29; 'wonder': 0.29; 'message- id:@mail.gmail.com': 0.30; "i'm": 0.30; 'code': 0.31; 'probably': 0.32; 'anywhere': 0.35; 'objects': 0.35; 'received:google.com': 0.35; 'var': 0.36; 'should': 0.36; 'little': 0.38; 'short': 0.38; 'sure': 0.39; 'skip:x 10': 0.40; 'no.': 0.61; 'name': 0.63; 'prompt': 0.68; 'subject:For': 0.78; 'confusing': 0.84; 'dict.': 0.84; 'subject:Make': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type:content-transfer-encoding; bh=ivDsF4Taq4jqcjtbGTKZNqkkWRTj8rp78ufupPOA6uc=; b=KN2Tvlgz9dyOLPr1y61eEyZCeT0Z0IZHVpIamPXnBaonMHQSoWl4UKEdUZIzMNZbxM 3hd24SUDQCscdP6zpmLEVxd5YcrvhHy217+5HRdr3p+VDy2vdBdyPPaa1l3qRIM/Eoja vpJb3qs2G5Eo1CHdNbFK+x6QVq0wsIEfnH31SZTvolCIrS8WexqSTvLNKuVSw2E+jE3X lm3Hto0+FE/dvZLm+Z6mWV8xCsh4HLS9IZJfs/HH4C3byXKiee7XJVQvoooNaWVVrsFm iG4kurFlgzNSkgZ5UWlIojyF7MhQrwJ4cWbKJ33d33HAKCaHAcLPZiOspA6KwEUBHFsU KLxg== MIME-Version: 1.0 X-Received: by 10.42.208.70 with SMTP id gb6mr5337788icb.89.1407241865872; Tue, 05 Aug 2014 05:31:05 -0700 (PDT) Sender: skip.montanaro@gmail.com In-Reply-To: <87k36nxhv8.fsf@elektro.pacujo.net> References: <7ef67ccc-3fc3-47dd-b858-09ef3b57a497@googlegroups.com> <87k36nxhv8.fsf@elektro.pacujo.net> Date: Tue, 5 Aug 2014 07:31:05 -0500 X-Google-Sender-Auth: EIKfCnG8qma44N-QUPmexRoSl3c Subject: Re: 3 Suggestions to Make Python Easier For Children From: Skip Montanaro To: Marko Rauhamaa Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: Python 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: 32 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1407241868 news.xs4all.nl 2956 [2001:888:2000:d::a6]:41614 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:75732 On Tue, Aug 5, 2014 at 7:04 AM, Marko Rauhamaa wrote: > > I wonder if that should be built into dict. Short answer, no. I'm sure it's been proposed before. Attributes =E2=89=A0 keys. When you see something.somethingelse anywhere else in Python, "somethingelse" is an attribute reference. When you see something[somethingelse], "somethingelse" is an index value or key. Why destroy that symmetry in dictionaries? JavaScript objects have that feature. I find it mildly confusing because whenever I see it I have to pause to consider whether the name I am looking at is an attribute or a key. This little JS code I just typed at my console prompt was also mildly surprising: > var x =3D {}; undefined > x.valueOf(47) Object {} > x["valueOf"] =3D 12 12 > x.valueOf 12 > x.valueOf(47) TypeError: number is not a function Still, in my own JS code I tend to lapse into that usage, probably because so much other code out in the wild uses dot notation for key references. (Doesn't make it right, just makes me lazy.) Skip