def outer(x): def inner(): x return 'x={x}'.format_map(locals()) return inner outer(42)()