def alltt_escape(s):
    'Replace backslash and braces with their escaped equivalents'
    xlat = {'{': r'\{', '}': r'\}', '\\': r'\textbackslash{}'}
    return re.sub(r'[\\{}]', lambda mo: xlat[mo.group()], s)
Replace backslash and braces with their escaped equivalents
recipes/Python/578178_Colorize_Pyth_Sourcecode_Syntax/recipe-578178.py