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

Chris Angelico rosuav at gmail.com
Sun Oct 7 10:45:01 EDT 2018


On Mon, Oct 8, 2018 at 1:41 AM Marko Ristin-Kaufmann
<marko.ristin at gmail.com> wrote:
> (If you wonder about the use case: I'd like to dynamically generate the docstrings when functions are decorated with contracts from icontract library. Condition functions need to be parsed and re-formatted, so this is something that should be done on-demand, when the user either wants to see the help() or when the sphinx documentation is automatically generated. The docs should not inflict computational overhead during the decoration since normal course of program operation does not need pretty-printed contracts.)
>

Have you tried just generating the docstrings at decoration time and
applying them? By the sound of it, they won't change after that, and
the only reason to run it later is performance... but have you
actually measured a performance hit resulting from that?

ChrisA


More information about the Python-ideas mailing list