mirror of
https://github.com/python/cpython.git
synced 2025-10-17 20:28:43 +00:00
Bug #1361643: fix textwrap.dedent() so it handles tabs appropriately,
i.e. do *not* expand tabs, but treat them as whitespace that is not equivalent to spaces. Add a couple of test cases. Clarify docs.
This commit is contained in:
parent
0e1159583c
commit
7f54740c4d
4 changed files with 107 additions and 43 deletions
|
@ -47,12 +47,17 @@ remove indentation from strings that have unwanted whitespace to the
|
|||
left of the text.
|
||||
|
||||
\begin{funcdesc}{dedent}{text}
|
||||
Remove any whitespace that can be uniformly removed from the left
|
||||
of every line in \var{text}.
|
||||
Remove any common leading whitespace from every line in \var{text}.
|
||||
|
||||
This is typically used to make triple-quoted strings line up with
|
||||
the left edge of screen/whatever, while still presenting it in the
|
||||
source code in indented form.
|
||||
This can be used to make triple-quoted strings line up with the left
|
||||
edge of the display, while still presenting them in the source code
|
||||
in indented form.
|
||||
|
||||
Note that tabs and spaces are both treated as whitespace, but they are
|
||||
not equal: the lines \code{" {} hello"} and \code{"\textbackslash{}thello"}
|
||||
are considered to have no common leading whitespace. (This behaviour is
|
||||
new in Python 2.5; older versions of this module incorrectly expanded
|
||||
tabs before searching for common leading whitespace.)
|
||||
|
||||
For example:
|
||||
\begin{verbatim}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue