[Python-3000] A super() idea - no _getframe() involved
Guido van Rossum
guido at python.org
Wed Apr 19 10:06:41 CEST 2006
On 4/19/06, Phillip J. Eby <pje at telecommunity.com> wrote:
> Here's how you solve the "how does super() get the current class" problem,
> using existing compiler and VM constructs, and without relying on class
> names, or on functions not being decorated, or anything like that. And
> it's so simple you'll slap your forehead for not thinking of it first. :)
Actually, I *did* think of it first. :-)
http://mail.python.org/pipermail/python-3000/2006-April/000947.html
And no, I didn't use the time machine to plant that. :-)
Regarding the syntax, IMO *if* we use this we should do it so that you can write
super.foobar(args)
where currently you'd write
super(ClassName, self).foobar(args)
'super' could be a new keyword. In 3.0 we could just make the keyword
expand to a magic built-in function with the appropriate arguments
(the magic cell and the first function argument). We could probably
introduce this in 2.6 if the super object, when called, would return
itself; then IMO no __future__ statement would be required since
existing code using super would continue to work.
Oh, I believe super() also supports static and/or class methods. I'm
not sure how to handle this but I'm sure you can think of something.
--
--Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the Python-3000
mailing list