Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'args': 0.07; 'method.': 0.07; '__init__': 0.09; 'arguments': 0.09; 'from:addr:ethan': 0.09; 'from:addr:stoneleaf.us': 0.09; 'from:name:ethan furman': 0.09; 'message-id:@stoneleaf.us': 0.09; 'received:184.172': 0.09; 'received:gator410.hostgator.com': 0.09; '~ethan~': 0.09; 'def': 0.12; "wouldn't": 0.14; '**kwargs):': 0.16; '23,': 0.16; 'bug,': 0.16; 'does,': 0.16; 'inheritance': 0.16; 'kwargs': 0.16; 'subject:object': 0.16; 'exception': 0.16; 'prevent': 0.16; 'ignore': 0.16; 'wrote:': 0.18; 'trying': 0.19; 'header:User- Agent:1': 0.23; 'class.': 0.26; 'header:In-Reply-To:1': 0.27; 'idea': 0.28; 'reporting': 0.29; "doesn't": 0.30; "d'aprano": 0.31; 'object.': 0.31; 'steven': 0.31; 'class': 0.32; 'probably': 0.32; 'skip:_ 10': 0.34; 'subject:the': 0.34; 'classes': 0.35; 'but': 0.35; 'add': 0.35; 'there': 0.35; 'keyword': 0.36; 'object,': 0.36; 'doing': 0.36; 'method': 0.36; 'charset:us- ascii': 0.36; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'read': 0.60; 'ian': 0.60; 'reaching': 0.61; 'received:173': 0.61; "you're": 0.61; 'received:69.56': 0.68; 'received:69.56.148': 0.84; 'thing,': 0.91; 'technique': 0.93; '2013': 0.98 Date: Wed, 26 Jun 2013 13:37:37 -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: What is the semantics meaning of 'object'? References: <15ba0011-bbf1-42f7-b3ea-1c1d4b70e56b@googlegroups.com> <51c66962$0$29999$c3e8da3$5496439d@news.astraweb.com> <20130623133546.GA2308@capricorn> <51c723b4$0$29999$c3e8da3$5496439d@news.astraweb.com> <51c7426f$0$29999$c3e8da3$5496439d@news.astraweb.com> In-Reply-To: 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 - gator410.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: X-Source-Args: X-Source-Dir: X-Source-Sender: ([173.12.184.233]) [173.12.184.233]:33863 X-Source-Auth: ethan+stoneleaf.us X-Email-Count: 3 X-Source-Cap: dG9idWs7dG9idWs7Z2F0b3I0MTAuaG9zdGdhdG9yLmNvbQ== 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: 1372279058 news.xs4all.nl 15960 [2001:888:2000:d::a6]:39213 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:49276 On 06/23/2013 12:05 PM, Ian Kelly wrote: > On Sun, Jun 23, 2013 at 12:46 PM, Steven D'Aprano > wrote: >> All is not lost, there are ways to make your classes cooperative. The >> trick is to have your classes' __init__ methods ignore keyword arguments >> they don't know what to do with. object used to do the same thing, but it >> no longer does, so you need to add an extra class just before object to >> swallow any args before they read object. >> >> >> class Blocker(object): >> def __init__(self, **kwargs): >> # Block kwargs from reaching object >> super(Blocker, self).__init__() > > I don't like the idea of doing this with a cooperative __init__ > method. If any keyword arguments were passed that weren't consumed, > that is probably a bug, and this just swallows the exception instead > of reporting it. +1 Z > Of course, if you're doing cooperative inheritance with some other > method that doesn't exist on object, then this technique is necessary > to prevent the topmost class from trying to call that method on object > and erroring out. But in that case the Blocker wouldn't call super since it is acting as the base class. -- ~Ethan~