"Thomas Wouters" <[EMAIL PROTECTED]> wrote: > On 12/6/06, Jan Grant <[EMAIL PROTECTED]> wrote: > > On Mon, 4 Dec 2006, Ben Wing wrote: > > > > > as a result, i imagine there's a strong urge to just hardcode the name > > > of the parent > > ^^^^^^^^^^ > > > > > -- super.meth(args) calls the superclass method `meth' > > ^^^^^^^^^^^^^^ > > > > Python supports multiple inheritance, unlike Java; the design mantra is > > "explicit is better than implicit" and "ambiguity should be an error". > > Two! The two design mantras are... > > > You forget that that's actually what super() is for. It does the right thing > in the case of MI (and every other case, in fact :-)
Except for this one: >>> class foo(object): ... pass ... >>> class bar(foo): ... def method(self): ... super(bar, self).method() ... >>> bar().method() Traceback (most recent call last): File "<stdin>", line 1, in ? File "<stdin>", line 3, in method AttributeError: 'super' object has no attribute 'method' >>> Because of this kind of thing, I do my best to never produce code that has a diamond inheritance structure (except for object), and always use things like foo.method(self). - Josiah _______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com