Different behaviour of regexp in 3.6.0b2

Lele Gaifax lele at metapensiero.it
Fri Oct 14 12:42:07 EDT 2016


Peter Otten <__peter__ at web.de> writes:

> Lele Gaifax wrote:
>
>> The original intent is to replace spaces within a string with the regular
>> expression \s+ (see
>> ...
>> 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”.

> According to
>
> https://docs.python.org/dev/library/re.html#re.sub
>
> rejection of \s is intentional
>
> """
> Changed in version 3.6: Unknown escapes consisting of '\' and an ASCII 
> letter now are errors.
> """

So, how am I supposed to achieve the mentioned intent? By doubling the escape
in the replacement?

> though IMHO the traceback needs a cleanup.

And the documentation as well, to clarify the fact immediately, without
assuming one will scroll down to the "changed in version" part (at least, that
is what seem the rule in other parts of the manual).

Thank you,
ciao, lele.
-- 
nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri
real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia.
lele at metapensiero.it  |                 -- Fortunato Depero, 1929.




More information about the Python-list mailing list