[Python-3000] PEP Draft: Class Decorators
jackdied at jackdied.com
Wed Feb 28 21:52:12 CET 2007
Greetings from PyCon!
I read hundreds of emails in the dozens of threads about class decorators and
there was surprisingly little content (most of the arguments were about syntax
which is no longer up for debate). As a result this PEP is quite plain.
If any IronPython or Jython folks could throw in their two bits it would be
Title: Class Decorators
Authors: Jack Diederich
Type: Standards Track
Extending the decorator syntax to allow the decoration of classes.
Allowing classes to be decorated serves many of the same purposes as
the ability to decorate functions. Decorators move factory registration
and class manipulation to the top of the class definition instead of the
current alternate methods of post-processing or the action-at-a-distance
History and Implementation
Class decorators were originally proposed in PEP318 _ and were rejected
by Guido _ for lack of use cases. Two years later he saw a use case
he liked and gave the go-ahead for a PEP and patch _.
The current patch is loosely based on a pre-2.4 patch _ and updated to
use the new AST.
Grammar/Grammar is changed from
funcdef: [decorators] 'def' NAME parameters ['->' test] ':' suite
decorated_thing: decorators (classdef | funcdef)
funcdef: 'def' NAME parameters ['->' test] ':' suite
If you enjoyed this PEP you might also enjoy:
..  PEP 318, "Decorators for Functions and Methods"
..  Class decorators rejection
..  Class decorator go-ahead
..  2.4 class decorator patch
..  3.x class decorator patch
More information about the Python-3000