Python Tip #90 (of 365):

Always use raw strings when defining regular expressions

I recommend this in order to:

1. Avoid warnings about invalid escape sequences
2. Avoid accidentally using a real escape sequence
3. Clarify which strings are regular expressions

Raw strings double up backslashes, disallowing escape sequences.

๐Ÿงต (1/2)

#Python #DailyPythonTip

@treyhunner wait, is r"" a raw string? In my head I've always interpreted that was a regular expression "string"
@CodenameTim @treyhunner precisely. Raw means no escape rewriting.