Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #109418

Re: Multiple inheritance, super() and changing signature

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Ian Kelly <ian.g.kelly@gmail.com>
Newsgroups comp.lang.python
Subject Re: Multiple inheritance, super() and changing signature
Date Fri, 3 Jun 2016 08:39:00 -0600
Lines 40
Message-ID <mailman.126.1464964789.1839.python-list@python.org> (permalink)
References <80ea0ea1-5468-2dee-2c38-c2b09801d0f1@shopzeus.com> <mailman.54.1464711627.1839.python-list@python.org> <574e45f4$0$1611$c3e8da3$5496439d@news.astraweb.com> <a17955cb-04d3-9dd6-e2b3-4719269f241d@shopzeus.com> <d91f49c5-4572-9cc4-9688-b4b3ffbce691@shopzeus.com> <CALwzidnc=Yws6gSOpt_spYWGTJkq4zOuUmcVNuyF6Xuv3dK++Q@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding quoted-printable
X-Trace news.uni-berlin.de +GfYIdBpXRgr0onH5rSp6gxU7oW13HMDXLl4fyn1pXFA==
Return-Path <ian.g.kelly@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.052
X-Spam-Evidence '*H*': 0.90; '*S*': 0.00; 'root': 0.04; 'classes.': 0.07; 'received:209.85.218': 0.10; 'def': 0.13; '2016': 0.16; 'b):': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'root:': 0.16; 'subject:changing': 0.16; 'sure.': 0.16; 'wrote:': 0.16; '>>>': 0.20; 'parameter': 0.22; 'pass': 0.22; 'am,': 0.23; 'this:': 0.23; 'header:In-Reply-To:1': 0.24; 'fri,': 0.27; 'message-id:@mail.gmail.com': 0.27; 'signatures': 0.29; 'classes': 0.30; 'raymond': 0.30; 'another': 0.32; "can't": 0.32; 'skip:_ 10': 0.32; 'class': 0.33; 'extract': 0.33; 'changing': 0.34; 'received:google.com': 0.35; 'something': 0.35; 'there': 0.36; 'received:209.85': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'really': 0.37; 'method': 0.37; 'received:209': 0.38; 'shared': 0.38; 'why': 0.39; 'to:addr:python.org': 0.40; 'still': 0.40; 'some': 0.40; 'easy': 0.60; 'share': 0.61; 'watch': 0.62; 'inherit': 0.66; 'url:26': 0.66; 'url:2011': 0.75; 'url:wordpress': 0.79; 'account.': 0.80; 'nagy': 0.84; 'to:name:python': 0.84; 'shows,': 0.91; 'cooperative': 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:to :content-transfer-encoding; bh=sPFcs+F1iyVE4cy0Y6cpGgvGJk9DuwFqBfpEuoebPfA=; b=gj6FgWsfp6Ddmaqg14I/9Vf7p8Y35O+YRwFd0ORaFXKVm3Go3UoGYhFwI08gNNzAJT v1C/nQUHYL7nHo2tvIb5n4qAoNNZbYfx2fwOWu7FLgrEWbH8SivxAyWMTtkC61U5UJnt Enm/LroUCr8qf1qEeONhEJQLH2QlKsRKXQE8HqXTDAXBi/2INB61fps5PBkAWEleq/0i 6dcr6GIspBVqkeJnpIPi8TF9auvXnbpsxP0eB+HJr/If3kjQOa1GuhNkudC8mgcSuGL6 1T3Xx0qg9y4slCKZh9NFubZ3QwLvpVGAI9eWMts6P+T9JPHuTjIJDjL8HppxzSMVUzyR Jqmw==
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:to:content-transfer-encoding; bh=sPFcs+F1iyVE4cy0Y6cpGgvGJk9DuwFqBfpEuoebPfA=; b=ZCjikU/6OkqPP6xcPnQKRJZm37YpvsLAWeSl+7FaVULcvH5eVropfYM6SpswcuFum1 7sBxg5+IdcZsVrqT7NBTiEW58t04ioNjLKMz/EOqCjo5P9JcZ+q3qWFkOpyfhqWmEQzn tXVu9gZeAZ3VrDPEgEbSfYKUR/shr+wYA/lLj/wYbwoAqpTS7Q+Qe0gIRA4zJinR9jOZ sFDwbdwQwZJz6kFyVP4l1nNPd6ga/iGb1EuFTe7duikJ5R+fYvr7WAMDC1O2vvFVwkLB tCo87bxSSEYKHlaghnDOpVg9f5nIjY8kKvkVceNZzCxsofSgQqzaBF+zybH/UnehUi7D 4ZvA==
X-Gm-Message-State ALyK8tJM1x9LlSxKb3hz8WOqa8d+z2US8r0CjGTH+xjS91XJhUntj0mNd00Xgxw0wi2fKEYw9KN/BSNaie3DWA==
X-Received by 10.157.54.98 with SMTP id w89mr1852521otb.187.1464964781255; Fri, 03 Jun 2016 07:39:41 -0700 (PDT)
In-Reply-To <d91f49c5-4572-9cc4-9688-b4b3ffbce691@shopzeus.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.22
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID <CALwzidnc=Yws6gSOpt_spYWGTJkq4zOuUmcVNuyF6Xuv3dK++Q@mail.gmail.com>
X-Mailman-Original-References <80ea0ea1-5468-2dee-2c38-c2b09801d0f1@shopzeus.com> <mailman.54.1464711627.1839.python-list@python.org> <574e45f4$0$1611$c3e8da3$5496439d@news.astraweb.com> <a17955cb-04d3-9dd6-e2b3-4719269f241d@shopzeus.com> <d91f49c5-4572-9cc4-9688-b4b3ffbce691@shopzeus.com>
Xref csiph.com comp.lang.python:109418

