2 ms·
> printf-style formatting ("foo %s" % "bar") feels the most ready to be retired (except insofar as it probably never will, because it's a nice shortcut). It’s
by masklinn 2y ago
> printf-style formatting ("foo %s" % "bar") feels the most ready to be retired (except insofar as it probably never will, because it's a nice shortcut).
It’s also the only one which is anything near safe for being user provided.
- pansa2 2y agoI don’t think I’ve ever used % formatting in Python - what makes it safer than `format`?
- masklinn 2y ago`str.format` allows the format string to navigate through indexes, entries, and attributes. If the result of the formatting is echoed back and any non-trivial object it passed in, it allows for all sorts of introspection. printf-style... does not support any of that. It can only format the objects passed in.
- rtpg 2y agoVery good point. While I think we could do away with the syntactic shorthand, definitely would want to keep some function/method around with the capabilities.