A RetroSearch Logo

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

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2006-March/062836.html below:

[Python-Dev] Class decorators

[Python-Dev] Class decorators [Python-Dev] Class decoratorsGreg Ewing greg.ewing at canterbury.ac.nz
Sun Mar 26 14:39:07 CEST 2006
I've just been playing around with metaclasses, and
I think I've stumbled across a reason for having
class decorators as an alternative to metaclasses
for some purposes.

The metaclass I wrote was for the purpose of
adding a class to a registry, the reason for which
isn't important here. It worked, but I was surprised
to find that it not only registered the classes that
I made it the metaclass of, but all subclasses of
those classes as well.

I'm not sure whether that's really the behaviour I
want, and I can imagine some cases in which it's
definitely not what I'd want.

The general principle brought out here is that when
you use a metaclass, it gets inherited by subclasses,
but if we had class decorators, they would only affect
to the classes that you explicitly applied them to.
I think there are uses for both behaviours.

Greg
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