2 ms·
An issue that can still happen with python's string formatting is that you can get the number of arguments/`{}` wrong. D (other languages too, probably) has com
by ben-schaaf 8y ago
An issue that can still happen with python's string formatting is that you can get the number of arguments/`{}` wrong. D (other languages too, probably) has compile-time format string, as well as automatic string conversion: `format!"%s"(2)`. Giving the wrong format string/argument types fails at compile time. Some C/C++ compilers also automatically check this for printf. Though they can still fail if the actual output writing fails, ie. stdout is closed or doesn't exist.
- teddyh 8y ago> An issue that can still happen with python's string formatting is that you can get the number of arguments/`{}` wrong. Easily avoided by using the latest Python feature, added in 3.6: Formatted string literals, a.k.a. f-strings¹. Instead of using "foo {} baz".format(bar) you use f"foo {bar} baz" 1. https://www.python.org/dev/peps/pep-0498 https://www.python.org/dev/peps/pep-0498