# HG changeset patch # Parent 7f4325dc42565fadfd1f768c8464372fb414001f Issue #17670: Provide an example of expandtabs() usage. diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -1527,10 +1527,19 @@ .. method:: str.expandtabs([tabsize]) Return a copy of the string where all tab characters are replaced by zero or - more spaces, depending on the current column and the given tab size. The - column number is reset to zero after each newline occurring in the string. - If *tabsize* is not given, a tab size of ``8`` characters is assumed. This - doesn't understand other non-printing characters or escape sequences. + more spaces, depending on the current tab column and the given tab size. + Starting at the first character of the string, the tab column is set to + zero. Whenever a tab character (``\t``) is encountered, space characters + are inserted as needed until the next tab position is reached and the tab + column is set to that tab position; the tab character itself is not copied. + Whenever a newline character (``\n`` or ``\r``) is encountered, it is copied + and the tab column is reset to zero. Any other character is copied unchanged + and the tab column is incremented by one regardless of how it may be + represented when printed. If *tabsize* is not given, a tab size of 8 + characters is assumed. + + >>> '012\t4\t89'.expandtabs(4) + '012 4 89' .. method:: str.find(sub[, start[, end]])