Python's str.replace
seems to be doing "clever" character escaping and the docs don't show any way to 'override' this behaviour.
Expected:
x = "val|with|pipe"
x.replace("|","\|")
>>> "val\|with\|pipe"
Actual output:
x.replace("|","\|")
>>> "val\\|with\\|pipe"
Bonus Round:
x.replace('|','\\|')
>>> "val\\|with\\|pipe"