[Python-Dev] method decorators (PEP 318) (original) (raw)

Phillip J. Eby pje at telecommunity.com
Fri Mar 26 15:42:11 EST 2004


At 02:10 PM 3/26/04 -0600, Skip Montanaro wrote:

Except in extreme cases (PEAK sort of sounds like it might be one), most functions will be of the current type.

This is true even in PEAK. 'binding.Make' is used most often to wrap short, simple lambda: functions, rather than lengthy 'def' suites, and 'events.taskFactory' is only used to wrap functions that will be run as pseudothreads in asynchronous, event-driven code. 'binding.classAttr' is really a wizard-level thing for framework builders, and so isn't seen in app-level code at all.

It's actually much more common to use class decorators in PEAK, actually, since they're used to declare interfaces and security, e.g.:

class Something(binding.Component):

 protocols.advise(
     instancesImplement=[ISomething]
 )

 security.declare(
     someAttr=SomePermission,
     otherAttr=OtherPermission
 )

 ...

So, if the PEP 318 class decorator syntax were available, these would move into an explicit declaration block, rather than just being inline function calls.



More information about the Python-Dev mailing list