<div dir="auto">Hi,<div dir="auto">@Jonathan: thanks! I'll have a look at your links.</div><div dir="auto"><br></div><div dir="auto">So there are actually two issues if I understand correctly:</div><div dir="auto">* help() ignoring the property getter when invoked on an instance</div><div dir="auto">* built-in class function ignoring the property getter (some_func.__doc__ set to a property returns the property instead of invoking the getter)</div><div dir="auto"><br></div><div dir="auto">Is the second issue also problematic or the built-ins are meant to ignore properties and there should be no fix? I think I'm misunderstanding something here.</div><div dir="auto"><br></div><div dir="auto">Cheers, </div><div dir="auto">Marko</div><div dir="auto"><br></div><div dir="auto"><br></div><div dir="auto"><br></div><div dir="auto"><br></div></div><br><div class="gmail_quote"><div dir="ltr">Le dim. 7 oct. 2018 à 17:37, Jonathan Fine <<a href="mailto:jfine2358@gmail.com">jfine2358@gmail.com</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Marko<br>
<br>
You wrote:<br>
<br>
> I just couldn't figure out how to make the __doc__ attribute of a function a getter. Is this a bug or am I making a mistake? If it's my mistake, is there any other way how to dynamically __doc__ a function or am I forced to set __doc__ of a function at the decoration time?<br>
<br>
Thank you for your clear examples. I'm not sure, but I may have found<br>
the problem.<br>
<br>
As I recall, setting obj.attr to a property won't work. Instead, you<br>
have to set type(obj).attr to the property. And now you come up<br>
against a problem. You can't set __doc__ on the type 'function', nor<br>
can you subclass the type 'function'.<br>
<br>
>>> def fn(): pass<br>
>>> type(fn)<br>
<class 'function'><br>
<br>
>>> type(fn).__doc__<br>
'function(code, globals[, name[, argdefs[, closure]]]) [snip]'<br>
<br>
>>> type(fn).__doc__ = None<br>
TypeError: can't set attributes of built-in/extension type 'function'<br>
<br>
>>> class FN(type(fn)): pass<br>
TypeError: type 'function' is not an acceptable base type<br>
<br>
As I (more vaguely) recall, something was done recently to add a get<br>
attribute property that works directly on objects, rather than on<br>
instances of a class. But I've not been able to find it. Perhaps I<br>
misunderstood PEP 562.<br>
<br>
Some perhaps relevant URLs:<br>
<a href="https://www.python.org/dev/peps/pep-0224/" rel="noreferrer noreferrer" target="_blank">https://www.python.org/dev/peps/pep-0224/</a> Attribute Docstrings<br>
<a href="https://www.python.org/dev/peps/pep-0549/" rel="noreferrer noreferrer" target="_blank">https://www.python.org/dev/peps/pep-0549/</a> Instance Descriptors<br>
<a href="https://www.python.org/dev/peps/pep-0562/" rel="noreferrer noreferrer" target="_blank">https://www.python.org/dev/peps/pep-0562/</a> Module __getattr__ and __dir__<br>
<a href="https://stackoverflow.com/questions/2447353/getattr-on-a-module" rel="noreferrer noreferrer" target="_blank">https://stackoverflow.com/questions/2447353/getattr-on-a-module</a><br>
<br>
-- <br>
Jonathan<br>
</blockquote></div>