[Python-3000] PEP 3124 - Overloading, Generic Functions, Interfaces, etc.

Greg Ewing greg.ewing at canterbury.ac.nz
Thu May 10 04:56:08 CEST 2007

Phillip J. Eby wrote:

> Which is an excellent demonstration, by the way, of another reason 
> why before/after methods are useful.  They're all *always* called 
> before and after the primary methods, regardless of how many of them 
> were registered.

But unless I'm mistaken, ClassC can still take over the
whole show using a method that doesn't call the next

>     debug = Debug.make_decorator('debug')
>     always_overrides(Debug, Around)
>     always_overrides(Debug, Method)
>     always_overrides(Debug, Before)
>     always_overrides(Debug, After)

This is getting seriously brain-twisting. Are you saying
that this somehow overrides the subclass relationships,
so that an @Debug method for ClassA always gets called
before other methods, even ones for ClassC? If so, I
think this is all getting way too deeply magical.

Also, you still can't completely win, as someone could
define an @UtterlySelfish decorator that takes precedence
over your @Debug decorator.

For that matter, what if there is simply another
decorator @Foo that is defined to always_override
@Around? The precedence between that and your
@Debug decorator then appears to be undefined.

Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury,	   | Carpe post meridiem!          	  |
Christchurch, New Zealand	   | (I'm not a morning person.)          |
greg.ewing at canterbury.ac.nz	   +--------------------------------------+

More information about the Python-3000 mailing list