[Python-ideas] Make undefined escape sequences have SyntaxWarnings

Steven D'Aprano steve at pearwood.info
Thu Oct 11 02:07:45 CEST 2012


On 11/10/12 07:04, Serhiy Storchaka wrote:
> On 10.10.12 22:46, Antoine Pitrou wrote:
>> -1. This will make life more difficult with regular expressions (and
>> produce lots of spurious warnings in existing code).
>
> Strings for regular expressions always should be raw.

Why? The re module doesn't care how you construct the strings. It *can't* care
how you construct the strings.

Something like re.search('\D*', 'abcd1234xyz') works perfectly well and there
is no need for a raw string. Any requirement to "always use raw strings" is a
style issue, not a language issue.




-- 
Steven



More information about the Python-ideas mailing list