The problem is that you import "module"instead of the specified module, and you did not put the name moduleanywhere. A stupid solution for this would be to always useexec
def get_doc(module):
exec "import {}".format(module)
exec "print {}.__doc__".format(module)"
But instead, execI would suggest using a function __import__:
def get_doc(module):
module = __import__(module)
print module.__doc__
This allows you to increase flexibility, and you can modify, use the module as you wish.
source
share