DecoratorTools 1.0
Use class and function decorators -- even in Python 2.3!
Latest Version: 1.8
Want to use decorators, but you still need to support Python 2.3? Wish you could have class decorators, or decorate arbitrary assignments? Then you need "DecoratorTools". Some quick examples:
# Method decorator example
from peak.util.decorators import decorate
class Demo1(object):
decorate(classmethod) # equivalent to @classmethod
def example(cls):
print "hello from", cls
# Class decorator example
from peak.util.decorators import decorate_class
def my_class_decorator():
def decorator(cls):
print "decorating", cls
return cls
decorate_class(decorator)
class Demo2:
my_class_decorator()
# "decorating <class Demo2>" will be printed when execution gets here
Installing DecoratorTools (using "easy_install DecoratorTools" or "setup.py install") gives you access to the peak.util.decorators module. The tools in this module have been bundled for years inside of PEAK, PyProtocols, RuleDispatch, and the zope.interface package, so they have been widely used and tested. (Unit tests are also included, of course.)
This standalone version is backward-compatible with the bundled versions, so you can mix and match decorators from this package with those provided by zope.interface, TurboGears, etc.
| File | Type | Py Version | Uploaded on | Size | # downloads |
|---|---|---|---|---|---|
| DecoratorTools-1.0-py2.3.egg (md5) | Python Egg | 2.3 | 2006-05-25 | 22KB | 1054 |
| DecoratorTools-1.0-py2.4.egg (md5) | Python Egg | 2.4 | 2006-05-25 | 9KB | 994 |
| DecoratorTools-1.0.zip (md5) | Source | 2006-05-25 | 14KB | 502 | |
- Author: Phillip J. Eby
- Home Page: http://peak.telecommunity.com/DevCenter/DecoratorTools
- License: PSF or ZPL
- Package Index Owner: pje
- DOAP record: DecoratorTools-1.0.xml
