Links tagged “decorator”

2 links, newest first.

  • phyast.pitt.edu

    ate classes. The decorator module takes advantage of this feature to provide a facility for writing complex decorator factories. We have already seen examples of simple decorator factories, implemented as functions returning a decorator. For more complex situations, it is more convenient to implement decorator factories as classes returning callable objects that can be used as signature-preserving decorators. To this aim, decorator can also be used as a class decorator. Given a class with a .call(self, func, *args, **kw) method decorator(cls) adds a suitable __call__ method to the class; it raises a TypeError if the class already has a nontrivial __call__ method.

  • code.activestate.com

    Recipe declaring a Python property from a single decorated function whose nested getter and setter are captured by a trace hook, instead of returning locals() by hand.