I love the decorator in Python!!!

Chris Rebert clp2 at rebertia.com
Thu Dec 8 03:04:28 EST 2011


On Wed, Dec 7, 2011 at 11:18 PM, 88888 Dihedral
<dihedral88888 at googlemail.com> wrote:
> I use the @ decorator to behave exactly like a c macro that
> does have fewer side effects.
>
> I am wondering is there other interesting methods to do the
> jobs in Python?

* Class decorators (http://www.python.org/dev/peps/pep-3129/ ); i.e.
using decorators on a class instead of a function/method
* Metaclasses (http://docs.python.org/dev/reference/datamodel.html#customizing-class-creation
); a rather more complicated feature capable of serious black magic
* Descriptors (http://docs.python.org/dev/reference/datamodel.html#implementing-descriptors
); probably the most rarely directly used of the three

Cheers,
Chris
--
http://rebertia.com



More information about the Python-list mailing list