Does 'super' exist?
Bruce Eckel
Bruce at EckelObjects.com
Sun Dec 9 13:35:59 EST 2001
You refer to this:
def super(self):
return self.__class__.__bases__[0]
class D(C):
def hello(self):
super(self).dothis(self)
which flips a little experience switch in my head: If I do
something like this which is ONLY a renaming of some existing thing
(especially such a fundamental, important thing as a base-class
call), and which doesn't actually add value, then people spend
valuable brain cycles translating it in their head, and I end up
having to explain it so many times so that it becomes embarrassing.
This happened to some degree with Java's awful
'System.out.println()' which I tried shortening to prt() or
something, but finally realized that everytime someone saw that
they'd have to think "oh, that's actually System.out.println(),"
wasting one of the 7+-2 things they can hold in their head at any
one time.
*********** REPLY SEPARATOR ***********
On 12/9/01 at 12:09 PM Tim Peters wrote:
>[Bruce Eckel]
>> Thanks. Looks like the syntax for calling the base-class B's
>> constructor would then be:
>> super(B, self).__init__()
>> I see the value of super() for MI but I was thinking I might get
a
>> free ride in the form of less typing for SI base-class calls. Oh
>> well.
>
>You may someday, but not in 2.2. The new 2.2 class features, from
super()
>to staticmethod(), are spelled in a very Lispish way. Guido is
keen to add
>nicer syntax for some (perhaps all) of them, but in later
releases. For
>SI,
>you can get less typing today by doing, e.g.,
>
> B.__init__(self)
>
>Another idea is in
>
> http://aspn.activestate.com/ASPN/Mail/Message/248323
>
>
>--
>http://mail.python.org/mailman/listinfo/python-list
Most current information can be found at:
http://www.mindview.net/Etc/notes.html
===================
Bruce Eckel http://www.BruceEckel.com
Contains free electronic books: "Thinking in Java 2e" & "Thinking
in C++ 2e"
Please subscribe to my free newsletter -- just send any email to:
join-eckel-oo-programming at earth.lyris.net
My schedule can be found at:
http://www.mindview.net/Calendar
===================
More information about the Python-list
mailing list