decorators ?

Jacek Generowicz jacek.generowicz at cern.ch
Wed Dec 1 07:53:56 EST 2004


BJörn Lindqvist <bjourne at gmail.com> writes:

> I think the essence of decorators is that it makes it possible to do
> in Python what you in other languages do with method qualifiers.

I find it fascinating that the addition of a bit of syntax sugar gives
the perception that a whole range of new and previously unthinkable
possibilities have opened themselves before us.

    @X
    def Y...
        ...
    

is merely syntax sugar (or syntax ammonia, for some) for


    def Y...
        ...
    Y = X(Y)

Anything you can do with decorators, you could do before (with the
exception of rebinding the __name__ of functions).

And yet, that bit of syntax sugar really _does_ make a big difference
to the lengths that people are prepared to take the possibilities that
the underlying feature affords them.



More information about the Python-list mailing list