Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Ian Kelly Newsgroups: comp.lang.python Subject: Re: Multiple inheritance, super() and changing signature Date: Fri, 3 Jun 2016 15:53:58 -0600 Lines: 24 Message-ID: References: <80ea0ea1-5468-2dee-2c38-c2b09801d0f1@shopzeus.com> <574e45f4$0$1611$c3e8da3$5496439d@news.astraweb.com> <85k2i65upp.fsf@benfinney.id.au> <85fusu58pw.fsf@benfinney.id.au> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de n5fVRhUrwXRVH0DJuBNFvwHOYm9uYWoo09mxCtYNnPuw== 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; '*args,': 0.07; 'cc:addr :python-list': 0.09; 'positional': 0.09; 'received:209.85.218': 0.10; 'python': 0.10; 'def': 0.13; 'argument': 0.15; '2016': 0.16; 'argument.': 0.16; 'cc:name:python': 0.16; 'initialiser': 0.16; "method's": 0.16; 'parameters,': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:changing': 0.16; 'wrote:': 0.16; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'handles': 0.20; 'arguments': 0.22; 'simpler': 0.22; 'specified': 0.23; 'header:In- Reply-To:1': 0.24; 'fri,': 0.27; 'parameters': 0.27; 'message- id:@mail.gmail.com': 0.27; 'actual': 0.28; '**kwargs)': 0.29; '**kwargs):': 0.29; 'spam,': 0.29; 'allows': 0.30; "we're": 0.30; 'certain': 0.31; 'skip:_ 10': 0.32; 'class': 0.33; 'except': 0.34; 'skip:d 20': 0.34; 'received:google.com': 0.35; 'next': 0.35; 'should': 0.36; 'received:209.85': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'two': 0.37; 'expect': 0.37; 'method': 0.37; 'received:209': 0.38; '"spam"': 0.84; 'to:none': 0.91; 'inheritance,': 0.93 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:cc; bh=JCjAJElU+Yb4OOKkhbQKjvElAKK1IEcbGFYIDGvzAuI=; b=QpTBrwvKxT11KzR8og9MWCilP/IsvNF2FYeZ/6Gp8ybMKDA6kX2NU2YJKacy5wJlX8 CDMvffo588Om2NS1/9YEZlJPdEU6QsuJUoTYBbVrXdPS7NzKKYATLK92i9qbDt7N2o/7 gBJXCcP/cio54p5DtSbZV13Hdq5Jn4rQJTyFLKgOUE9IHM9XuavZP8TIKCjJDou6zSo0 BEXwwwz65vJPZoFVnthVcqGPq/3znJ5Yr17ZTRKz15iEcL4XR1yXWc0zvLCvTikObQqp gHCFrrXJyf2Rz7wmhJrXMgy6Wxpg2SJOKD7Kbt0aWLPpl4UtTZw4Nid6DvtBjRhvTxXs LHug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:cc; bh=JCjAJElU+Yb4OOKkhbQKjvElAKK1IEcbGFYIDGvzAuI=; b=bvQoYSoPp1OLSECDDWrRuEp0/nxCPegNuLq4eBHBJRCziBJtrt+sKtqKxyJbBdBvTV SYRDHwUvNc9bh4OVIt+RNu7b5ymWGPTYvdeKjfh3xukigWUcsoRmCNMmY689+mi6UXR/ EfuwA3GNUhhcND9vyyIrMsewPd7OkIKCjLb3NDxX5y5Lmm1aMt+9tg5MfJO8CFhx9rVC q3j+VIDLnxIq1QD0kW14zoFI1q5JWlVmRHdqnO7KU3SpqjAr030Ykd63sV/mFlHSSEy5 hv3EIi/K3dL1EumdRwbVN0Mkpex99ICchEOPmshFr0hwv5B0d5EvpnvWLQb5W8g30rXJ YAcA== X-Gm-Message-State: ALyK8tI44Ww3BerRa4DROX1UcAK4e6dhaSM40KlHJR1vj8jxIxc1SSamBusqyz8hU8HViFf3wrRG5mAnJnrcpA== X-Received: by 10.202.51.133 with SMTP id z127mr3185277oiz.194.1464990877945; Fri, 03 Jun 2016 14:54:37 -0700 (PDT) In-Reply-To: <85fusu58pw.fsf@benfinney.id.au> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: X-Mailman-Original-References: <80ea0ea1-5468-2dee-2c38-c2b09801d0f1@shopzeus.com> <574e45f4$0$1611$c3e8da3$5496439d@news.astraweb.com> <85k2i65upp.fsf@benfinney.id.au> <85fusu58pw.fsf@benfinney.id.au> Xref: csiph.com comp.lang.python:109440 On Fri, Jun 3, 2016 at 2:16 PM, Ben Finney wrote: > If you're writing a custom initialiser that handles two additional > parameters, then those parameters should not be present when you call > the super() method's initialiser:: > > # You specified Python 3, which allows simpler syntax. > > class LoremIpsum: > def __init__(self, spam, *args, **kwargs): > do_something_important_with(spam) > super().__init__(*args, **kwargs) > > class DolorSitAmet(LoremIpsum): > def __init__(self, spam, eggs=4, beans=None, *args, **kwargs): > self.eggs = eggs > self.beans = beans > super().__init__(spam, *args, **kwargs) Except that since we're discussing design for multiple inheritance, the positional argument "spam" is inappropriate. All arguments should be passed by keyword; the DolorSitAmet.__init__ method cannot be certain that LoremIpsum will be the next class in the MRO, and the actual next class might not expect spam to be the first positional argument.