Greg Ewing <greg.ew...@canterbury.ac.nz> writes: > 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.
Very interesting! Thanks very much. That would let me block them, though the ideal would be a certain python.exe binary that simply blows a helpful syntax error when they use something the course doesn't allow. But surely the course could provide students with a certain module or procedure which would validate their work. (Don't turn in unless you pass these verifications.) > 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!) So true! If they can get around such verifications, they should present their work at an extra-curricular sessions. -- https://mail.python.org/mailman/listinfo/python-list