[docs] argparse add_help with prefix_chars example wrong

Patrick Strasser pstrasser at cccom.at
Fri Apr 26 14:02:07 CEST 2013


Hello,

in
   http://docs.python.org/3.4/library/argparse.html#add-help

The last example reads:

The help option is typically -h/--help. The exception to this is if the 
prefix_chars= is specified and does not include -, in which case -h and 
--help are not valid options. In this case, the first character in 
prefix_chars is used to prefix the help options:

>>>

>>>parser  =  argparse.ArgumentParser(prog='PROG',  prefix_chars='+/')
>>>parser.print_help()
usage: PROG [-h]

optional arguments:
   -h, --help  show this help message and exit
  

This example does not show the effect.
On my Ubuntu I get:

% python3.2
Python 3.2.3 (default, Apr 10 2013, 05:07:54)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import argparse
>>> parser = argparse.ArgumentParser(prog='PROG', prefix_chars='+/')
>>> parser.print_help()
usage: PROG [+h]

optional arguments:
   +h, ++help  show this help message and exit
>>>

Docs of 2.7, 3.3 and 3.4 show this error, 3.2 is correct.

Regards

Patrick
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/docs/attachments/20130426/55d0b6a9/attachment-0001.html>


More information about the docs mailing list