[Python-Dev] Re: decorators and 2.4

Jewett, Jim J jim.jewett at eds.com
Mon Jun 28 12:28:04 EDT 2004


Phillip Eby:

> Is it the name you dislike?  Or the idea of simply 
> invoking decorating functions directly?

If decorate is a callable class rather than a function,
it can be subclassed for common idioms.  

The question is whether or not this is a good idea.  Any 
specific use will be more clear with a usage-specific
name, but the construct as a whole may be muddied if nothing
ties these names together.  For instance, it classmethod 
were subclassed from decorate (but used current usage when 
it got an argument), you could write

    classmethod()
    def f():
        pass

But you would also see things like

    dec1()	# No good way to chain decorators.
    def g():
        pass
    g=dec2(g)

Personally, I want decorators tied together with a word (such
as "decorate" or "using"), but I admit that list brackets + 
line-break *might* be enough.

    decorators(classmethod())
    def f(): 
        pass

    decorators(dec1(), dec2())
    def g():
        pass

vs

    [classmethod()]
    def f():
        pass

    [dec1(), dec2()]
    def g():
        pass


-jJ



More information about the Python-Dev mailing list