def print_arg(arg):

    def do_print():
        print(arg)
_exec('do_print(); do_print(); do_print()', globals(), locals())
print_arg(7)
Is it possible to call exec so that it's compatible with both Python 3 and Python 2?