3 ms·
say looks nice, but it still suffers from exactly what this pep is trying to fix >>> def test(x=1):return lambda:say.say("{x}") >>> test() NameErro
by RubyPinch 11y ago
say looks nice, but it still suffers from exactly what this pep is trying to fix
>>> def test(x=1):return lambda:say.say("{x}")
>>> test()
NameError: name 'x' is not defined
https://github.com/syrusakbary/interpy https://github.com/syrusakbary/interpy seems like a closer solution, could be modified to also support format specs
- jonathaneunice 11y agoI think you're right that Interpy and PEP 498 have a different, earlier binding strategy than say does. I've found the late / local binding of say() and fmt() convenient. Are there use cases where that earlier binding is valuable or critical? Your example highlights the binding strategy, but more typical would be: >>> def test(x=1): ... return fmt("{x}") ... >>> test() '1' >>> test(12) '12' >>> test('woobers') 'woobers'