bpo-30754: Document textwrap.dedent blank line behavior. (GH-14469)

* Added documentation for textwrap.dedent behavior.
* Remove an obsolete note about pre-2.5 behavior from the docstring.
(cherry picked from commit eb97b9211e)

Co-authored-by: tmblweed <tmblweed@users.noreply.github.com>
This commit is contained in:
Miss Islington (bot) 2019-06-29 21:38:11 -07:00 committed by GitHub
parent ffa419ad00
commit e2e41cd114
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View File

@ -77,6 +77,9 @@ functions should be good enough; otherwise, you should use an instance of
equal: the lines ``" hello"`` and ``"\thello"`` are considered to have no equal: the lines ``" hello"`` and ``"\thello"`` are considered to have no
common leading whitespace. common leading whitespace.
Lines containing only whitespace are ignored in the input and normalized to a
single newline character in the output.
For example:: For example::
def test(): def test():

View File

@ -420,9 +420,9 @@ def dedent(text):
Note that tabs and spaces are both treated as whitespace, but they Note that tabs and spaces are both treated as whitespace, but they
are not equal: the lines " hello" and "\\thello" are are not equal: the lines " hello" and "\\thello" are
considered to have no common leading whitespace. (This behaviour is considered to have no common leading whitespace.
new in Python 2.5; older versions of this module incorrectly
expanded tabs before searching for common leading whitespace.) Entirely blank lines are normalized to a newline character.
""" """
# Look for the longest leading string of spaces and tabs common to # Look for the longest leading string of spaces and tabs common to
# all lines. # all lines.