Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed2a.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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'from:addr:ethan': 0.09; 'from:addr:stoneleaf.us': 0.09; 'from:name:ethan furman': 0.09; 'if,': 0.09; 'message-id:@stoneleaf.us': 0.09; 'methods,': 0.09; '~ethan~': 0.09; 'python': 0.11; '(via': 0.16; 'dict': 0.16; 'general.': 0.16; 'magic': 0.16; 'overridden': 0.16; 'received:69.93': 0.16; 'saying.': 0.16; 'subclassing': 0.16; 'subject: \n ': 0.16; 'subject:class': 0.16; 'subject:failed': 0.16; 'subject:key': 0.16; 'tuples,': 0.16; 'wrote:': 0.18; 'normally': 0.19; 'issue.': 0.22; 'saying': 0.22; 'header:User- Agent:1': 0.23; 'issue,': 0.24; 'subject:like': 0.24; "haven't": 0.24; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; "i'm": 0.30; 'subject:that': 0.31; 'class': 0.32; 'implemented': 0.33; 'something': 0.35; 'but': 0.35; 'method': 0.36; 'charset:us- ascii': 0.36; 'example,': 0.37; 'to:addr:python-list': 0.38; 'sure': 0.39; 'to:addr:python.org': 0.39; 'called': 0.40; 'received:173': 0.61; 'provide': 0.64; 'more': 0.64; 'behavior': 0.77; 'dict,': 0.84; 'played': 0.84 Date: Mon, 30 Jun 2014 10:09:20 -0700 From: Ethan Furman User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121010 Thunderbird/16.0.1 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Creating a dict-like class that counts successful and failed key matches References: <1404135829.10485.136092537.2F0486D2@webmail.messagingengine.com> <1404139465.27658.136120269.0CA38211@webmail.messagingengine.com> <53B18398.4090302@stoneleaf.us> <1404146834.28955.136173757.51576D44@webmail.messagingengine.com> In-Reply-To: <1404146834.28955.136173757.51576D44@webmail.messagingengine.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator3304.hostgator.com X-AntiAbuse: Original Domain - python.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - stoneleaf.us X-BWhitelist: no X-Source-IP: 173.12.184.233 X-Exim-ID: 1X1f4y-0004ho-9v X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: ([173.12.184.233]) [173.12.184.233]:36363 X-Source-Auth: ethan+stoneleaf.us X-Email-Count: 1 X-Source-Cap: dG9idWs7dG9idWs7Z2F0b3IzMzA0Lmhvc3RnYXRvci5jb20= 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: 23 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1404148248 news.xs4all.nl 2925 [2001:888:2000:d::a6]:35388 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:73753 On 06/30/2014 09:47 AM, python@bdurham.com wrote: >> >> Keep in mind that dict /will not/ call your overridden methods, so if, >> for example, you provide your own __getitem__ you will also need to >> provide your own copies of any dict method that calls __getitem__. > > I'm not sure I understand. Are you saying that Chris's __getitem__ will > not be called by other dict methods that would normally call this magic > method and instead call the parent's __getitem__ directly (via super() > or something similar?)? That is what I am saying. > Is this specific to the native Dict class (because its implemented in C > vs. Python?) or is this behavior more general. I /think/ it's only dict, but I haven't played with subclassing lists, tuples, etc. It's not a C vs Python issue, but a 'implemented with __private methods' issue. From what I have seen so far in the confusion and frustration that decision has caused, I do not think it was a good one. :( -- ~Ethan~