Something similar to eval is the exec function. What exec is going to do is both compile and evaluate a statement from a string.
So, as you might guess, this one is even more dangerous than pickle and eval, so again, only do this with
sources that can be trusted. This is another example of something people might get the wild idea of using unprotected with some sort online form so they can create their own embedded Python IDE in a browser.
Let's see some examples of exec. If you recall from the previous tutorial, eval wouldn't compile any code. Exec, however, will. Let's see:
First, we can see how it can do the same things eval does, like: