diff options
author | Rafael Fontenelle <rffontenelle@users.noreply.github.com> | 2025-04-01 04:19:06 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-04-01 08:19:06 +0100 |
commit | 23a658b9af410b72beeb28ba4ace2d83896c5631 (patch) | |
tree | 00264c94d16bb6f5fee065c1ad83616f80dd5864 | |
parent | 2505573f2094092b6262e5831c9832d95e77f223 (diff) | |
download | cpython-23a658b9af410b72beeb28ba4ace2d83896c5631.tar.gz cpython-23a658b9af410b72beeb28ba4ace2d83896c5631.zip |
Minor improvements to the programming FAQ (#127261)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
-rw-r--r-- | Doc/faq/programming.rst | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/Doc/faq/programming.rst b/Doc/faq/programming.rst index 776bab1ed5b..b39efced304 100644 --- a/Doc/faq/programming.rst +++ b/Doc/faq/programming.rst @@ -986,8 +986,8 @@ There are various techniques. f() -Is there an equivalent to Perl's chomp() for removing trailing newlines from strings? -------------------------------------------------------------------------------------- +Is there an equivalent to Perl's ``chomp()`` for removing trailing newlines from strings? +----------------------------------------------------------------------------------------- You can use ``S.rstrip("\r\n")`` to remove all occurrences of any line terminator from the end of the string ``S`` without removing other trailing @@ -1005,8 +1005,8 @@ Since this is typically only desired when reading text one line at a time, using ``S.rstrip()`` this way works well. -Is there a scanf() or sscanf() equivalent? ------------------------------------------- +Is there a ``scanf()`` or ``sscanf()`` equivalent? +-------------------------------------------------- Not as such. @@ -1020,8 +1020,8 @@ For more complicated input parsing, regular expressions are more powerful than C's ``sscanf`` and better suited for the task. -What does 'UnicodeDecodeError' or 'UnicodeEncodeError' error mean? -------------------------------------------------------------------- +What does ``UnicodeDecodeError`` or ``UnicodeEncodeError`` error mean? +---------------------------------------------------------------------- See the :ref:`unicode-howto`. @@ -1036,7 +1036,7 @@ A raw string ending with an odd number of backslashes will escape the string's q >>> r'C:\this\will\not\work\' File "<stdin>", line 1 r'C:\this\will\not\work\' - ^ + ^ SyntaxError: unterminated string literal (detected at line 1) There are several workarounds for this. One is to use regular strings and double |