Hacker News new | ask | show | jobs
by pauleveritt 679 days ago
If the string is an f-string, it is immediately evaluated and you no longer have access to the interpolation info for a resolver.

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.

1 comments

> If the string is an f-string, it is immediately evaluated and you no longer have access to the interpolation info for a resolver.

So? It's been evaluated successfully. What more is there to do?

> If the string is not an f-string, you get no help from Python tooling.

Expose that tooling via the standard library. It's just pure functions.

> In both cases, you have to use frame hacks to get back to the scope, which has negative consequences.

What consequences? Isn't CPython forced to do all the nasty stuff anyhow when it's a language feature?

Frame hacks with sys._getframe necessarily imply dynamic scope not lexical scope. Dynamic scope does not work with nested functions, including comprehensions. See this issue with the htm library, https://github.com/jviide/htm.py/issues/11