Security aside, `eval` and `exec` are often marked as undesirable because of the complexity they induce. When you see a `eval` call you often don't know what's really going on behind it, because it acts on data that's usually in a variable. This makes code harder to read.
Invoking the full power of the interpreter is a heavy weapon that should be only reserved for very tricky cases. In most cases, however, it's best avoided and simpler tools should be employed.
That said, like all generalizations, be wary of this one. In some cases, exec and eval can be valuable. But you must have a very good reason to use them. See [this post][1] for one acceptable use.
For reference see :[this][2]
[1]: https://stackoverflow.com/questions/533382/dynamic-runtime-method-creation-code-generation-in-python
[2]: https://lucumr.pocoo.org/2011/2/1/exec-in-python/
Security aside, `eval` and `exec` are often marked as undesirable because of the complexity they induce. When you see a `eval` call you often don't know what's really going on behind it, because it acts on data that's usually in a variable. This makes code harder to read.
Invoking the full power of the interpreter is a heavy weapon that should be only reserved for very tricky cases. In most cases, however, it's best avoided and simpler tools should be employed.
That said, like all generalizations, be wary of this one. In some cases, exec and eval can be valuable. But you must have a very good reason to use them. See [this post][1] for one acceptable use.
[1]: https://stackoverflow.com/questions/533382/dynamic-runtime-method-creation-code-generation-in-python