I had a similar problem and decided to inherit it from string.Formatter :
import string class MyFormatter(string.Formatter): def get_field(self, field_name, args, kwargs): return (self.get_value(field_name, args, kwargs), field_name)
however you cannot use str.format() because it still points to the old formatter and you need to go this way
>>> MyFormatter().vformat("{ab}", [], {'a.b': 'Success!'}) 'Success!'
Ski
source share