73 karma · joined November 25, 2015
If the string is not an f-string, you get no help from Python tooling.
In both cases, you have to use frame hacks to get back to the scope, which has negative consequences.
From their POV, inside the quotes, what you know about f-strings, you know here as well.
I don't particularly mind the prefix thing. It came up in the PEP discussion, as did choice of backticks to indicate this is different. But JS template literals -> tagged template literals shows, you can get from A to B without a fundamental change.
I'm very interested though in the deferred part. I agree that there is complexity. I weigh that, though, against the complexity of existing Python HTML templating, where finding out what just happened is...harder.
I think we can get a TSX-level of DX out of this. And maybe a Lit level of composition. Agree that it is non-zero complexity.
- 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.
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/
Companion repo with: JupyterLite playground, Docker images, other material. https://github.com/pauleveritt/tagstr-site
I see things differently. In those, nearly everything is a parallel universe where things aren't Python. Scope rules. Imports. Control flow. Calling things. Navigation. Refactoring. Linting. Therefore, Python tooling can't really help much. Tools have to write special rules to help on each template language and framework.
Instead, imagine if Black, Ruff, mypy, pyupgrade, and IDEs could treat the template part as software.
I realize I'm describing "people who want Python tooling", which might be a minority. I also realize there's pushback about additions to Python. That said, I think TSX and friends have shown -- there's lots we can do to improve Python web development.
Hooking these two up would make for a neat programming experience. Best of all...if some $$ €€ were involved, it would show Python open source can be sustainable.
Can you let me know if this is the kind of thing that you're talking about?