At the risk of riling some people up, this smells like Perl. Some poor Python user comes across
greet"Hello {user}"
and there isn't even so much as a symbol they can search for on the internet, just an identifier smashed into a string.But I guess Python and I parted ways on this matter quite a while ago. I like to joke about Katamari Dama-C++ but Python is starting to give it a run for its money. C++ is still in the lead, but Python is arguably sustainably moving more quickly on the "add more features" front.
Also it’s harder to do nothing than something.
That being said, I think this is partly abstract. I’ve just ignored a lot of new Python features without issue. And while I worried that they’d force me to learn new things to understand others’ code, that’s not really materialized.
That identifier has to come from somewhere. In order for this to work:
greet"Hello {user}"
…they would have to first write something like: from some_tag_strings_library import greet
Also, in most IDEs, cmd-clicking on `greet` or similar would take them to its definition.html() is not going to be equivalent.
Companion repo with: JupyterLite playground, Docker images, other material. https://github.com/pauleveritt/tagstr-site
It required a janky workaround for the absence of this PEP: https://pypi.org/project/tagged/
I used these to investigate ideas about component-driven development: https://viewdom.readthedocs.io/en/latest/
- No tooling in Python will do anything with the string, so DX suffers. - Evaluating the variable requires frame evaluation, which is...problematic.
You could do `html(f'<div>Hello {name}</div>')` and get f-string coding assistance. But you'd also get immediate evaluation. There's nothing the `html` function can do with the `{name}` part.
That f-strings were "static" was by far my biggest criticism of it, given how useful I find JS's template strings.
And this proposal seems like a straight up better version of template strings:
- the static strings and interpolations are not split and don't have to be awkwardly re-interpsersed which I've never found 100% trouble and 0% utility
- the lazy evaluation means it can be used for things like logging (which really want lazy evaluation), or meta-programmation (because you can introspect the callables, and you get the expression text)
Could you elaborate? I would find it rather surprising if my log messages don't contain the data at the very moment I invoke the logger.
In most APIs this requires an explicit conditional check and the average developer will not think of it. This allows said check to be performed internally.
It's such a subtle difference that I only notice it when my IDE underlines it :/