Module access from inside itself
dippy at mikka.net.au
Fri Aug 15 18:20:43 CEST 2003
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.
I've tried searching for an answer, but haven't found anything. Please
excuse me if I'm missing something simple, I'm a newbie to Python.
I'm doing something like this:
"""Module doc string goes here.
import getopt, sys
if __name__ == "__main__":
opts, args = getop.getopt(sys.argv[1:], , ["help"])
for opt in opts:
if opt == "--help":
print MY_MODULE.__doc__ # How do I get this?
How do I get a reference to the module from inside the module? Is this
the Pythonic way of generating help strings for CL scripts?
More information about the Python-list