On Sat, Oct 15, 2016 at 2:40 AM, Lele Gaifax <l...@metapensiero.it> wrote: > Accordingly to the documentation > (https://docs.python.org/3.6/library/re.html#re.sub) > “unknown escapes [in the repl argument] such as \& are left alone”. > > Am I missing something, or is this a regression?
Further down, you'll find this note: Changed in version 3.6: Unknown escapes consisting of '\' and an ASCII letter now are errors. There's a shift as of 3.6 to make unrecognized alphabetic escapes into errors, or at least warnings. rosuav@sikorsky:~$ python3 -Wall Python 3.7.0a0 (default:a78446a65b1d+, Sep 29 2016, 02:01:55) [GCC 6.1.1 20160802] on linux Type "help", "copyright", "credits" or "license" for more information. >>> "C:\Documents\my_user" sys:1: DeprecationWarning: invalid escape sequence '\D' sys:1: DeprecationWarning: invalid escape sequence '\m' 'C:\\Documents\\my_user' >>> rosuav@sikorsky:~$ python3.5 -Wall Python 3.5.2+ (default, Sep 22 2016, 12:18:14) [GCC 6.2.0 20160914] on linux Type "help", "copyright", "credits" or "license" for more information. >>> "C:\Documents\my_user" 'C:\\Documents\\my_user' >>> I wasn't specifically aware that the re module was doing the same thing, but it'll be from the same purpose and goal. The idea is that, for instance, Windows path names in non-raw string literals will no longer behave differently based on whether the path is "my_user" or "the_other_user". Definite improvement. ChrisA -- https://mail.python.org/mailman/listinfo/python-list