On Sun, Jul 3, 2016 at 5:25 PM, Lawrence D’Oliveiro
<lawrenced...@gmail.com> wrote:
> On Monday, July 4, 2016 at 10:39:30 AM UTC+12, Ian wrote:
>> Sorry, but you're the one who doesn't seem to get it. Because it's a
>> decorator, "your" function is replacing the caller's function in the
>> caller's namespace.
>
> No it is not. The replacement happens here:
>
>         def generated_decorator(func) :
>             return \
>                 decorator(func, *args, **kwargs)
>         #end generated_decorator
>
> As you can see, the function being called, “decorator”, is supplied by the 
> caller. The function being decorated, “func”, is supplied by the caller 
> (along with the additional *args and **kwargs). And the returned function is 
> returned *as-is*, so whatever docstring was assigned by the caller is *NOT* 
> “clobbered”.

I'm talking about the docstring of the *decorator*, not func. I agree
that whatever docstring func has is entirely up to func and the
decorator, not your code. Here again is the example I posted earlier:

>>> @decorator_with_args
... def my_decorator(func, *args, **kwargs):
...     """Returns func unmodified."""
...     return func
...
>>> my_decorator.__doc__
'generates a decorator which applies my_decorator to the given arguments'

I never made any claim about the docstring of the decorated func.
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to