Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed5.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.078 X-Spam-Evidence: '*H*': 0.84; '*S*': 0.00; 'instance': 0.05; 'attribute': 0.09; 'pm,': 0.11; 'wrote:': 0.14; 'aliases': 0.16; 'attributes.': 0.16; 'finney': 0.16; 'innovations': 0.16; 'class,': 0.16; 'cc:no real name:2**0': 0.20; 'cc:2**0': 0.20; 'code': 0.22; 'header:In-Reply-To:1': 0.22; 'cc:addr:python-list': 0.22; 'thu,': 0.22; 'define': 0.26; 'url:mailman': 0.27; 'message- id:@mail.gmail.com': 0.28; 'class': 0.29; 'sort': 0.30; 'cc:addr:python.org': 0.31; 'all,': 0.31; 'url:listinfo': 0.33; 'using': 0.34; 'open': 0.35; 'problems': 0.37; 'it?': 0.37; 'refer': 0.37; 'should': 0.37; 'received:209.85': 0.37; 'url:python': 0.37; 'depend': 0.38; 'received:google.com': 0.38; 'ways': 0.38; 'url:org': 0.38; 'end': 0.39; 'received:209': 0.39; 'how': 0.39; 'header:Received:5': 0.40; 'exact': 0.60; '2011': 0.62; 'mar': 0.64; 'skip:\xe2 10': 0.72; 'reply-to:no real name:2**0': 0.72; 'header:Reply-To:1': 0.72; 'protecting': 0.73; 'reply-to:addr:gmail.com': 0.78; 'confidence': 0.80; 'blog!': 0.84; '\xe2\x80\x9cthe': 0.93 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:reply-to:in-reply-to:references :from:date:message-id:subject:to:cc:content-type :content-transfer-encoding; bh=UQsRBefi+usMjPtRKMMwvxgXDToLBr5sweIvgNEfWG8=; b=Y+Vc5kNzuWsIyoqfHaMEJixp0Z31Ers8WW5Y4hPGLcLj4BUThcQYiCYJV3aJo/hh95 oYZ+hS1YUJxJDD7sWuXCVKqz7zQUwpGDureCjmVlE9ULKKKYatTZJENATz05zf6N8sSy AouCnKG7WE8B3p0dJRKw1ioS/jEm7QWFJqq7Q= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:reply-to:in-reply-to:references:from:date:message-id :subject:to:cc:content-type:content-transfer-encoding; b=V9V1lM8r3dZ6bluwIDqwLZXi/Mq4izfyQA9fdxXvkF3HSUFvPHb7xsmpp9tKBUDVxH 3kUMPrS/+J7SY5F4R1kQ5imOgzfUILfDCfiZVIrzQUdoqo4dghOKu8tZAZeT3mhoBpRG yhrpcBe9dini2fo5rGw98yF514frUpmnu7PF4= MIME-Version: 1.0 In-Reply-To: <87sju3ndjo.fsf@benfinney.id.au> References: <87sju3ndjo.fsf@benfinney.id.au> From: Calvin Spealman Date: Thu, 31 Mar 2011 20:36:09 -0400 Subject: Re: Alias for an attribute defined in a superclass To: Ben Finney Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: ironfroggy@gmail.com 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: 48 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1301618196 news.xs4all.nl 41110 [::ffff:82.94.164.166]:41353 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:2321 Sounds like you're just going to end up with more confusing code having multiple ways to refer to the exact same thing. Why? On Thu, Mar 31, 2011 at 6:14 PM, Ben Finney wr= ote: > Howdy all, > > I want to inherit from a class, and define aliases for many of its > attributes. How can I refer to =E2=80=9Cthe attribute that will be availa= ble by > name =E2=80=98spam=E2=80=99 once this class is defined=E2=80=9D? > > =C2=A0 =C2=A0class Foo(object): > =C2=A0 =C2=A0 =C2=A0 =C2=A0def spam(self): > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0pass > > =C2=A0 =C2=A0 =C2=A0 =C2=A0def eggs(self): > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0pass > > =C2=A0 =C2=A0class Bar(Foo): > =C2=A0 =C2=A0 =C2=A0 =C2=A0beans =3D Foo.spam > =C2=A0 =C2=A0 =C2=A0 =C2=A0mash =3D Foo.eggs > > Is that the right way to do it? Will that leave me open to =E2=80=9Cunbou= nd > method=E2=80=9D or =E2=80=9Cis not an instance of =E2=80=98Bar=E2=80=99= =E2=80=9D or other problems when using > =E2=80=98Bar.beans=E2=80=99? > > -- > =C2=A0\ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =E2=80=9CIf [a technology comp= any] has confidence in their future | > =C2=A0`\ =C2=A0 =C2=A0 =C2=A0ability to innovate, the importance they pla= ce on protecting | > _o__) =C2=A0 =C2=A0 their past innovations really should decline.=E2=80= =9D =E2=80=94Gary Barnett | > Ben Finney > -- > http://mail.python.org/mailman/listinfo/python-list > --=20 Read my blog! I depend on your acceptance of my opinion! I am interesting! http://techblog.ironfroggy.com/ Follow me if you're into that sort of thing: http://www.twitter.com/ironfro= ggy