3 ms·
I like the general thrust of PEP 498 (`f""` is explicit, unlike Ruby or Bash's magic `"` vs. `'`). That said, I think it would be much improved if it went the
by svieira 11y ago
I like the general thrust of PEP 498 (`f""` is explicit, unlike Ruby or Bash's magic `"` vs. `'`).
That said, I think it would be much improved if it went the way of Scala and JavaScript (2015+) and made `r`, `u`, `b`, and `f` all interpolation providers. That way libraries could provide interpolators without having to extend the language to create a new one.
For example, in Scala or JavaScript, you can create a string context / template tag for composing JSON strings, resulting in a nice syntax like this (scala-like):
json"""{
"my": $data,
"anArray": $someArray
}"""
The `data` and `someArray` values serialized to JSON by the `json` interpolation provider.
At that point, internationalization is just creating your own interpolation provider and importing it as `i`, which is far less machinery than this PEP requires.
- dragonwriter 11y ago> (`f""` is explicit, unlike Ruby or Bash's magic `"` vs. `'`) Both are equally explicit, though f"" is perhaps marginally more clear because it is somewhat mnemonic.