News for hackers. Stuff that matters.
Re:New string formatting in Python by losvedir on Monday January 04, 2016 @04:42AM (#10834702)
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}".

Re:New string formatting in Python by scrollaway on Monday January 04, 2016 @04:52AM (#10834733)
If 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?

Re:New string formatting in Python by mixmastamyk on Monday January 04, 2016 @12:58PM (#10837138)
All 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.

Re:New string formatting in Python by scrollaway on Monday January 04, 2016 @04:04PM (#10838599)
"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.
Re:New string formatting in Python by mixmastamyk on Monday January 04, 2016 @05:47PM (#10839345)
I'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.