MCPcopy Create free account
hub / github.com/dabeaz/python-cookbook / sub

Function sub

src/2/variable_interpolation_in_strings/example.py:25–26  ·  view source on GitHub ↗
(text)

Source from the content-addressed store, hash-verified

23n = 37
24import sys
25def sub(text):
26 return text.format_map(safesub(sys._getframe(1).f_locals))
27
28print(sub('Hello {name}'))
29print(sub('{name} has {n} messages'))

Callers 1

example.pyFile · 0.70

Calls 1

safesubClass · 0.85

Tested by

no test coverage detected