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