This is the behavior I need: path = path.replace('\\', '\\\\') msg = ". {} .. '{}' .. {} .".format(a, path, b) Is there a better way? Kiuhnm