I'm formatting a lot of strings for user messages. One might look like this:
def sms(**kwargs):
return "Sorry {name}, but your payment was rejects. Please visit {url} and try again.".format(
name=kwargs.get('name'),
url=shorten_url(kwargs.get('url'))
)
If I dont need to reformat any of the keyword args, I could just do this this is sweet:
def sms(**kwargs):
return "Sorry {name}, but your payment was rejects. Please visit {url} and try again.".format(**kwargs)
So I was hoping maybe it would be possible to do something like this:
def sms(**kwargs):
return "Sorry {name}, but your payment was rejects. Please visit {url|shorten_url} and try again.".format(**kwargs)
So I could format the string inline using pipes. It may not seem like a big deal, but I'm writing a LOT of these messages.
I noticed python string.vformat function but I'm not sure if thats what I'm looking for. Any ideas?