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


Groups > comp.lang.python > #4296

Re: Composition instead of inheritance

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
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.004
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'attributes': 0.05; 'recipe': 0.07; 'python': 0.07; 'none)': 0.09; 'url:activestate': 0.09; 'this:': 0.11; 'url:code': 0.11; 'am,': 0.14; 'wrote:': 0.14; 'furman': 0.16; 'simplified': 0.16; 'cc:2**0': 0.20; 'cheers,': 0.20; 'header:In-Reply-To:1': 0.22; 'cc:addr:python- list': 0.22; 'thu,': 0.22; 'posted': 0.22; 'values': 0.23; 'received:209.85.161.46': 0.26; 'received:mail- fx0-f46.google.com': 0.26; 'instead': 0.26; 'message- id:@mail.gmail.com': 0.28; 'received:209.85.161': 0.29; 'cc:addr:python.org': 0.31; '(for': 0.33; 'considered': 0.36; 'received:209.85': 0.37; 'apr': 0.38; 'received:google.com': 0.38; 'code:': 0.38; 'comments': 0.39; 'could': 0.39; 'received:209': 0.39; 'header:Received:5': 0.40; 'happen': 0.61; '2011': 0.62; 'composition': 0.84; 'inheritance,': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type; bh=Kjf9byYbYqIhUwZX3viY0HaKU4vxHb+XPZR0HO1JOMs=; b=kikYrB6pDPzaQz/f5EXAFAezJAGJtml5AM2zWsrKvmw7t9QEOtZm3f+3tx6XqpB7Z+ RdMtrDW7TDTyBSeMSg8cGwycdwLeWJagWwjVzdo49dqyCcac3Pr/ogaI708F2iV/NuCE BQcEPC5fiiuB3Gyj1bkcvAjfKzaz2xfQ0VBaw=
DomainKey-Signature a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; b=N7doNx1OCIUM0nfBabvaWvRqBC7o0/s9m6bgOtIVf6CnWVBWiujMH5k/4vbaMTpQbM ITB2NmM32dgJiVWiVbyU6SZUEKSV7kFTkPM1B+U9NY/i96FMad1F/i6g8R3baQQ/S+2P tczTVVtkatRzZrK+fyDZFRXdadA4hay5OMGDI=
MIME-Version 1.0
In-Reply-To <4DB9A096.3020200@stoneleaf.us>
References <4DB9A096.3020200@stoneleaf.us>
From Ian Kelly <ian.g.kelly@gmail.com>
Date Thu, 28 Apr 2011 22:23:14 -0600
Subject Re: Composition instead of inheritance
To Ethan Furman <ethan@stoneleaf.us>
Content-Type text/plain; charset=ISO-8859-1
Cc Python <python-list@python.org>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.983.1304051025.9059.python-list@python.org> (permalink)
Lines 21
NNTP-Posting-Host 82.94.164.166
X-Trace 1304051025 news.xs4all.nl 41102 [::ffff:82.94.164.166]:49323
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:4296

Show key headers only | View raw


On Thu, Apr 28, 2011 at 11:15 AM, Ethan Furman <ethan@stoneleaf.us> wrote:
> For anybody interested in composition instead of multiple inheritance, I
> have posted this recipe on ActiveState (for python 2.6/7, not 3.x):
>
> http://code.activestate.com/recipes/577658-composition-of-classes-instead-of-multiple-inherit/
>
> Comments welcome!

On line 14, is it intentional that attributes whose values happen to
be false are not considered as conflicts?

On line 31, this code:

thing = getattr(thing, '__func__', None) or thing

could be simplified to this:

thing = getattr(thing, '__func__', thing)

Cheers,
Ian

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


Thread

Re: Composition instead of inheritance Ian Kelly <ian.g.kelly@gmail.com> - 2011-04-28 22:23 -0600

csiph-web