[Python-3000] Fixing super anyone?

Michele Cella michele.cella at gmail.com
Mon Apr 23 23:08:03 CEST 2007

Thomas Wouters wrote:
> But how would it *work*? I assume you want 'super' to take a single 
> expression, and be an expression itself. How does it know which instance 
> you want to 'super'? Does it specialcase the variable named 'self'? 
> Threat 'everything up to the first dot' as 'the instance'? Specialcase 
> the first argument to the method? (That's what ' super.foo()' would do.) 
> How would you do things like:
>   # call the supermethod 'register' with the nonsuper 'callback':
>   super.register(self.callback)
>   # call the nonsuper 'register' with the supermethod 'callback'
>   self.register(super.callback)
>   # call the 'frominstance' method of the 'innerclass' attribute on the 
> superclass
>   super.innerclass.frominstance(self)

Hi Thomas,

Yes, you raise good points.

My solution is nice (IMHO) for the simplest use case (and, probably, the 
most frequent) but it's behavior is really unclear for these complex use 
cases. Thanks for pointing that out.

As far as I'm concerned, I can only confirm that having a super keyword 
with methods attached (like Aahz said) when no other keyword has (and 
there are many) doesn't feel right (to me) and can be confusing at 
first. That's unfortunate as I rarely found python confusing up to now 
(contrary to other languages).

The only other option that comes to my mind is using a special attribute 
in the instance itself (like __class__, __dict__, ...):


I'm sure this (again) introduces other problems I simply overlooked, in 
this case, forgive me please. ;-)

Thanks again for your attention.


More information about the Python-3000 mailing list