I like that IPython will fetch docstrings if I type foo.bar?
However, I may sometimes build the foo.bar method dynamically, using foo.__getattr__. I could conceivably also generate a docstring dynamically, perhaps in a magic method like foo.__getdoc__.
Does IPython provide any mechanism for doing this, such that it would discover and display docstrings built on the fly?
That has nothing to do with IPython, IPython just reads the
__doc__attribute of an object. If you dynamically create your objects in the__getattr__method you should just set their__doc__attribute as well and everything will work correctly in IPython.Here is an example: