Skip to content

Instantly share code, notes, and snippets.


Ofer Koren koreno

View GitHub Profile
tonyseek /
Last active Jul 11, 2019
Convert the old style string formatting of Python into the new style one.
import re
def convert_string_template(string):
index = -1
def repl(matched):
nonlocal index
keyword =
if keyword:
return "{%s}" % keyword.strip('()')