3 ms·
> People seems to be under the illusion that this stuff is easy, or obvious. Sure. In 2022. I mentioned that Ruby had this for "upwards of 20 years." I was va
by haberman 4y ago
> People seems to be under the illusion that this stuff is easy, or obvious. Sure. In 2022.
I mentioned that Ruby had this for "upwards of 20 years." I was vague on the timeline because I didn't know for sure how long it had been. After reading your message I looked into it and it looks like Ruby supported "#{expr}" since at least Ruby 0.95, in 1995: https://github.com/nobu/ruby-1.0/blob/master/sample/tkdialog.rb#L58 https://github.com/nobu/ruby-1.0/blob/master/sample/tkdialog...
This is not to mention Perl, awk, shell, and Tcl, which had syntax like $FOO for even longer.
Ruby's solution existed before all of the following PEPs, which added different varieties of string formatting to Python:
- PEP 215 – String Interpolation (2000) (superseded by PEP 292)
- PEP 292 – Simpler String Substitutions (2002), added string.Template()
- PEP 3101 – Advanced String Formatting (2006), added str.format()
- PEP 498 – Literal String Interpolation (2015), added f''
I get that language design is hard, and it's difficult to have the final answer right away. But it's not as if this idea was unknown or untested when Python introduced other home-grown solutions. When Python proposed f strings in 2015, it imitated a design that had been in Ruby for almost 20 years at that point.