Chris Angelico wrote:
> On Tue, Sep 16, 2014 at 9:15 AM, ISE Development
> wrote:
>> @functools.wraps(func)
>> def wrapper(self):
>> func(self)
>> return wrapper
>>
>> try:
>> k.method(1)
>> except Exception as e:
>> print('exception:',e
On Mon, Sep 15, 2014 at 5:15 PM, ISE Development wrote:
> The first two lines are as expected, using the name of the decorated
> function. However, the exception uses the name of the decorating wrapper
> function.
>
> Is this a bug in functools? Or is this a language feature? If so, is there a
> v
On Tue, Sep 16, 2014 at 9:15 AM, ISE Development wrote:
> @functools.wraps(func)
> def wrapper(self):
> func(self)
> return wrapper
>
> try:
> k.method(1)
> except Exception as e:
> print('exception:',e)
>
> The output (Python 3.3) is:
>
The purpose of 'functools.wraps' is to make a decorated function look like
the original function, i.e. such that the __name__, __module__, __doc__
attributes are the same as the wrapped function.
However, I've noticed inconsistent behaviour.
Given the following:
import functools
def d