[issue24549] string.format() should have a safe_substitute equivalent, to be run consecutively
azrdev added the comment: (Sorry for not replying so long, I expected an email notification) > Why not use string.Template? because it's so slow > I think that there may be a good argument to be made for a safe_format with > *named* arguments, like string.Template, but not positional arguments. Yes! > But that would require some discussion, to decide on the correct behaviour. What open question(s) do you think of? For context, I got the idea for this from Qts .arg() which can be chained, see <https://doc.qt.io/qt-5/qstring.html#arg>. -- ___ Python tracker <http://bugs.python.org/issue24549> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24549] string.format() should have a safe_substitute equivalent, to be run consecutively
New submission from azrdev: "{1} {0}".format('one').format('two') should return "two one", but throws IndexError: tuple index out of range This would allow partial replacements, similar to string.Template.safe_substitute() I suggest an analog construction (e.g. a method string.safe_format() ) -- components: Library (Lib) messages: 246047 nosy: azrdev priority: normal severity: normal status: open title: string.format() should have a safe_substitute equivalent, to be run consecutively type: enhancement ___ Python tracker <http://bugs.python.org/issue24549> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com