Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #13122
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeder.news-service.com!news2.euro.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <SRS0=5uSt=34=ieee.org=davea@srs.perfora.net> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.007 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'instance': 0.05; 'method,': 0.07; '>>>>': 0.09; 'module)': 0.09; 'referenced': 0.09; 'subclass': 0.09; 'subject:method': 0.09; 'def': 0.15; 'method.': 0.15; 'constructor,': 0.16; 'cc:addr:python-list': 0.16; 'wrote:': 0.16; 'cc:no real name:2**0': 0.20; 'this?': 0.21; "doesn't": 0.22; 'cc:2**0': 0.22; 'header:In-Reply-To:1': 0.22; 'pm,': 0.24; 'expect': 0.25; 'modify': 0.28; 'temporary': 0.29; 'print': 0.29; 'cc:addr:python.org': 0.30; 'invoke': 0.30; 'class': 0.30; 'does': 0.32; "can't": 0.33; '...': 0.34; 'header :User-Agent:1': 0.34; 'statement,': 0.34; 'object': 0.35; 'good.': 0.37; 'passed': 0.37; 'could': 0.38; 'think': 0.38; 'some': 0.38; 'should': 0.38; 'subject:: ': 0.39; 'received:192': 0.39; 'missing': 0.39; 'why': 0.39; 'subject:from': 0.40; 'here': 0.65; 'header:Reply-To:1': 0.71; 'reply-to:no real name:2**0': 0.71; '02:59': 0.84; 'reasoning': 0.84 |
| Date | Sun, 11 Sep 2011 07:55:31 -0400 |
| From | Dave Angel <davea@ieee.org> |
| User-Agent | Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.21) Gecko/20110831 Thunderbird/3.1.13 |
| MIME-Version | 1.0 |
| To | Kayode Odeyemi <dreyemi@gmail.com> |
| Subject | Re: Invoke a superclass method from a subclass constructor |
| References | <CAPbrmCtnuAGk=T=hS43GH5g_Tx2oAGbQJ+AODrVfc5jxyQk7RA@mail.gmail.com> |
| In-Reply-To | <CAPbrmCtnuAGk=T=hS43GH5g_Tx2oAGbQJ+AODrVfc5jxyQk7RA@mail.gmail.com> |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Provags-ID | V02:K0:AOMPc80Zuv4DA4yOtAeCEXXDDz6wm8wsU9k94o7if5J pXGTnEwg99MezSZ3RsYmYFH9MQh0hxTHLKODLcblIsoqPALFqt ZN4Qu21vrjfKXyDKV2kgt/CxQOQE1fElwE0444BB9vqHwxP7/q /KLgvlkgmnFOUlgq4r6NY208R8DsTYqSNb0gMK1N6zJz2VImAt cwzn8uGIR1Up59HwHI4ko87RKyvHcJmnC+ZFLx3cy5TTn32bEy GAk/p6sjJ/agjEPNFDFpBsKtFu/g06D33kQAbY8U9S/W3taCgY MBfEwpz+qL6F3j25gTaSuQ6bylOiGrTlaJhO/PqbMn5YDBv2LF AEpWLvy9XLnXHuVROjhs= |
| Cc | python-list@python.org |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| Precedence | list |
| Reply-To | davea@ieee.org |
| 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.982.1315742183.27778.python-list@python.org> (permalink) |
| Lines | 41 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1315742183 news.xs4all.nl 2426 [2001:888:2000:d::a6]:53686 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:13122 |
Show key headers only | View raw
On 01/-10/-28163 02:59 PM, Kayode Odeyemi wrote:
> Hello friends,
>
> An instance of my subclass doesn't invoke its superclass method, except when
> it is referenced
> directly.
>
> Here is what I mean:
>
>>>> class A(object):
> ... def log(self, module):
> ... return str('logged')
> ...
>
>>>> class B(A):
> ... def __init__(self, module):
> ... self.module = A().log(module)
> ...
>>>> c = B('system')
>>>> # I expect 'logged' to be printed here
>>>> print c.log('system') # why do I have to do this?
>>>> 'logged'
> Why do I have to make a call to c.log before log() method can be invoked?
>
> My reasoning is such that since I have passed the log() method to B's
> constructor, an instance
> of B should invoke A's log() method.
>
> What could I be missing in class A or B to have this working as expected?
What makes you think that A.log() was not invoked???
You have no print statement, so you can't tell that way. All the method
does is to modify a temporary object of type A, so you can't tell that way.
Perhaps you mean to write
self.module = A.log(self, module)
So that the return value could do some good.
DaveA
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Invoke a superclass method from a subclass constructor Dave Angel <davea@ieee.org> - 2011-09-11 07:55 -0400
csiph-web