As pointed out in another subthread, Python code is practically impossible to sandbox. Most competition isolate player code by running it in a separate process which has the additional benefit of easily allowing different implementation languages.
Making sure the process doesn't use your network to spread malware is not 100% trivial but still easier than sandboxing Python code within Python.
Good luck with your project!