Python's built-in compile
function has eval
, exec
and single
modes. single
mode seems a bit useless (ref). How about the eval
and exec
?
- eval: works on an
expression
- exec: works on
statements
But an expression
is a statement
. My question is: why not just use exec
all the time?
PS: I've read some related questions like Python built-in function "compile". What is it used for?. They do a good job explaining the difference between the modes, but doesn't directly answer my question.