[Python-ideas] Dynamic getting of __doc__ of a function

Marko Ristin-Kaufmann marko.ristin at gmail.com
Sun Oct 7 03:25:13 EDT 2018

I'm working on decorators that have a dynamic __doc__ property computed at
runtime and not at decoration time.

The decorator must return the wrapper as a function and can not return a
callable object with __call__ since the "self" argument would not be
properly passed through the decorator. (Making __call__ a static method
drops implicitly the first argument). If __call__ could be a static method
and get the arguments as-are, I could make __doc__ a property. But this is
not possible,  right?

Assigning a class satisfying the property protocol to the function
wrapper.__doc__ did not work either since the property object is returned
as-is instead of invoking __get__ on it.

Could someone explain a bit -- is this the desired behavior or a bug or an

Is there any way for a callable object to be used as a decorator?


Cheers Marko
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20181007/bb5dfa82/attachment.html>

More information about the Python-ideas mailing list