0


I'm writing a script where I'm asking the user to provide some python code that I store in a xml file to reuse it later. The thing is, I'd like to test this code before storing it to see if it works at all.

How can I achieve that without actually executing the script?

UKDP
  • 226
  • 5
  • 21
  • What is the risk of executing it? That it will take too long or that it will cause unwanted changes? What kind of code are you expecting them to enter? Do you have no reason to worry about malicious code? You can probably catch syntax errors with the `ast` module, do you want more than that? – Alex Hall May 12 '16 at 08:35
  • I don't think it is possible to know entirely if it raises an exception before executing the code... You could check some pre-conditions using `if-else`, but not entirely. – Ian May 12 '16 at 08:36
  • I don't get the reasoning behind this? why don't you test input, storage yourself first to see if it works? Shouldn't you always test? – izk May 12 '16 at 08:36
  • The thing is, that's a python script for Maya, and if I execute it, it will probably modify the scene or create some objects. Sorry if I misunderstood something, I learnt python all by myself, so I probably don't understand every tricks. – UKDP May 12 '16 at 08:42
  • Can you make a copy of a Maya file and execute the script on that copy? – Alex Hall May 12 '16 at 08:45
  • I don't know if that possible. I'll take a look, that's a good idea. Can't I at least test if the synthax is okay? – UKDP May 12 '16 at 08:50

0 Answers0