Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #21390
| Path | csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!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.004 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'python': 0.08; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'def': 0.13; 'explicitly.': 0.16; 'received:dip.t-dialin.net': 0.16; 'received:t-dialin.net': 0.16; 'wrote:': 0.18; '>>>': 0.18; 'from:addr:web.de': 0.23; 'figure': 0.26; 'there.': 0.27; 'pass': 0.29; 'class': 0.29; 'print': 0.29; '"in': 0.30; 'parent': 0.30; 'header:User-Agent:1': 0.33; 'header:X-Complaints-To:1': 0.34; 'to:addr:python-list': 0.35; 'received:org': 0.36; 'skip:_ 10': 0.38; 'to:addr:python.org': 0.40; 'maarten': 0.91 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Peter Otten <__peter__@web.de> |
| Subject | Re: newb __init__ inheritance |
| Date | Thu, 08 Mar 2012 18:03:25 +0100 |
| Organization | None |
| References | <1c6db866-6fa3-4de5-96de-51d6720a1300@x17g2000yqj.googlegroups.com> <13988849.1044.1331224217273.JavaMail.geo-discussion-forums@ynnk21> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset="ISO-8859-1" |
| Content-Transfer-Encoding | 7Bit |
| X-Gmane-NNTP-Posting-Host | p5084ac8a.dip.t-dialin.net |
| User-Agent | KNode/4.7.3 |
| 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.514.1331226222.3037.python-list@python.org> (permalink) |
| Lines | 41 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1331226223 news.xs4all.nl 6858 [2001:888:2000:d::a6]:45091 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:21390 |
Show key headers only | View raw
Maarten wrote: > Alternatively you can figure out the parent class with a call to super: This is WRONG: > super(self.__class__, self).__init__() You have to name the current class explicitly. Consider: >> class A(object): ... def __init__(self): ... print "in a" ... >>> class B(A): ... def __init__(self): ... print "in b" ... super(self.__class__, self).__init__() # wrong ... >>> class C(B): pass ... >>> Can you figure out what C() will print? Try it out if you can't. The corrected code: >>> class B(A): ... def __init__(self): ... print "in b" ... super(B, self).__init__() ... >>> class C(B): pass ... >>> C() in b in a <__main__.C object at 0x7fcfafd52b10> In Python 3 you can call super() with no args; super().__init__() do the right thing there.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
newb __init__ inheritance hyperboogie <hyperboogie@gmail.com> - 2012-03-08 07:25 -0800
Re: newb __init__ inheritance Maarten <maarten.sneep@knmi.nl> - 2012-03-08 08:30 -0800
Re: newb __init__ inheritance Peter Otten <__peter__@web.de> - 2012-03-08 18:03 +0100
Re: newb __init__ inheritance Ethan Furman <ethan@stoneleaf.us> - 2012-03-08 09:34 -0800
Re: newb __init__ inheritance "Colin J. Williams" <cjw@ncf.ca> - 2012-03-10 12:58 -0500
Re: newb __init__ inheritance "Colin J. Williams" <cjw@ncf.ca> - 2012-03-10 17:47 -0500
Re: newb __init__ inheritance hyperboogie <hyperboogie@gmail.com> - 2012-03-11 03:18 -0700
Re: newb __init__ inheritance Chris Rebert <clp2@rebertia.com> - 2012-03-11 03:38 -0700
Re: newb __init__ inheritance hyperboogie <hyperboogie@gmail.com> - 2012-03-11 03:56 -0700
Re: newb __init__ inheritance Chris Rebert <clp2@rebertia.com> - 2012-03-11 04:37 -0700
Re: newb __init__ inheritance Ian Kelly <ian.g.kelly@gmail.com> - 2012-03-11 05:40 -0600
Re: newb __init__ inheritance Ian Kelly <ian.g.kelly@gmail.com> - 2012-03-11 05:52 -0600
Re: newb __init__ inheritance Peter Otten <__peter__@web.de> - 2012-03-11 13:12 +0100
Re: newb __init__ inheritance hyperboogie <hyperboogie@gmail.com> - 2012-03-11 03:56 -0700
Re: newb __init__ inheritance hyperboogie <hyperboogie@gmail.com> - 2012-03-12 02:09 -0700
csiph-web