Question about accessing class-attributes.

Alex Martelli aleax at aleax.it
Fri May 2 12:19:15 EDT 2003


Michele Simionato wrote:
   ...
> superclass is B. Then we say to the newbie that super(A,C).a is *ideally*
> equivalent to B.a and therefore it returns 45.
> 
> If super had a __superclass__ attribute I could say to the newbie
> 
> super(A,C).a <=> super(A,C).__superclass__.a <=> B.a
> 
> Of course, the equivalence would not be exact in subtle cases,
> i.e. when B does not have an 'a' attribute, nor it inherits it,
> but it has (or inherits) a __getattr__ defining 'a' (as Bjorn
> pointed out)
> Still in the typical case there would be equivalence.
> 
> I made my point clear, now ? At least, this is the way I followed
> to teach to myself how super works.

Sorry, you still haven't made your point clear to me.  What IS
the added value of that "__superclass__" attribute when its whole
point now seems to be that in the typical case it does nothing?

You asked for __superclass__ as an attribute of classes.  Now it
seems that what you want is an extra attribute of the 'super'
object -- or is it, that you want an attribute of all classes
which is ALSO special in the super object?  I really do not at
all understand what you're asking for nor what the point would be.


Alex





More information about the Python-list mailing list