3 ms·
I don’t understand what you’re seeking. This is purely for string literals. If you’re taking a user input string like `"foo-{date}.{extension}"`, you could use
by chrismorgan 11y ago
I don’t understand what you’re seeking. This is purely for string literals. If you’re taking a user input string like `"foo-{date}.{extension}"`, you could use `string.format(date=…, extension=…)`
- stinos 11y agoYes it's for literals only, just saying I like the inline style and readability and succinctness of it and wouldn't mind it being implemented in Python and other languages.
- dalke 11y agoBut 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.
- stinos 11y agoYes, I know that as well. But this wasn't a Python application :] Maybe should have mentioned that earlier..