3 ms·
I do a similar thing as suggested by the article, except by using Python's "concat between parenthesis" strings instead of Python's heredoc strings. The advanta
by sam2426679 4y ago
I do a similar thing as suggested by the article, except by using Python's "concat between parenthesis" strings instead of Python's heredoc strings. The advantage of doing it this way is that there are no caveats (as mentioned in the article) with needing to unexpectedly escape certain characters.
It looks like this:
pattern = (
r'[A-Z]*H' # prefix
r'\d+' # digits
r"[a-z']*" # suffix
)
No funky stuff with escapes, and you can indent to your heart's content.