[Python-3000] PEP Draft: Class Decorators (original) (raw)
Jack Diederich jackdied at jackdied.com
Sat Mar 10 01:39:12 CET 2007
- Previous message: [Python-3000] PEP Draft: Class Decorators
- Next message: [Python-3000] PEP Draft: Class Decorators
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Fri, Mar 09, 2007 at 06:19:49PM -0600, Collin Winter wrote:
>History and Implementation >========================== > >Class decorators were originally proposed alongside function decorators >in PEP318 [1] and were rejected by Guido [2] 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 [3].
I'd still prefer it if this use case -- which is so central to the PEP -- were provided in the PEP itself.
I'll make that more clear. The use cas was factory registration right next to the class definition (as opposed to afterwards or through a metaclass). This is the example I use most frequently in the PEP.
>Grammar/Grammar is changed from > > funcdef: [decorators] 'def' NAME parameters ['->' test] ':' suite > >to > > decoratedthing: decorators (classdef | funcdef) > funcdef: 'def' NAME parameters ['->' test] ':' suite > >"decoratedthing"s are premitted everywhere that funcdef and classdef >are premitted. > >An alternate change to the grammar would be to make a 'decoratablething' >which would include funcdefs and classdefs even if they had no decorators.
Is it "decoratedthing" or "decoratablething"?
The current production is 'decorated_thing' because it requires at least one decorator so it is definitely decorated. If there are zero or more decorators it would become 'decoratable_thing' as it would include the case where something could be decorated but isn't.
Thanks, and I'll go typo hunting.
-Jack
- Previous message: [Python-3000] PEP Draft: Class Decorators
- Next message: [Python-3000] PEP Draft: Class Decorators
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]