[Baypiggies] A few decorator questions...

Andrew Dalke dalke at dalkescientific.com
Thu Feb 26 21:00:01 CET 2009


On Feb 26, 2009, at 8:36 AM, Charles Merriam wrote:
> What decorators do most people actually use?

In the world of Python code, or the ones which come with Python?

Turbogears uses decorators. It's what got me into understanding more  
about when to use them.

nose uses decorators for a few things. One of the test frameworks  
(nose? py.test?) lets you label tests through decorators, so you can  
select, say, "fast" tests.

mock uses them for patching objects:
   http://www.voidspace.org.uk/python/mock.html

PLY has the @TOKEN decorator, which is handy for autogenerated  
patterns instead of using docstrings.

Zope uses the "apply" decorator in a few places, which was weird the  
first time I saw it

@apply
def f():
   ... code here ...
   return result

I didn't realize 'apply' was a useful decorator. Did you? :)

>

				Andrew
				dalke at dalkescientific.com




More information about the Baypiggies mailing list