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.
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/RDS4KL7SUAP4AAA2XVBZTM5SZE4NUU46/
Code of Conduct: http://python.org/psf/codeofconduct/