At 10:05 AM 3/31/05 +1000, Nick Coghlan wrote: >PJE's example of moving the decoration near the top of the class >definition without allowing class decoration contains an important caveat: >it requires that the decorators be written to support doing that. Allowing >class decoration means any appropriate decorators can be used, unmodified, >to affect classes as well as functions. Yeah, but that can be trivially worked around using a 'decorate' function, e.g.: from protocols.advice import addClassAdvisor def decorate(*decorators): decorators = list(decorators)[::-1] def callback(cls): for dec in decorators: cls = cls(dec) return cls addClassAdvisor(callback) class SomeClass: decorate(dec1,dec2,...)
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