Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #45405
| Path | csiph.com!usenet.pasdenom.info!gegeweb.org!newsfeed.kamp.net!newsfeed.kamp.net!newsfeed.freenet.ag!news2.euro.net!newsfeed.xs4all.nl!newsfeed1.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.002 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'subject:not': 0.03; 'syntax': 0.04; 'classes,': 0.05; 'explicitly': 0.05; 'subject:Python': 0.06; 'classes.': 0.09; 'obj': 0.09; 'python': 0.11; 'def': 0.12; ':-p': 0.16; 'benjamin': 0.16; 'merely': 0.16; 'referencing': 0.16; 'subject: \n ': 0.16; 'subtype': 0.16; 'sugar': 0.16; 'syntactic': 0.16; 'typeerror:': 0.16; 'write,': 0.16; 'wrote:': 0.18; 'wed,': 0.18; '>>>': 0.22; 'subject:problem': 0.24; 'looks': 0.24; "i've": 0.25; '15,': 0.26; 'least': 0.26; 'primary': 0.26; 'header:In-Reply-To:1': 0.27; 'generally': 0.29; 'especially': 0.30; 'message- id:@mail.gmail.com': 0.30; 'code': 0.31; '"",': 0.31; '+0100,': 0.31; "d'aprano": 0.31; 'steven': 0.31; 'though.': 0.31; 'file': 0.32; 'class': 0.32; 'probably': 0.32; '(most': 0.33; 'skip:_ 10': 0.34; 'subject:with': 0.35; "can't": 0.35; 'received:209.85': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'really': 0.36; 'method': 0.36; 'should': 0.36; 'received:209': 0.37; 'clear': 0.37; 'expected': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'recent': 0.39; 'to:addr:python.org': 0.39; 'skip:u 10': 0.60; 'read': 0.60; 'course': 0.61; "you're": 0.61; 'making': 0.63; 'finally': 0.65; 'oscar': 0.84; 'subject: *': 0.84; 'subject:skip:o 10': 0.84; 'tied': 0.93; '2013': 0.98 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:mime-version:in-reply-to:references:from:date:message-id :subject:to:content-type; bh=785h7MLIl5Xsfzy6Hkg0WhsIw/8vYljdPCVriVHb8t8=; b=HktPR0zWZYTnouY/7419tvyte3Mo56SWduAIE97id0usLo4/pup6One0ZGgBua6AKs L0T8iVYzU5C2tdnJ5Ct9KLQJl/cLMb13NbsSvbb1R4/Kjyk9Eym5AfLxuxXs1HFlnRau tPLl6j1QKgV94xYdMkf5HqSEe7bSpYiMPavdZBQ2wL6rSw7C5dAOyPenMWJT3HKuJTOm 1Y1MOgIz7g/MCcgtpJ9VxYmqVtCd0CB5Y/mGnjbN/xXRe+NJm09jkTrt/G79qrM/Omh2 4LLrB/5bpY/2amy9+M7jFRJ8IsvF/KumopxK8+Ed6qSU1uuDt4issMT+XUgunu/hK7B9 pAFg== |
| X-Received | by 10.68.12.98 with SMTP id x2mr2994872pbb.92.1368686313638; Wed, 15 May 2013 23:38:33 -0700 (PDT) |
| MIME-Version | 1.0 |
| In-Reply-To | <51943f13$0$29997$c3e8da3$5496439d@news.astraweb.com> |
| References | <f4ce525a-2728-4ad6-9858-e9005534ee54@bz1g2000vbb.googlegroups.com> <mailman.1695.1368620192.3114.python-list@python.org> <51943f13$0$29997$c3e8da3$5496439d@news.astraweb.com> |
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Date | Thu, 16 May 2013 00:37:53 -0600 |
| Subject | Re: Python 2.7.x - problem with obejct.__init__() not accepting *args and **kwargs |
| To | Python <python-list@python.org> |
| Content-Type | text/plain; charset=ISO-8859-1 |
| 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.1737.1368686317.3114.python-list@python.org> (permalink) |
| Lines | 52 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1368686317 news.xs4all.nl 15983 [2001:888:2000:d::a6]:60715 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:45405 |
Show key headers only | View raw
On Wed, May 15, 2013 at 8:06 PM, Steven D'Aprano <steve+comp.lang.python@pearwood.info> wrote: > On Wed, 15 May 2013 13:16:09 +0100, Oscar Benjamin wrote: > > >> I don't generally use super() > > Then you should, especially in Python 3. > > If you're not using super in single-inheritance classes, then you're > merely making your own code harder to read and write, and unnecessarily > difficult for others to use with multiple-inheritance. > > If you're not using super in multiple-inheritance[1] classes, then your > code is probably buggy. > > There really is no good reason to avoid super in Python 3. The Python 3 syntactic sugar is the primary reason that I've finally started using super in single-inheritance classes. The magicalness of it still disturbs me a bit, though. >>> class A: ... def __str__(self): ... return super().__str__() ... >>> class B: ... __str__ = A.__str__ ... >>> A().__str__ <bound method A.__str__ of <__main__.A object at 0x0289E3B0>> >>> str(A()) '<__main__.A object at 0x0289E270>' >>> B().__str__ <bound method B.__str__ of <__main__.B object at 0x0289E470>> The transplanted __str__ method is considered a method of B by Python... >>> str(B()) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "<stdin>", line 3, in __str__ TypeError: super(type, obj): obj must be an instance or subtype of type But you can't use it because the super() call is irrevocably tied to class A. :-P Of course the same is true with the syntax "super(A, self)", but at least with that syntax it is clear that the method is explicitly referencing class A, and so should not be expected to work correctly in class B. By contrast the syntax "super()" looks misleadingly generic.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Python 2.7.x - problem with obejct.__init__() not accepting *args and **kwargs wzab <wzab01@gmail.com> - 2013-05-15 04:18 -0700
Re: Python 2.7.x - problem with obejct.__init__() not accepting *args and **kwargs Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-05-15 13:16 +0100
Re: Python 2.7.x - problem with obejct.__init__() not accepting *args and **kwargs Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-05-16 02:06 +0000
Re: Python 2.7.x - problem with obejct.__init__() not accepting *args and **kwargs Ian Kelly <ian.g.kelly@gmail.com> - 2013-05-16 00:37 -0600
Re: Python 2.7.x - problem with obejct.__init__() not accepting *args and **kwargs Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-05-16 11:31 +0100
Re: Python 2.7.x - problem with obejct.__init__() not accepting *args and **kwargs Ian Kelly <ian.g.kelly@gmail.com> - 2013-05-15 09:41 -0600
csiph-web