
May 6, 2021
3:43 a.m.
Maybe I'm missing something, but why do you need the SimpleNamespace at all? Why not make your own mapping as in class StringMapper: ... def __getitem__(self, s): # Whatever arbitrary behavior you want # Process suffixes, etc here, for example: if s.endswith(".lc"): return self.wrapped[s.removesuffix(".lc")].lower() return self.wrapped[s] format_string.format_map(StringMapper(whatever)) Maybe then the data can just be data and this wrapper can handle all the formatting conversions.