-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 19 Dec 2009, at 22:32, Mike Orr wrote:

> On Sat, Dec 19, 2009 at 7:55 AM, Graham Higgins  
> <[email protected]> wrote:
>> "A decorator is a Python object that can be called with a single
>> argument and which modifies a function or a method."
>
> "wraps" would be a better term.

I think I prefer the description given in the wikipedia entry. Whilst  
"wrapping" does seem a reasonable metaphor at first glance, if it is  
used to describe the action of a decorator, it leaves one reaching  
with respect to the concept of wrapper functions defined inside  
decorators, such as that indicated by the functools.wrap()  
documentation:

http://docs.python.org/library/functools.html#functools.wraps

AIUI, the utility of wrapper functions inside decorators is that they  
provide access to the decorator function's variable scope, including  
the target function (culled from John Siafoo's article: 
http://www.siafoo.net/article/68) 
.

> Decorators are easy to use, but one of the most difficult things in
> Python to write or understand the source.


Personally, I think they're something of a poisoned pill in that  
respect. I use 'em but I don't particularly like 'em.

Cheers,

Graham

http://www.linkedin.com/in/ghiggins




-----BEGIN PGP SIGNATURE-----

iEYEARECAAYFAkstrmkACgkQOsmLt1NhivzM3QCcDiwfvgqP8gQErS+56c8a/eGT
9QEAoIEF0X/zAyxtso21jMbjJFf7XlRxiQCVAgUBSy2uaVnrWVZ7aXD1AQK3wgQA
o1RUuoW/3UDoHA8a2VzslwYAABQB881QpSjUatSoliv6z81hCAc/DNTdMtDzxx4r
+wvXdC1Mz69HIbV2KhJY08ZBS5LV7UDn0OC/1tuKwDJMdDzHwA5vrtopUuCKJc86
CUwY/Bzh34BXxonJOHzudwXqNdJ2ksvsHDFo2R8xXeA=
=7isB
-----END PGP SIGNATURE-----

--

You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en.


Reply via email to