Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #13238

Re: Invoke a superclass method from a subclass constructor

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <ian.g.kelly@gmail.com>
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; 'instance': 0.05; 'does.': 0.07; 'imply': 0.07; 'python': 0.08; '>>>>': 0.09; 'created,': 0.09; 'module)': 0.09; 'subject:method': 0.09; 'am,': 0.12; 'def': 0.15; 'constructs': 0.16; 'executed,': 0.16; 'executed.': 0.16; 'wrote:': 0.16; 'language': 0.17; 'string,': 0.18; 'written,': 0.18; 'header:In-Reply-To:1': 0.22; 'tue,': 0.23; 'sep': 0.23; 'string': 0.26; 'message-id:@mail.gmail.com': 0.29; 'print': 0.29; 'oop': 0.30; 'class': 0.30; 'received:209.85.161.46': 0.31; 'received:mail-fx0-f46.google.com': 0.31; 'does': 0.32; 'it.': 0.33; 'to:addr:python-list': 0.33; '...': 0.34; 'all.': 0.34; 'do?': 0.34; 'received:209.85.161': 0.35; 'question': 0.36; 'returning': 0.38; 'received:google.com': 0.38; 'received:209.85': 0.38; 'should': 0.38; 'subject:: ': 0.39; 'to:addr:python.org': 0.39; 'subject:from': 0.40; 'your': 0.61; 'here': 0.65; 'unnecessary': 0.73; '10:56': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; bh=//ld9dE28Li4M9tFGm3ggyRYymgO/gWthHIwaxzEJfY=; b=WXljcp3Uov7QGjZZKDFlvLVXJZod8/drdOjp9tXUP7z+Y9xVYIehZT5GAyEOR4ExjE tcTLzcIr2yQjKTovFMN15d04sWetDjX56WqG24zfEgdyibszgdrY0dDgJMIpj/efN8G1 Pn5dEfhv2bhwolkdW1A/cMtvV5yc90x/gCfkY=
MIME-Version 1.0
In-Reply-To <CAPbrmCtEemgxBC1RRjFSmuePsp8AkO8FTO95orJ_T3MMB=j3Og@mail.gmail.com>
References <CAPbrmCtnuAGk=T=hS43GH5g_Tx2oAGbQJ+AODrVfc5jxyQk7RA@mail.gmail.com> <4E6C9044.5060302@jollybox.de> <CAPbrmCua4wZFJEyiTJHe5Wo_+ho_Q=F-GRsYvSs_FqEdNTP_Xw@mail.gmail.com> <0604E20B5F6F2F4784C9C8C71C5DD4DD2F16B197E2@EMARC112VS01.exchad.jpmchase.net> <0604E20B5F6F2F4784C9C8C71C5DD4DD2F16B1987A@EMARC112VS01.exchad.jpmchase.net> <CAPbrmCtEemgxBC1RRjFSmuePsp8AkO8FTO95orJ_T3MMB=j3Og@mail.gmail.com>
From Ian Kelly <ian.g.kelly@gmail.com>
Date Tue, 13 Sep 2011 11:24:34 -0600
Subject Re: Invoke a superclass method from a subclass constructor
To Python <python-list@python.org>
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding quoted-printable
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.1080.1315934926.27778.python-list@python.org> (permalink)
Lines 30
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1315934927 news.xs4all.nl 2500 [2001:888:2000:d::a6]:35506
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:13238

Show key headers only | View raw


On Tue, Sep 13, 2011 at 10:56 AM, Kayode Odeyemi <dreyemi@gmail.com> wrote:
>>>> class B(A):
> ...     def __init__(self, module):
> ...             self.module = A.log(self, module)
> ...             print self.module # printing here is completely unnecessary
> in a good OOP language
> ...
>>>> c = B('system')
> logged
>>>> class B(A):
> ...     def __init__(self, module):
> ...             print super(B, self).log('system') # printing here is
> completely unnecessary in a good OOP language
> ...
>>>> c = B('system')
> logged
>>>>
> When an instance of a class is created, all codes within that instance block
> should be executed. That's my understanding of OOP.

The initializer should be executed, which is what Python does.  Your
initializer then calls A.log, which does nothing interesting at all.

My question is, what exactly is it that you intend A.log to do?  As
written, it does not do any logging.  It merely constructs a string
and then returns it.  Neither constructing a string, nor returning a
string, imply logging it or printing it.

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Invoke a superclass method from a subclass constructor Ian Kelly <ian.g.kelly@gmail.com> - 2011-09-13 11:24 -0600

csiph-web