On Sat, Aug 14, 2010 at 1:01 AM, Eric Snow <es...@verio.net> wrote:
> Actually, what is the problem with having all decorators add a __decorated__ 
> to the function that ultimately gets returned, pointing to the function they 
> decorated?  I guess I never saw that discussion.  Perhaps set it to None when 
> the decorator is the same as the decorated (no wrapping involved).  The 
> alternative is sifting through closures, trying to figure out which is the 
> decorated function.  Finding the original decorated function has been a real 
> pain, particularly when a function has more than one closure cell.

Because decorators don't always return simple wrapper functions -
sometimes they return the original function and sometimes they
completely replace the original function with something else entirely
(which may not be callable, or even mutable). We refused the
temptation to try to guess when it was appropriate to add the
referring attribute.

functools.update_wrapper and functools.wraps are explicit though, so
it's easy to add the attribute there, we just hadn't thought of doing
it before now.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncogh...@gmail.com   |   Brisbane, Australia
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to