Python: add triple doc quotes and handle expansion of `"|"`