Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #52822
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eweka.nl!lightspeed.eweka.nl!194.109.133.83.MISMATCH!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <fabiosantosart@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; 'classes,': 0.05; 'subject:Python': 0.06; 'class,': 0.07; 'method.': 0.07; '__init__': 0.09; 'used.': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'def': 0.12; '"in': 0.16; '"in': 0.16; 'called,': 0.16; 'executed.': 0.16; 'instantiated': 0.16; 'precedence': 0.16; 'subclass': 0.16; 'subject:Query': 0.16; '\xa0print': 0.16; 'wrote:': 0.18; 'all,': 0.19; 'starts': 0.20; 'example': 0.22; 'aug': 0.22; 'cc:addr:python.org': 0.22; 'print': 0.22; 'cc:2**1': 0.23; 'creating': 0.23; 'flows': 0.24; 'instance,': 0.24; 'question': 0.24; 'cc:no real name:2**0': 0.24; '>': 0.26; 'second': 0.26; 'header:In-Reply-To:1': 0.27; 'message-id:@mail.gmail.com': 0.30; 'code': 0.31; 'that.': 0.31; '"': 0.31; 'class': 0.32; 'cases': 0.33; 'skip:_ 10': 0.34; 'created': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'described': 0.36; 'method': 0.36; 'example,': 0.37; 'skip:& 10': 0.38; 'either': 0.39; '8bit%:6': 0.40; 'remove': 0.60; 'worry': 0.60; 'skip:t 30': 0.61; 'first': 0.61; 'dont': 0.67; ',the': 0.84; "class's": 0.84; 'to:addr:yahoo.co.in': 0.91; '2013': 0.98 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=0CLDrhfCDf37vXeznBcb6RUCu4MfK4QEU2GBaWGeYN4=; b=dmqGN2WDXw/BlTcglmIWF0FdvLFJLZx13Fy5Un7c4oumQKU6l9BCthkY7U4w0NmkzR YdmlLaeAQTR0DnTRWwFqm0ZUvJuMNj3+ar0hEQjQRQXedNISfUsfLNZl5SFXwUnSpGFK mk7Q1M3Yf98c9ozZ7d5WYRtAIlPY/DwSB2QM1V899YKdAyUzSBxKYtVz/p50xOFA6v6X 8Oev9bAkh/jfbG6cl6Oje3ZOIcyLtHtvOqNgyNJ0D0P4NSDoFljVKQrysMN+F3EzwkF/ HWKubt5j0e1wRTHztNbeT8/nJ6q3Y3lJN3Mgbc9ydsNcdsnaAVlhqV66dasobMQeqv5T wZeA== |
| MIME-Version | 1.0 |
| X-Received | by 10.52.227.6 with SMTP id rw6mr8809103vdc.19.1377161193194; Thu, 22 Aug 2013 01:46:33 -0700 (PDT) |
| In-Reply-To | <1377158037.22487.YahooMailBasic@web190503.mail.sg3.yahoo.com> |
| References | <kv32q9$rd2$1@news.albasani.net> <1377158037.22487.YahooMailBasic@web190503.mail.sg3.yahoo.com> |
| Date | Thu, 22 Aug 2013 09:46:33 +0100 |
| Subject | Re: Basic Python Query |
| From | Fábio Santos <fabiosantosart@gmail.com> |
| To | chandan kumar <chandan_psr@yahoo.co.in> |
| Content-Type | multipart/alternative; boundary=089e01161660b80afd04e485535d |
| Cc | python-list@python.org, Johannes Bauer <dfnsonfsduifb@gmx.de> |
| 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.125.1377161201.19984.python-list@python.org> (permalink) |
| Lines | 112 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1377161201 news.xs4all.nl 15950 [2001:888:2000:d::a6]:37420 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:52822 |
Show key headers only | View raw
[Multipart message — attachments visible in raw view] - view raw
On 22 Aug 2013 08:58, "chandan kumar" <chandan_psr@yahoo.co.in> wrote: > > Hi all, > > Sorry for not explaining question properly.Here Its not about threading and dont worry about any indentations.Please see below example > > class Call_Constructor(): > def __init__(self): > print "In __init__ " > > class Test_Constructor(Call_Constructor): > def method(self): > print " In Test_Constructor Class" > > ConstructInstance = Test_Constructor() > > When an instace is created for Test_Constructor class ,The code flows starts __init__ in Call_Constructor class.Whys is it like that. > > > class Call_Constructor(): > def __init__(self): > print "In __init__ " > > > class Test_Constructor(Call_Constructor): > def __init__(self): > print " In Test_Constructor Class" > > ConstructInstance = Test_Constructor() > > But for the above case Code flows starts from Test_Constructor(). > > Whats is the difference for both cases described above. > > Best Regards, > Chandan. When creating an instance, Python will call __init__. In the first example there was only an __init__ method in the base class, so that one was used. On the second example, there were __init__ methods on both classes, but since you instantiated the subclass, the subclass's __init__ method was executed. Subclass methods have precedence over base class methods. If you want the __init__ method of the base class in the second example to be called, you can either remove the subclass __init__ method or call super(TestConstructor, self).__init__() in that method. That will call the base class's __init__.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Basic Python Query chandan kumar <chandan_psr@yahoo.co.in> - 2013-08-21 14:50 +0800
Re: Basic Python Query Steven D'Aprano <steve@pearwood.info> - 2013-08-21 08:19 +0000
Re: Basic Python Query Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2013-08-21 11:11 +0200
Re: Basic Python Query Johannes Bauer <dfnsonfsduifb@gmx.de> - 2013-08-21 20:58 +0200
Re: Basic Python Query Fábio Santos <fabiosantosart@gmail.com> - 2013-08-21 23:50 +0100
Re: Basic Python Query Johannes Bauer <dfnsonfsduifb@gmx.de> - 2013-08-22 10:49 +0200
Re: Basic Python Query Ned Batchelder <ned@nedbatchelder.com> - 2013-08-21 20:06 -0400
Re: Basic Python Query Bob Martin <bob.martin@excite.com> - 2013-08-22 06:43 +0100
Re: Basic Python Query Ned Batchelder <ned@nedbatchelder.com> - 2013-08-22 09:45 -0400
Re: Basic Python Query Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-08-23 03:12 +0000
Re: Basic Python Query random832@fastmail.us - 2013-08-22 14:57 -0400
Re: Basic Python Query Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-08-22 18:22 -0400
Re: Basic Python Query random832@fastmail.us - 2013-08-23 01:08 -0400
Re: Basic Python Query Johannes Bauer <dfnsonfsduifb@gmx.de> - 2013-08-22 10:50 +0200
Re: Basic Python Query Fábio Santos <fabiosantosart@gmail.com> - 2013-08-22 09:46 +0100
Re: Basic Python Query Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2013-08-22 13:54 +0200
Re: Basic Python Query Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-08-23 03:28 +0000
Re: Basic Python Query Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2013-08-23 09:12 +0200
Re: Basic Python Query Chris Angelico <rosuav@gmail.com> - 2013-08-24 01:50 +1000
csiph-web