[Python-ideas] PEP-3150

Nick Coghlan ncoghlan at gmail.com
Thu Apr 14 08:03:03 CEST 2011


On Thu, Apr 14, 2011 at 3:46 PM, Carl M. Johnson
<cmjohnson.mailinglist at gmail.com> wrote:
> On Wed, Apr 13, 2011 at 3:48 PM, Nick Coghlan <ncoghlan at gmail.com> wrote:
>> On Thu, Apr 14, 2011 at 8:33 AM, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
>
>>> assigned to the __doc__ attribute of whatever object the
>>> RHS expression returns.
>>
>> Ah, true, that would make a lot of sense. It also generalises nicely
>> to other cases like "return" and "yield" as well. I'll see if I can
>> thrash out something sensible along those lines.
>
> So, in the case of
>
> def decorator(f):
>    return decorated given:
>        "Docstring A..."
>        def decorated(*args, **kwargs):
>            "Docstring B..."
>            do something...
>
> it would be docstring A that gets put on the decorated function, not
> docstring B? I guess I can kind of see the reasoning there, but it
> seems a little weird.

Yep, but if it was designed that way from the start, people simply
wouldn't include the inner docstring.

I'm not completely sold on this particular idea as yet, but it's one
I'll explore further in the next update of the PEP.

> Also, this case (and the general issue of callbacks, thunks, etc.)
> seems to be crying out for a special convenience syntax to save a
> level indenting. But would that just add needlessly to the complexity
> of the language?

Given that PEP 3150 itself is already highly vulnerable to that last
accusation, I'm going to go with "Yes" :)

Cheers,
Nick.

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



More information about the Python-ideas mailing list