3 ms·
> * fmt("Hello, {name}! You have {len(msgs)} waiting.")* Yikes! Please don't tell me that's a function which peeks at the caller's lexical variables, at run
by kazinator 11y ago
> * fmt("Hello, {name}! You have {len(msgs)} waiting.")*
Yikes!
Please don't tell me that's a function which peeks at the caller's lexical variables, at run time, by name?
I see "inspect.currentframe().f_back" hacks in the code, good grief.
- jonathaneunice 11y agoYes indeed. That's exactly how it works. Introspection. Given a language that doesn't support templated strings inherently, how else would you provide that feature? Though technically, `fmt` is not a function per se. It's an object with a `__call__` method. That doesn't improve the situation for you, does it?