[docs] give more meaningful argument names in argparse documentation (issue 11176)

ezio.melotti at gmail.com ezio.melotti at gmail.com
Mon Jul 9 10:23:56 CEST 2012


http://bugs.python.org/review/11176/diff/5362/Doc/library/argparse.rst
File Doc/library/argparse.rst (right):

http://bugs.python.org/review/11176/diff/5362/Doc/library/argparse.rst#newcode40
Doc/library/argparse.rst:40: parser.add_argument('-f', '--file',
type=str, default="/usr/share/dict/words",
Not sure it's a good idea to provide a default here (especially one that
doesn't work on all the operative systems).

http://bugs.python.org/review/11176/diff/5362/Doc/library/argparse.rst#newcode70
Doc/library/argparse.rst:70:
text_file_lines.extend(text_file.readlines())     # start at "line 1"
I would keep the lines starting from 0, and use the with statement:
with open(args.file) as f:
    lines = list(f)

http://bugs.python.org/review/11176/diff/5362/Doc/library/argparse.rst#newcode74
Doc/library/argparse.rst:74: lines_to_print =
(text_file_lines[args.line_numbers[0]]),
Did you mean to put the comma inside the ()?

http://bugs.python.org/review/11176/diff/5362/Doc/library/argparse.rst#newcode78
Doc/library/argparse.rst:78: lines_to_print =
itemgetter(*args.line_numbers)(text_file_lines)
This is a bit tricky, I would use something like:
[line for n,line in enumerate(lines)
 if n in args.line_numbers]?

http://bugs.python.org/review/11176/diff/5362/Doc/library/argparse.rst#newcode84
Doc/library/argparse.rst:84: print('Line #{0}: 
{1}'.format(args.line_numbers[i], line), end="")
The 0 and 1 are unnecessary.

http://bugs.python.org/review/11176/diff/5362/Doc/library/argparse.rst#newcode207
Doc/library/argparse.rst:207: >>> pizza_parser =
argparse.ArgumentParser(
/me approves pizza

http://bugs.python.org/review/11176/diff/5362/Doc/library/argparse.rst#newcode472
Doc/library/argparse.rst:472: ...                     help='the sauce to
use')
This should be indented under the first ' of the previous line.

http://bugs.python.org/review/11176/diff/5362/Doc/library/argparse.rst#newcode495
Doc/library/argparse.rst:495: ...     help="how man slices the pizza
will be cut up into")
Why a float? can you cut 7.9 slices?

http://bugs.python.org/review/11176/diff/5362/Doc/library/argparse.rst#newcode1125
Doc/library/argparse.rst:1125: >>> pizza_parser.add_argument('slices',
nargs='?', type=int, default=10,
The default here should be 8.

http://bugs.python.org/review/11176/


More information about the docs mailing list