def _swap_curly ( string ) : return ( string . replace ( '{{ ' , '{{' ) . replace ( '{{' , '\x00' ) . replace ( '{' , '{{' ) . replace ( '\x00' , '{' ) . replace ( ' }}' , '}}' ) . replace ( '}}' , '\x00' ) . replace ( '}' , '}}' ) . replace ( '\x00' , '}' ) )
python curly brakcet string fixed width
Swap single and double curly brackets
def _swap_curly(string):
    """Swap single and double curly brackets"""
    return (
        string.replace('{{ ', '{{').replace('{{', '\x00').replace('{', '{{')
        .replace('\x00', '{').replace(' }}', '}}').replace('}}', '\x00')
        .replace('}', '}}').replace('\x00', '}')
    )