RE: [Python-Dev] @decoration of classes

Nick Coghlan wrote:
class factory: @register def __call__(self): pass Just as an additional data point - obviously not applicable in all cases. Tim Delaney

Delaney, Timothy C (Timothy) wrote:
Yep, and it's obviously possible to do that now with just function decorators. Getting my head around what that actually *does* is a little trickier, though (as near as I can tell, it will register a standalone function named __call__, with nothing linking it to the containing class). What a class decorator allows is the registration of the whole process of invoking the metaclass and hence __new__ and __init__ as a single unit. Anyway, I don't particularly feel the lack of class decorators, but I thought I should mention this (perhaps small) category of non-transforming decorators as a situation where class decoration would make more sense to me than using a metaclass. Cheers, Nick. -- Nick Coghlan | ncoghlan@email.com | Brisbane, Australia --------------------------------------------------------------- http://boredomandlaziness.skystorm.net

Delaney, Timothy C (Timothy) wrote:
Yep, and it's obviously possible to do that now with just function decorators. Getting my head around what that actually *does* is a little trickier, though (as near as I can tell, it will register a standalone function named __call__, with nothing linking it to the containing class). What a class decorator allows is the registration of the whole process of invoking the metaclass and hence __new__ and __init__ as a single unit. Anyway, I don't particularly feel the lack of class decorators, but I thought I should mention this (perhaps small) category of non-transforming decorators as a situation where class decoration would make more sense to me than using a metaclass. Cheers, Nick. -- Nick Coghlan | ncoghlan@email.com | Brisbane, Australia --------------------------------------------------------------- http://boredomandlaziness.skystorm.net
participants (2)
-
Delaney, Timothy C (Timothy)
-
Nick Coghlan