Show key headers only | View raw


On Fri, Jun 3, 2016 at 8:06 AM, Nagy László Zsolt <gandalf@shopzeus.com> wrote:
>
>>> That's overly strict. As Raymond shows, it is easy to deal with
>>> changing method signatures in *cooperative* classes.
>> I must watch that for sure.
>
> All right, I have read this:
>
> https://rhettinger.wordpress.com/2011/05/26/super-considered-super/
>
> There is still something I don't get: how to create cooperative classes
> when some base classes share some of the parameters?

Why do they need to share the same parameter? Part of cooperative
design is that you can't really design each class in a vacuum; you
need to take the other classes they might get combined with into
account. Perhaps you can extract that parameter into another base
class that is shared by both:

class Root:
    def __init__(self, *, param1, **kwds):
        self.param1 = param1
        super().__init__(**kwds)

class A(Root):
    def __init__(self, *, param2, **kwds):
        self.param2 = param2
        super().__init__(**kwds)

class B(Root):
    def __init__(self, *, param3, **kwds):
        self.param3 = param3
        super().__init__(**kwds)

class X(A, B):
    pass

A and B can both depend on having param1 without stomping on each
other because they both inherit Root which requires it.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Multiple inheritance, super() and changing signature Nagy László Zsolt <gandalf@shopzeus.com> - 2016-05-31 18:10 +0200
  Re: Multiple inheritance, super() and changing signature Steven D'Aprano <steve@pearwood.info> - 2016-06-01 12:18 +1000
    Re: Multiple inheritance, super() and changing signature Nagy László Zsolt <gandalf@shopzeus.com> - 2016-06-03 14:10 +0200
      Re: Multiple inheritance, super() and changing signature Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2016-06-04 13:06 +1200
        Re: Multiple inheritance, super() and changing signature Steven D'Aprano <steve@pearwood.info> - 2016-06-04 12:51 +1000
          Re: Multiple inheritance, super() and changing signature Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2016-06-04 23:50 +1200
        Re: Multiple inheritance, super() and changing signature Ian Kelly <ian.g.kelly@gmail.com> - 2016-06-03 23:05 -0600
          Re: Multiple inheritance, super() and changing signature Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2016-06-04 23:52 +1200
            Re: Multiple inheritance, super() and changing signature Steven D'Aprano <steve@pearwood.info> - 2016-06-04 23:46 +1000
              Re: Multiple inheritance, super() and changing signature Nagy László Zsolt <gandalf@shopzeus.com> - 2016-06-04 16:42 +0200
    Re: Multiple inheritance, super() and changing signature Ben Finney <ben+python@benfinney.id.au> - 2016-06-03 22:21 +1000
      Re: Multiple inheritance, super() and changing signature Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2016-06-04 13:10 +1200
    Re: Multiple inheritance, super() and changing signature Nagy László Zsolt <gandalf@shopzeus.com> - 2016-06-03 14:14 +0200
    Re: Multiple inheritance, super() and changing signature Nagy László Zsolt <gandalf@shopzeus.com> - 2016-06-03 14:57 +0200
    Re: Multiple inheritance, super() and changing signature Nagy László Zsolt <gandalf@shopzeus.com> - 2016-06-03 16:06 +0200
    Re: Multiple inheritance, super() and changing signature Ian Kelly <ian.g.kelly@gmail.com> - 2016-06-03 08:39 -0600
    Re: Multiple inheritance, super() and changing signature Michael Selik <michael.selik@gmail.com> - 2016-06-03 15:33 +0000
    Re: Multiple inheritance, super() and changing signature Nagy László Zsolt <gandalf@shopzeus.com> - 2016-06-03 17:59 +0200
    Re: Multiple inheritance, super() and changing signature Michael Selik <michael.selik@gmail.com> - 2016-06-03 16:28 +0000
    Re: Multiple inheritance, super() and changing signature Ben Finney <ben+python@benfinney.id.au> - 2016-06-04 06:16 +1000
    Re: Multiple inheritance, super() and changing signature Ben Finney <ben+python@benfinney.id.au> - 2016-06-04 06:19 +1000
    Re: Multiple inheritance, super() and changing signature Ian Kelly <ian.g.kelly@gmail.com> - 2016-06-03 15:53 -0600
    Re: Multiple inheritance, super() and changing signature Ben Finney <ben+python@benfinney.id.au> - 2016-06-04 10:44 +1000

csiph-web