Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #24630
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!news.unit0.net!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; '%s"': 0.07; "'a'": 0.07; '"a"': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'def': 0.10; '"b"': 0.16; "'b'": 0.16; '(resulting': 0.16; 'a()': 0.16; 'a(object):': 0.16; 'b()': 0.16; 'classes:': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject:class': 0.16; 'subject:instance': 0.16; 'wed,': 0.16; '>>>': 0.18; 'all,': 0.21; 'question': 0.27; 'header:X-Complaints- To:1': 0.28; 'trouble': 0.28; 'question:': 0.29; 'subject:other': 0.29; 'skip:_ 10': 0.29; 'van': 0.29; 'class': 0.29; 'print': 0.32; 'url:home': 0.33; 'to:addr:python-list': 0.33; 'received:org': 0.36; 'method': 0.36; 'charset:us-ascii': 0.36; 'subject:: ': 0.38; 'some': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'ana': 0.91; 'dennis': 0.91; 'received:108': 0.91 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Dennis Lee Bieber <wlfraed@ix.netcom.com> |
| Subject | Re: moving methods from class to instance of other class |
| Date | Thu, 28 Jun 2012 14:15:05 -0400 |
| Organization | > Bestiaria Support Staff < |
| References | <c376d4cf-c888-4fa9-8d4c-032b80a43947@e20g2000vbm.googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=us-ascii |
| Content-Transfer-Encoding | 7bit |
| X-Gmane-NNTP-Posting-Host | adsl-108-68-178-241.dsl.klmzmi.sbcglobal.net |
| X-Newsreader | Forte Agent 3.3/32.846 |
| X-No-Archive | YES |
| 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.1617.1340907329.4697.python-list@python.org> (permalink) |
| Lines | 46 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1340907329 news.xs4all.nl 6840 [2001:888:2000:d::a6]:43804 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:24630 |
Show key headers only | View raw
On Wed, 27 Jun 2012 23:59:22 -0700 (PDT), lars van gemerden
<lars@rational-it.com> declaimed the following in
gmane.comp.python.general:
> Hi all,
>
> I have some trouble with the following question: Let say i have the
> following classes:
>
> class A(object):
> def __init__(self):
> self.name = 'a'
> def do(self):
> print 'A.do: self.name =', self.name
>
> class B(object):
> def __init__(self):
> self.name = 'b'
>
>
>
> The question is: How do i move the 'do' method from A to b (resulting
> in printing "A.do: self.name = b")?
>>> class A(object):
... def __init__(self):
... self.name = "a"
... def do(self):
... print "A.do: self.name = %s" % self.name
...
>>> class B(A):
... def __init__(self):
... super(B, self).__init__()
... self.name = "b"
...
>>> anA = A()
>>> aB = B()
>>> anA.do()
A.do: self.name = a
>>> aB.do()
A.do: self.name = b
>>>
--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
moving methods from class to instance of other class lars van gemerden <lars@rational-it.com> - 2012-06-27 23:59 -0700
Re: moving methods from class to instance of other class Benjamin Kaplan <benjamin.kaplan@case.edu> - 2012-06-28 00:22 -0700
Re: moving methods from class to instance of other class lars van gemerden <lars@rational-it.com> - 2012-06-28 01:14 -0700
Re: moving methods from class to instance of other class Terry Reedy <tjreedy@udel.edu> - 2012-06-28 13:57 -0400
Re: moving methods from class to instance of other class Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-06-28 14:15 -0400
csiph-web