How are you giving the strings?
If you are giving a complete python program in the string, you do a trick:
Write all the string into a file and execute it with the interpreter by using a execv or system command.
You are loading code from a string into your application and running it. Unless you have compete and absolute control over the string (you create it yourself, and no part of it comes from outside our program), there is always a way for someone to inject some malicious code into your program.
What does it return, an error message? exec() will work on things like print statements or 1+2-3, but if you call a function or class then you must already have that function defined, otherwise an error message. Perhaps if you explained what you are trying to do, there would be an easier way, like a generic class that you would pass the strings in the file to as parameters --> some_class( the_string ).
in the main program, I read a text file which outputs:
Vent( 100,300, 'Vent' )
I assign that string from the text file to a var called 'temp_string', and then I go:
It doesn't work, but I write up some code that (based of the strings from the text file) recognizes the first four characters in a line, a.k.a 'Vent', and then gets the string(s) from in between the characters '(' and ',' and then ',' and ','. The last argument just stays a string. I then pass a new instance with those new given values. It's no big deal if the exec thing doesn't work, but thanks any ways