Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #42560
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder7.xlned.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.001 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'advance': 0.07; 'derived': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:members': 0.09; 'def': 0.12; 'anyway': 0.14; 'question.': 0.14; 'merged': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject:class': 0.16; 'all,': 0.19; 'this?': 0.23; 'header:User-Agent:1': 0.23; 'pass': 0.26; 'header:X-Complaints-To:1': 0.27; 'way?': 0.31; 'class': 0.32; 'says': 0.33; 'could': 0.34; 'there': 0.35; 'thanks': 0.36; 'two': 0.37; 'follows:': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'extended': 0.61; 'received:186': 0.93 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Fabian PyDEV <pydev@hotmail.com> |
| Subject | extending class static members and inheritance |
| Date | Tue, 02 Apr 2013 08:27:25 -0500 |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=ISO-8859-1 |
| Content-Transfer-Encoding | 7bit |
| X-Gmane-NNTP-Posting-Host | 186.68.114.214 |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/17.0 Thunderbird/17.0 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| 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.38.1364909383.17481.python-list@python.org> (permalink) |
| Lines | 42 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1364909383 news.xs4all.nl 6971 [2001:888:2000:d::a6]:48969 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:42560 |
Show key headers only | View raw
Hi All, I have a question. Let says I have the following two classes: class Base(object): __mylist__ = ["value1", "value2"] def somemethod(self): pass class Derived(Base): __mylist__ = ["value3", "value4"] def anothermethod(self): pass what I would like to accomplish is that the class Derived has the member __mylist__ extended or merged as ["value1", "value2", "value3", "value4"]. Is there anyway I could accomplish this? I was thinking on accomplishing this as follows: class Derived(Base): __mylist__ = Base.__mylist__ + ["value3", "value4"] def anothermethod(self): pass Is there a better way? Perhaps a decorator? Thanks in advance and regards, Fabian
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
extending class static members and inheritance Fabian PyDEV <pydev@hotmail.com> - 2013-04-02 08:27 -0500
csiph-web