Module access from inside itself

Scott David Daniels Scott.Daniels at Acm.Org
Fri Aug 15 19:58:07 CEST 2003

Steven wrote:

> I'm writing a Python script which can be called from the command-line, and 
> I want to use my module doc string as the CL help text, but I don't know 
> how to access my module object from inside the module.

How about this:

# demo of accessing the docstring:

This is a test.

Had this been a real document, it would have said something.

if __name__ == '__main__':
     import __main__
     print __main__.__doc__

More information about the Python-list mailing list