A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/2005-March/052478.html below:

[Python-Dev] @decoration of classes

[Python-Dev] @decoration of classes [Python-Dev] @decoration of classesNick Coghlan ncoghlan at iinet.net.au
Thu Mar 31 03:31:54 CEST 2005
Delaney, Timothy C (Timothy) wrote:
> class factory:
> 
>     @register
>     def __call__(self):
>         pass
> 
> Just as an additional data point - obviously not applicable in all
> cases.

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 at email.com   |   Brisbane, Australia
---------------------------------------------------------------
             http://boredomandlaziness.skystorm.net
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4