Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #2331
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!feeder.erje.net!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!198.186.194.247.MISMATCH!news-out.readnews.com!transit3.readnews.com!postnews.google.com!a11g2000pro.googlegroups.com!not-for-mail |
|---|---|
| From | Raymond Hettinger <python@rcn.com> |
| Newsgroups | comp.lang.python |
| Subject | Re: Alias for an attribute defined in a superclass |
| Date | Thu, 31 Mar 2011 19:24:42 -0700 (PDT) |
| Organization | http://groups.google.com |
| Lines | 25 |
| Message-ID | <787d36b9-e31d-4b61-a14e-770337cfc280@a11g2000pro.googlegroups.com> (permalink) |
| References | <87sju3ndjo.fsf@benfinney.id.au> |
| NNTP-Posting-Host | 76.94.45.111 |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=windows-1252 |
| Content-Transfer-Encoding | quoted-printable |
| X-Trace | posting.google.com 1301624683 2311 127.0.0.1 (1 Apr 2011 02:24:43 GMT) |
| X-Complaints-To | groups-abuse@google.com |
| NNTP-Posting-Date | Fri, 1 Apr 2011 02:24:43 +0000 (UTC) |
| Complaints-To | groups-abuse@google.com |
| Injection-Info | a11g2000pro.googlegroups.com; posting-host=76.94.45.111; posting-account=4Y7qkQkAAACIJklcr0OP4w6S6TBL_zh2 |
| User-Agent | G2/1.0 |
| X-HTTP-UserAgent | Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_7) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.25 Safari/534.24,gzip(gfe) |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:2331 |
Show key headers only | View raw
On Mar 31, 3:14 pm, Ben Finney <ben+pyt...@benfinney.id.au> wrote: > Howdy all, > > I want to inherit from a class, and define aliases for many of its > attributes. How can I refer to “the attribute that will be available by > name ‘spam’ once this class is defined”? > > class Foo(object): > def spam(self): > pass > > def eggs(self): > pass > > class Bar(Foo): > beans = Foo.spam > mash = Foo.eggs > > Is that the right way to do it? For methods, that will work just fine. For attributes, you will need to make @property accessors that get and set the underlying attribute. Raymond
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Alias for an attribute defined in a superclass Ben Finney <ben+python@benfinney.id.au> - 2011-04-01 09:14 +1100
Re: Alias for an attribute defined in a superclass Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-04-01 00:14 +0000
Re: Alias for an attribute defined in a superclass Ben Finney <ben+python@benfinney.id.au> - 2011-04-01 11:59 +1100
Re: Alias for an attribute defined in a superclass Calvin Spealman <ironfroggy@gmail.com> - 2011-03-31 20:36 -0400
Re: Alias for an attribute defined in a superclass Ben Finney <ben+python@benfinney.id.au> - 2011-04-01 11:57 +1100
Re: Alias for an attribute defined in a superclass Raymond Hettinger <python@rcn.com> - 2011-03-31 19:24 -0700
Re: Alias for an attribute defined in a superclass Jean-Michel Pichavant <jeanmichel@sequans.com> - 2011-04-01 11:54 +0200
csiph-web