On 21/08/21 1:36 pm, Hope Rouselle wrote:
I wish I could restrict their syntax too, though,
but I fear that's not possible.  For instance, it would be very useful
if I could remove loops.

Actually you could, using ast.parse to get an AST and then walk
it looking for things you don't want to allow.

You could also play around with giving them a custom set of
builtins and restricting what they can import. Just be aware
that such things are not foolproof, and a sufficiently smart
student could find ways around them. (Although if they know
that much they probably deserve to pass the course anyway!)

--
Greg
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to