Print docstrings to shell

André Roberge andre.roberge at gmail.com
Wed Feb 2 02:53:11 CET 2011


On Tuesday, February 1, 2011 9:21:48 PM UTC-4, André Roberge wrote:
SNIP
> 
> =======
> import pydoc
> import os
> import sys
> 
> '''this is a test'''
> 
> class A(object):
> 	'''docstring'''
> 	pass
> 
> _path, _file_name = os.path.split(__file__)
> _module_name = _file_name[:-3]
> sys.path.append(_path)
> pydoc.help(_module_name)
> =====
> 

Actually, one does not need to import pydoc; using help() without importing seems to work just as well (or as badly, as it displays it twice...)
André


> Note: I've included an underscore in variables names so that they would not appear.
> Note 2: for some reason, which I do not understand, it shows the help twice (i.e. I have to hit "q" twice to make it go away).  Sorry that I can not help with this.
> 
> André




More information about the Python-list mailing list