decorators as generalized pre-binding hooks

Terry Reedy tjreedy at udel.edu
Sun Jul 10 16:08:32 EDT 2005


"Bengt Richter" <bokr at oz.net> wrote in message 
news:42d02c21.231516573 at news.oz.net...
> The binding of a class name is similar, and class decorators
> would seem natural, i.e.,
>
>    @cdeco
>    class Foo: pass
> for
>    class Foo: pass
>    Foo = cdeco(Foo)

This possibility was discussed on the py-dev list about a year or so ago. 
The twice monthly summaries should include this topic.  As I remember, the 
reason for limiting to functions included:

1. classes have metaclasses, functions don't have metafunctions.  No one 
gave an example for classes not handled at least as well with a metaclass.

2. certain applications require long-function_names_like_this, for which 
triple typing is substantially annoying and error-prone.

Terry J. Reedy






More information about the Python-list mailing list