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: 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: References: <4E6C9044.5060302@jollybox.de> <0604E20B5F6F2F4784C9C8C71C5DD4DD2F16B197E2@EMARC112VS01.exchad.jpmchase.net> <0604E20B5F6F2F4784C9C8C71C5DD4DD2F16B1987A@EMARC112VS01.exchad.jpmchase.net> From: Ian Kelly Date: Tue, 13 Sep 2011 11:24:34 -0600 Subject: Re: Invoke a superclass method from a subclass constructor To: Python 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: 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 On Tue, Sep 13, 2011 at 10:56 AM, Kayode Odeyemi wrote: >>>> class B(A): > ... =A0 =A0 def __init__(self, module): > ... =A0 =A0 =A0 =A0 =A0 =A0 self.module =3D A.log(self, module) > ... =A0 =A0 =A0 =A0 =A0 =A0 print self.module # printing here is complete= ly unnecessary > in a good OOP language > ... >>>> c =3D B('system') > logged >>>> class B(A): > ... =A0 =A0 def __init__(self, module): > ... =A0 =A0 =A0 =A0 =A0 =A0 print super(B, self).log('system')=A0# printi= ng here is > completely unnecessary in a good OOP language > ... >>>> c =3D B('system') > logged >>>> > When an instance of a class is created, all codes within that instance bl= ock > 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.