Let\'s say, I have a string:
> my_string = \'{foo}/{bar}\' > my_string.format(foo=\'foo\', bar=\'bar\') \'foo/bar\'
Right, coo
Why reinvent the wheel? string.Formatter has the parse() function.
string.Formatter
>>> import string >>> [a[1] for a in string.Formatter().parse('{foo}/{bar}')] ['foo', 'bar']