But this wouldn't solve your case because it could only be applied to strings that are in the source code. Your users don't have the ability to change those string. Instead, they want to provide a format string, which you fill in. That is already available, eg, via str.format(kwargs), where you control the kwargs and the user controls the str.