I have to run some student-made code that they made as homework, I'm running this on my own computer (Mac OS), and I'm not entirely certain they won't accidentally "rm -rf /" my machine. Is there an easy way to run their python scripts with reduced permissions, so that e.g. they can access only a certain directory? Is PyPy the way to go?
Create a new user account "student". Run your students' scripts as "student". Worst case, the script will destroy this special user account. If this happens, just delete user "student" and start over.
Run python script with reduced permissions