[Python-Dev] Class decorators (original) (raw)

Phillip J. Eby pje at telecommunity.com
Thu Mar 30 08:49:07 CEST 2006


At 03:09 PM 3/30/2006 +1200, Greg Ewing wrote:

Well, here's how my use case would look if I had class decorators:

@IOClass class MyClass: ... Does that count? My decorator wouldn't need any arguments, because it looks inside the class for all the information it needs. [1] That's actually a general solution to Phillip's concern: the decorator can always look for attributes in the class (or the class's dict if you don't want them inherited) for large amounts of information that wouldn't comfortably fit up the top. That's an extra degree of freedom that we don't have with functions.

I fail to see how this is an improvement. It sounds like the worst of all possible worlds to me -- much worse than the status quo.

I use class decorators to declare metadata about attributes, so having to add a bunch of attributes for that and having to stick a funny hat on top of the class is definitely not an improvement for me.

Are you actually using this IOClass thing, or is this just a hypothetical proposal?



More information about the Python-Dev mailing list