I know this question is very simple, I know it must have been asked a lot of times and I did my search on both SO and Google but I could not find the answer, probably due to my lack of ability of putting what I seek into a proper sentence.
I want to be able to read the docs of what I import.
For example if I import x by "import x", I want to run this command, and have its docs printed in Python or ipython.
What is this command-function?
PS. I don't mean dir(), I mean the function that will actually print the docs for me to see and read what functionalities etc. this module x has.
You can use the
.__doc__ attribute of the module of function:
In : import itertools In : print itertools.__doc__ Functional tools for creating and using iterators.......... In : print itertools.permutations.__doc__ permutations(iterable[, r]) --> permutations object Return successive r-length permutations of elements in the iterable. permutations(range(3), 2) --> (0,1), (0,2), (1,0), (1,2), (2,0), (2,1)
__doc__ work fine on both inbuilt as well as our own modules:
def myfunc(): """ this is some info on myfunc """ foo=2 bar=3 In : help(so27.myfunc) In : import foo In : print foo.myfunc.__doc__ this is some info on func In : help(foo.myfunc) Help on function myfunc in module foo: myfunc() this is some info on func