[Python-ideas] Proposal for new-style decorators

Nick Coghlan ncoghlan at gmail.com
Wed Apr 27 06:26:07 CEST 2011


Attacking (some aspects of) the same problem from a different angle,
note that part of the motivation of PEP 362 (function signature
objects) is to allow functools.wraps to be more effective at
preserving signature information, and to allow similar gains for
functools.partial. It also allows signature checks to be performed
independently of actually calling functions (via the Signature.bind()
method).

As of 3.2, functools.wraps has already been updated to automatically
include a __wrapped__ attribute on the resulting callable, which links
back to the underlying function. The "func" attribute on
functools.partial serves the same purpose.

Actually *writing* decorators is still somewhat cumbersome by default,
but if anything were to happen on that front, the most likely would be
to ask Michele about making the decorators module part of the standard
library.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia



More information about the Python-ideas mailing list