2

I want to extract a docstring from every function in a python module. Thought, help does the intended action, It would print out a lot of extra stuff which I do not need. I have tried .__ doc__ as well. However, Even that does print out a lot of stuff and also print \n and \t.

eg.

def Foo():
"""
This is
a multiline
comment
"""
    pass:

I want something which will give me only the comment as a single line or in the specified format as is.

>>> print (some operation on foo)
>>> "This is a multiline comment"
>>>

How do I remove of all the extra stuff.

Greater picture: I have a module with a search function to find all functions and I want to display their descriptions along with functions

>>> find('*', maths) # suppose maths is a module
>>> shapes.square "This is square"
    shapes.cube   "This is cube"

P.S I already have the find function I just need the string to append in the print statement.

Thnaks

Chinmoy Kulkarni
  • 187
  • 1
  • 13

0 Answers0