def embed(): vars = globals() vars.update(locals()) shell = code.InteractiveConsole(vars) shell.interact()