[Python-3000] Fixing super anyone?

Guido van Rossum guido at python.org
Fri Apr 20 20:56:46 CEST 2007


If you are serious about this, it'd need a PEP, clarifying the use cases etc.

On 4/20/07, Phillip J. Eby <pje at telecommunity.com> wrote:
> At 10:53 AM 4/20/2007 -0700, Guido van Rossum wrote:
> >Also, what arguments are passed to the hook? For this purpose the
> >class object is the only thing needed -- but is that always
> >sufficient?
>
> I'd want to have the attribute name as an argument, too, at least for other
> uses of the hook.  PEAK and Chandler both have special metaclasses to do
> this sort of attribute-class association, and I believe Paste does too (it
> might be some other project(s) by Ian Bicking, e.g. SQLObject or
> FormEncode).  It comes up pretty much anywhere that people have some sort
> of object-attribute system.  Having a built-in hook for this would be nice.
>
> Ideally, the return value of the hook should then be used as the
> descriptor, rather than the original one; PEAK uses an approach like this
> to do things like:
>
>      class Whatever:
>          foo = bar = DelegateTo('otherattribute')
>
> where the foo and bar attributes are being set up to delegate to the foo
> and bar attributes of self.someattribute.  (i.e., foo and bar end up with
> separate descriptors, because the DelegateTo descriptor's association hook
> is called twice, once with 'foo' and once with 'bar', and the return values
> become the actual descriptors used in the class.)
>
> One question, however, would be whether it should refer to the class
> *after* decoration, or before.  For the super() use case, it would
> presumably need to be the *decorated* class, which might make things a bit
> more complicated.
>
> I also wonder if this hook mightn't be usable to implement abstractmethod
> as well?
>
>


-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-3000 mailing list