Optparse and help formatting?

Tim Chase python.list at tim.thechases.com
Sun Sep 30 09:51:11 EDT 2007


>>   def format_option(self, option):
>>     # The help for each option consists of two parts: 
>>     #   * the opt strings and metavars
> [snip]
> 
> Tim, I notice you're using lots of # lines as comments to describe the 
> function. Perhaps you should consider using docstrings instead.
> 
> Pardon me if I'm telling you what you already know... 

Yes, I do know about and use docstrings, and no, no offense
taken.  You'll have to persuade the [Debian/Python] maintainer of
optparse.py from whom I pilfered the code.  :)

tim at rubbish:~$ sed -n '/def format_option(/{N;N;N;N;N;p}'
/usr/lib/python2.4/optparse.py

    def format_option(self, option):
        # The help for each option consists of two parts:
        #   * the opt strings and metavars
        #     eg. ("-x", or "-fFILENAME, --file=FILENAME")
        #   * the user-supplied help string
        #     eg. ("turn on expert mode", "read data from FILENAME")


-tim







More information about the Python-list mailing list