A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2010-August/103001.html below:

[Python-Dev] Proposed tweaks to functools.wraps

[Python-Dev] Proposed tweaks to functools.wraps [Python-Dev] Proposed tweaks to functools.wrapsNick Coghlan ncoghlan at gmail.com
Wed Aug 11 14:28:00 CEST 2010
On Wed, Aug 11, 2010 at 9:26 PM, Simon Cross
<hodgestar+pythondev at gmail.com> wrote:
> On Wed, Aug 11, 2010 at 4:39 AM, Benjamin Peterson <benjamin at python.org> wrote:
>> Namespace conflict with what? I would prefer "wraps" unless it's
>> standardized as a behavior for all decorators.
>
> Having the original function available as __wrapped__ would be really
> cool, although I'm not quite sure what the behaviour should be in
> corner cases like:
>
> * The decorator returns the original function (I suppose a reference
> to itself is okay?)
> * The decorator returns the a function that is already decorating
> something else.

Those are the corner cases that make it more appropriate to have this
as a behaviour of functools.update_wrapper() (and hence the
functools.wraps() decorator) rather than built in to the decorator
machinery.

The change will just add the following line to update_wrapper():

  wrapper.__wrapped__ = wrapped

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4