USER_CODE_FILE = '/home/user/user_code_file.py'
PYTHON_PATH = '/usr/bin/python'
import subprocess
import json
user_code = """
import json
my_data= {"a":[1,2,3]}
print json.dumps(my_data)
"""
with open(USER_CODE_FILE, 'wb') as f:
    f.write(user_code)
user_result_str = subprocess.check_output([PYTHON_PATH, USER_CODE_FILE])
user_result = json.loads(user_result_str)
print(user_result)
Можно ли ограничить доступ к глобальным переменным для блока кода в python?