def exec_then_eval(code, namespace=None):
<EOL>namespace = namespace or {}<EOL>block = ast.parse(code, mode='<STR_LIT>')<EOL>last = ast.Expression(block.body.pop().value)<EOL>exec(compile(block, '<STR_LIT>', mode='<STR_LIT>'), namespace)<EOL>return eval(compile(last, '<STR_LIT>', mode='<STR_LIT>'), namespace)<EOL>
Exec a code block & return evaluation of the last line