pyEnsemblRest
pyEnsemblRest copied to clipboard
Use raw strings to silence deprecation warnings
Beginning with Python 3.6, using a backslash literal before a character
(where the two do not form an escape sequence) has been deprecated.
It's unclear if the author means for there to be two characters - a
backslash and then the following character (e.g. '\-') or a single
character (e.g. a newline literal '\n'
https://docs.python.org/dev/whatsnew/3.6.html#deprecated-python-behavior
To silence these deprecation warnings, use a raw string syntax instead.
Note that these strings are exactly equivalent:
$ PYTHONWARNINGS=always python3
>>> old_pattern = '\{\{(?P<m>[a-zA-Z1-9_]+)\}\}'
<stdin>:1: DeprecationWarning: invalid escape sequence \{
>>> new_pattern = r'\{\{(?P<m>[a-zA-Z1-9_]+)\}\}'
>>> new_pattern == old_pattern
True