[Python-Dev] New Super PEP

James Y Knight foom at fuhm.net
Sun Apr 29 06:12:12 CEST 2007


On Apr 28, 2007, at 10:43 PM, Calvin Spealman wrote:
> Abstract
> ========
>
> The PEP defines the proposal to enhance the super builtin to work  
> implicitly
> upon the class within which it is used and upon the instance the  
> current
> function was called on. The premise of the new super usage  
> suggested is as
> follows:
>
>     super.foo(1, 2)
>
> to replace the old:
>
>     super(Foo, self).foo(1, 2)
>
>
> Rationale
> =========
>
> The current usage of super requires an explicit passing of both the  
> class and
> instance it must operate from, requiring a breaking of the DRY  
> (Don't Repeat
> Yourself) rule. This hinders any change in class name, and is often  
> considered
> a wart by many.

This is only a halfway fix to DRY, and it really only fixes the less  
important half. The important problem with super is that it  
encourages people to write incorrect code by requiring that you  
explicitly specify an argument list. Since calling super with any  
arguments other than the exact same arguments you have received is  
nearly always wrong, requiring that the arglist be specified is an  
attractive nuisance.

Now, I'm no syntax designer, but, just being able to say "super()"  
seems nice to me. (but don't get too hung up on that spelling, the  
concept of not having to repeat the arglist is the important point.)

James




More information about the Python-Dev mailing list