Skip to content

Commit fbbef96

Browse files
savannahostrowskimiss-islington
authored andcommitted
GH-54732: Tweak wording around empty lines in argument files (GH-150980)
(cherry picked from commit 528550e) Co-authored-by: Savannah Ostrowski <savannah@python.org>
1 parent fc9b11f commit fbbef96

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

Doc/library/argparse.rst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -423,9 +423,8 @@ is considered equivalent to the expression ``['-f', 'foo', '-f', 'bar']``.
423423

424424
.. note::
425425

426-
Empty lines are treated as empty strings (``''``), which are allowed as values but
427-
not as arguments. Empty lines that are read as arguments will result in an
428-
"unrecognized arguments" error.
426+
Each line is treated as a single argument, so an empty line is read as an
427+
empty string (``''``).
429428

430429
:class:`ArgumentParser` uses :term:`filesystem encoding and error handler`
431430
to read the file containing arguments.
@@ -2088,6 +2087,9 @@ Customizing file parsing
20882087
def convert_arg_line_to_args(self, arg_line):
20892088
return arg_line.split()
20902089

2090+
Note that with this override an argument can no longer contain spaces, since
2091+
each space-separated word becomes a separate argument.
2092+
20912093

20922094
Exiting methods
20932095
^^^^^^^^^^^^^^^

0 commit comments

Comments
 (0)