Thanks for proposing this -- I've been scratching my head wondering what the use of unbound super() would be. :-) I'm fine with killing it -- perhaps someone can do a bit of research to try and find out if there are any real-life uses (apart from various auto-super clones)?
--Guido On 9/1/07, Michele Simionato <[EMAIL PROTECTED]> wrote: > So Python 3000a1 is out! Kudos to everybody involved! > You did an incredible amount of work in a relatively short time! :-) > > Having said that, let me go to the point. This morning I downloaded > the tarball and compiled everything without issues, then I > started playing around. One of the first thing I looked at was the new > super, since it is a matter that made me scratch my head a lot in the > past. Basically I am happy with the implementation, especially about > the new magic name __class__ inside the methods which is something I > always wanted. So I am not here to ask for new features. I am actually > here to ask for less features: specifically, I would like the unbound > syntax for super to be removed. I am talking about this: > > >>> help(super) > Help on class super in module __builtin__: > > class super(object) > | super() -> same as super(__class__, <first argument>) > | super(type) -> unbound super object > | super(type, obj) -> bound super object; requires isinstance(obj, type) > | super(type, type2) -> bound super object; requires issubclass(type2, type) > > > The single argument syntax 'super(type)' is what I call the unbound syntax. > I would like 'super(type)' to be removed from the valid signatures. > AFAIK, the only use case for it was the implementation of the autosuper > recipe in Guido's new style classes essay. That use case has disappeared > nowadays, and I cannot think of other situations where may want to use > that feature (you may think differently, if so, please speak). > The other reason why I would like it to be removed (apart from the fact > that it looks unneeded to me) is that is very difficult to explain to > beginners. For instance in the past I lectured on Python, and in order > to explain why unbound super objects can be useful I gave this example, > which is basically Guido's autosuper recipe implemented by hand: > > class B(object): > def __repr__(self): > return '<instance of %s>' % self.__class__.__name__ > [EMAIL PROTECTED] > def cmeth(self): > print("B.meth called from %s" % self) > > class C(B): > [EMAIL PROTECTED] > def cmeth(self): > print("C.meth called from %s" % self) > self.__super.cmeth() > > C._C__super = super(C) > > c = C() > > c.cmeth() > > Here everything works because the unbound super object is a descriptor > and self.__super calls super(C).__get__(self, C) which corresponds > to the bound method super(C, self) which is able to dispatch to .cmeth. > However, if you uncomment the classmethod decorator, self.__super (where > self is now the class C) will just return the unbound super object super(C) > which is unable to dispatch to .cmeth. Now, try to explain that to a beginner! > We can leave just as well without unbound super methods, so let's take > the occasion of Python3k to remove this glitch. > > > Michele Simionato > _______________________________________________ > 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/guido%40python.org > -- --Guido van Rossum (home page: http://www.python.org/~guido/) _______________________________________________ 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