3 ms·
As an outsider to the python community and full time ruby dev, this "controversy" baffles me every time it comes up. Lightweight string interpolation is obvious
by losvedir 11y ago
As an outsider to the python community and full time ruby dev, this "controversy" baffles me every time it comes up. Lightweight string interpolation is obviously better! I think you all have string Stockholm Syndrome or something.
The one counter argument that makes sense to me is that in general we shouldn't be doing easy string interpolation, since that way lies SQL injection, XSS, etc, and should instead rely on a stronger type system with binary text blobs, HtmlStrings, SqlStrings, etc, with automatic escaping into and out of the data type.
But then that's not the case with Python now. If you're only trying to stick this string inside that string in a quick and dirty manner, I totally don't understand the reticence folks have to something the way ruby does it: "Name: #{first_name}".
- scrollaway 11y agoIf it's obviously better, would you care to share some better arguments than "people who disagree have stockholm syndrome"? Don't get me wrong, I'd like Python to have better, more obvious, more concise string formatting. However the last time we had this discussion, it was about str.format() and how it was going to be awesome and don't worry modulo-formatting will go away. Turns out it did not; modulo formatting is still there because why would it be removed. This is history repeating itself - are you actually baffled that some people learn from past mistakes?
- mixmastamyk 11y agoAll you have to do is try it once or twice to enjoy the readability and lack of positional mismatch bugs. None of the other techniques are going away. This time yes, no one is naive enough to think so.
- scrollaway 11y ago"Try it!" is not an objective argument (I have tried it extensively eg. in Bash and I neither like or hate it), and positional mismatch is not a concern when you use name-based syntax, which interpolation forces you into due to its nature.
- mixmastamyk 11y agoI've made numerous posts in this discussion, so not going to copy them again here. The previous named-based syntax comes with significant redundancy and noise. As a ruby dev posted here, it is obviously better in most respects in most common cases.