On Mon, Feb 13, 2017 at 11:11 AM, Chris Angelico <ros...@gmail.com> wrote: > The string "\t" gets shown in the repr as "\t". It is a string > consisting of one character, U+0009, a tab. The string r"\t" is shown > as "\\t" and consists of two characters, REVERSE SOLIDUS and LATIN > SMALL LETTER T. That might be why you think there's confusing stuff > happening :)
Oh, and the other trap you can fall into is the reverse of that: >>> "worl\d" 'worl\\d' This one actually triggers a warning in sufficiently-recent Pythons: $ python3 -Wall Python 3.7.0a0 (default:cebc9c7ad195, Jan 24 2017, 06:55:19) [GCC 6.2.0 20161027] on linux Type "help", "copyright", "credits" or "license" for more information. >>> "worl\d" <stdin>:1: DeprecationWarning: invalid escape sequence \d 'worl\\d' A future Python may define \d to mean something else, or may trigger an error on this. ChrisA -- https://mail.python.org/mailman/listinfo/python-list