Hi,<br><br>It is stated in PEP 257 that:<br><br>&quot;The docstring of a script (a stand-alone program) should be usable as
its &quot;usage&quot; message, printed when the script is invoked with incorrect
or missing arguments (or perhaps with a &quot;-h&quot; option, for &quot;help&quot;).[...]&quot;<br><br>This is exactly what I&#39;m trying to do, but I haven&#39;t been able to figure out how to access a script&#39;s docstring from within it. That is, I&#39;m assuming (perhaps erroneously) that I can define some kind of usage function in my script that will spit out the docstring, as in the following example<br>
<br>#!/usr/bin/python<br>&quot;&quot;&quot; <br>myscript.py<br><br>Usage:  python myscript.py &lt;params&gt;<br><br>Some more specific info here.<br>&quot;&quot;&quot;<br><br>[python code here]<br><br>def main():<br>    [do stuff here]<br>
<br>### THIS IS WHAT I&#39;D LIKE TO DO... ###<br>def usage():<br>    sys.stderr.write(this.__doc__)<br>    sys.exit()<br>### EXCEPT OF COURSE &quot;this&quot; ISN&#39;T DEFINED<br><br>if __name__ == &quot;__main__&quot;:<br>
    if [some condition is not satisfied]:<br>        usage()<br>    else:<br>        main()<br>################################<br><br>What should I be doing instead? I&#39;ve Googled a bunch and turned up nothing, so I may just not be looking for the right terms (Googling &quot;python print script docstring&quot; gets me nothing).<br>
<br>Thanks!<br>Fred.<br><br>