Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #30520
| Path | csiph.com!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <jeanpierreda@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.013 |
| X-Spam-Evidence | '*H*': 0.97; '*S*': 0.00; '__init__': 0.09; 'received :mail-qc0-f174.google.com': 0.09; 'sep': 0.09; 'typeerror:': 0.09; 'cc:addr:python-list': 0.10; 'def': 0.10; 'sat,': 0.15; 'arbitrarily': 0.16; 'to:addr:pearwood.info': 0.16; 'to:addr:steve+comp.lang.python': 0.16; "to:name:steven d'aprano": 0.16; 'wrote:': 0.17; 'parameters': 0.20; '"",': 0.22; 'cc:2**0': 0.23; 'cc:no real name:2**0': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; '(most': 0.27; 'message- id:@mail.gmail.com': 0.27; "doesn't": 0.28; "d'aprano": 0.29; 'leaves': 0.29; 'steven': 0.29; 'skip:_ 10': 0.29; 'class': 0.29; 'code': 0.31; 'file': 0.32; 'traceback': 0.33; 'received:google.com': 0.34; 'pm,': 0.35; 'subject:?': 0.35; 'received:209.85': 0.35; 'add': 0.36; 'received:209': 0.37; 'received:209.85.216': 0.37; 'subject:: ': 0.38; 'object': 0.38; 'takes': 0.39; 'header:Received:5': 0.40; 'gone': 0.64; 'potentially': 0.66; '"just': 0.84; 'subject:always': 0.84; 'x):': 0.84; 'subject:add': 0.91 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=QbFoxEeNv9ymXxHXC7gBF1RhQpP0MXGpQ9hUarp/fxQ=; b=kJE58djBXZDArukRSEhDtP8p3jaOSjNfU9dE79GSV+jJ9sOEhgcAYOpKH4rY3FEd6w B9EFLe9SwJFZRP9c68ZfSLRWwQ7srUbM/SCdyVwiXIRDB1A2liI6NFpawn5ubIq59QzR R0rhxibRv4MZUfcl9CXQQnyUR4Ii4E0w67Lrnb1PnuxX5F1RH/jrL17MxN2t+UGRmsJJ TkkXmc1QLdC2qQNdjwAZIxs/roa418J5tl4H3G1TxGy1hjAbza502mv4dNzBJRbyXMwE MEAa2E1nq3uSZ8goKwcmTvPIV7twJbvm99xHk3S47I8JtBjuio5t8yjvApFXbpjskBTV +5+A== |
| MIME-Version | 1.0 |
| In-Reply-To | <50672d20$0$29981$c3e8da3$5496439d@news.astraweb.com> |
| References | <d8fc9d99-8dc0-4290-88a0-33cd38d09f7d@googlegroups.com> <50672d20$0$29981$c3e8da3$5496439d@news.astraweb.com> |
| From | Devin Jeanpierre <jeanpierreda@gmail.com> |
| Date | Sat, 29 Sep 2012 14:18:03 -0400 |
| Subject | Re: Should one always add super().__init__() to the __init__? |
| To | "Steven D'Aprano" <steve+comp.lang.python@pearwood.info> |
| Content-Type | text/plain; charset=UTF-8 |
| Cc | python-list@python.org |
| 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.1649.1348942728.27098.python-list@python.org> (permalink) |
| Lines | 24 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1348942728 news.xs4all.nl 6963 [2001:888:2000:d::a6]:45747 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:30520 |
Show key headers only | View raw
On Sat, Sep 29, 2012 at 1:17 PM, Steven D'Aprano <steve+comp.lang.python@pearwood.info> wrote: > No. Only add code that works and that you need. Arbitrarily adding calls > to the superclasses "just in case" may not work: > > > > py> class Spam(object): > ... def __init__(self, x): > ... self.x = x > ... super(Spam, self).__init__(x) > ... > py> x = Spam(1) > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > File "<stdin>", line 4, in __init__ > TypeError: object.__init__() takes no parameters That's a good thing. We've gone from code that doesn't call the initializer and leaves the object in a potentially invalid state (silently!), to code that calls the initializer and then fails (loudly). -- Devin
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Should one always add super().__init__() to the __init__? Ramchandra Apte <maniandram01@gmail.com> - 2012-09-29 06:27 -0700
Re: Should one always add super().__init__() to the __init__? Ramchandra Apte <maniandram01@gmail.com> - 2012-09-29 06:28 -0700
Re: Should one always add super().__init__() to the __init__? Ian Kelly <ian.g.kelly@gmail.com> - 2012-09-29 10:59 -0600
Re: Should one always add super().__init__() to the __init__? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-09-29 17:17 +0000
Re: Should one always add super().__init__() to the __init__? Devin Jeanpierre <jeanpierreda@gmail.com> - 2012-09-29 14:18 -0400
Re: Should one always add super().__init__() to the __init__? Chris Angelico <rosuav@gmail.com> - 2012-09-30 04:31 +1000
Re: Should one always add super().__init__() to the __init__? Piet van Oostrum <piet@vanoostrum.org> - 2012-09-29 17:51 -0400
Re: Should one always add super().__init__() to the __init__? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-09-30 04:40 +0000
Re: Should one always add super().__init__() to the __init__? Ian Kelly <ian.g.kelly@gmail.com> - 2012-09-30 00:08 -0600
Re: Should one always add super().__init__() to the __init__? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-09-30 09:34 +0000
Re: Should one always add super().__init__() to the __init__? Manuel Pégourié-Gonnard <mpg@elzevir.fr> - 2012-09-30 14:04 +0200
Re: Should one always add super().__init__() to the __init__? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-09-30 04:37 +0000
Re: Should one always add super().__init__() to the __init__? Chris Angelico <rosuav@gmail.com> - 2012-09-30 14:53 +1000
Re: Should one always add super().__init__() to the __init__? Ian Kelly <ian.g.kelly@gmail.com> - 2012-09-30 01:13 -0600
Re: Should one always add super().__init__() to the __init__? Ramchandra Apte <maniandram01@gmail.com> - 2012-09-29 20:14 -0700
Re: Should one always add super().__init__() to the __init__? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-09-30 04:23 +0000
Re: Should one always add super().__init__() to the __init__? Ramchandra Apte <maniandram01@gmail.com> - 2012-09-29 21:55 -0700
Re: Should one always add super().__init__() to the __init__? Ian Kelly <ian.g.kelly@gmail.com> - 2012-09-30 00:10 -0600
csiph-web