[Python-checkins] r77309 - in python/branches/release31-maint: Doc/library/optparse.rst

ezio.melotti python-checkins at python.org
Mon Jan 4 22:54:32 CET 2010


Author: ezio.melotti
Date: Mon Jan  4 22:54:31 2010
New Revision: 77309

Log:
Merged revisions 77308 via svnmerge from 
svn+ssh://pythondev@svn.python.org/python/branches/py3k

................
  r77308 | ezio.melotti | 2010-01-04 23:53:17 +0200 (Mon, 04 Jan 2010) | 9 lines
  
  Merged revisions 77306 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r77306 | ezio.melotti | 2010-01-04 23:43:02 +0200 (Mon, 04 Jan 2010) | 1 line
    
    #3340: document print/get_usage and print/get_version
  ........
................


Modified:
   python/branches/release31-maint/   (props changed)
   python/branches/release31-maint/Doc/library/optparse.rst

Modified: python/branches/release31-maint/Doc/library/optparse.rst
==============================================================================
--- python/branches/release31-maint/Doc/library/optparse.rst	(original)
+++ python/branches/release31-maint/Doc/library/optparse.rst	Mon Jan  4 22:54:31 2010
@@ -598,6 +598,20 @@
    $ /usr/bin/foo --version
    foo 1.0
 
+The following two methods can be used to print and get the ``version`` string:
+
+.. method:: OptionParser.print_version(file=None)
+
+   Print the version message for the current program (``self.version``) to
+   *file* (default stdout).  As with :meth:`print_usage`, any occurrence
+   of ``"%prog"`` in ``self.version`` is replaced with the name of the current
+   program.  Does nothing if ``self.version`` is empty or undefined.
+
+.. method:: OptionParser.get_version()
+
+   Same as :meth:`print_version` but returns the version string instead of
+   printing it.
+
 
 .. _optparse-how-optparse-handles-errors:
 
@@ -1384,6 +1398,18 @@
    constructor keyword argument.  Passing ``None`` sets the default usage
    string; use :data:`optparse.SUPPRESS_USAGE` to suppress a usage message.
 
+.. method:: OptionParser.print_usage(file=None)
+
+   Print the usage message for the current program (``self.usage``) to *file*
+   (default stdout).  Any occurrence of the string ``"%prog"`` in ``self.usage``
+   is replaced with the name of the current program.  Does nothing if
+   ``self.usage`` is empty or not defined.
+
+.. method:: OptionParser.get_usage()
+
+   Same as :meth:`print_usage` but returns the usage string instead of
+   printing it.
+
 .. method:: OptionParser.set_defaults(dest=value, ...)
 
    Set default values for several option destinations at once.  Using


More information about the Python-checkins mailing list