PDA

View Full Version : Running inputted code



gameguy
August 12th, 2011, 01:09 PM
I'm trying to run some code inputted by the user.
I am attempting to use the eval statement without much luck.
I am trying to input commands like "a = b[0]" (that's an example). The problem seems to be that I can't set variable names using eval. Does anyone know how to solve this problem, or have any suggestions?
PS. Yes, I know this is dangerous. this would be used by me, not others

Tony Flury
August 12th, 2011, 01:39 PM
Which language - that would help.

I know in Python there is a module for compiling code fragments - I have never used it though.

gameguy
August 12th, 2011, 10:54 PM
Python. Thanks