Eric V. Smith added the comment:
So let's say your function would be named "safe_format". Then:
"{1} {0}".safe_format('one')
would give: "{1} one".
Then:
"{1} one".safe_format('two')
would be an error, because there's no index "1" in the args tuple.
I can't imagine how you'd implement this function so it would know to start
with index 1 on the second call, instead of 0 as usual.
Or maybe it would decrement the index values it doesn't use, so that the result
of the first call would be: "{0} one". That seems very complex, especially when
you throw in implicit argument numbering, named arguments, format specifiers,
etc.
I agree with David that string.Template might be better for you.
On an unrelated note, I think that "IndexError: tuple index out of range" is a
horrible error message for this case. I wouldn't mind an enhancement request to
make that something like "argument index '1' is out of range, only 1 argument
supplied". Or something with better wordsmithing.
----------
components: +Interpreter Core -Library (Lib)
nosy: +eric.smith
versions: +Python 3.6
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue24549>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com