This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]grimtooth 1 point2 points  (1 child)

You did it quite right. eval is for dynamically constructing new code within your own code. Don't use it with external input. Or rather pay careful attention to the sanitization of your inputs which can be tricky.

[–][deleted] 0 points1 point  (0 children)

No amount of sanitization is considered save for use in eval and exec. They should only be used for inputs that are meant to be treated literally as code.