I am using a yaml file to store some config data, including some (many) regex strings that I don't want to keep in code. Everything works except when I try to search for some incorrectly escaped pipe characters with r'\\\|'. I tried quoted, unquoted and literal strings in yaml, nothing works. Yaml and Python string escape rules together seem to conspire to keep the number of backslashes in a string even. I open and load the file with
f=open(file_path, 'r', encoding='utf_8')
python_dict = yaml.load(f)
I'd like to reproduce
re.compile('\\\|')
using something like
re.compile(python_dict['escaped-pipes'])
Python 3.4 with PyYAML.