MCPcopy Index your code
hub / github.com/python/cpython / format

Method format

Lib/test/test_peepholer.py:709–715  ·  view source on GitHub ↗
(fmt, *values)

Source from the content-addressed store, hash-verified

707
708 def test_format_misc(self):
709 def format(fmt, *values):
710 vars = [f'x{i+1}' for i in range(len(values))]
711 if len(vars) == 1:
712 args = '(' + vars[0] + ',)'
713 else:
714 args = '(' + ', '.join(vars) + ')'
715 return eval(f'{fmt!r} % {args}', dict(zip(vars, values)))
716
717 self.assertEqual(format('string'), 'string')
718 self.assertEqual(format('x = %s!', 1234), 'x = 1234!')

Callers

nothing calls this directly

Calls 1

joinMethod · 0.45

Tested by

no test coverage detected