5 ms·
Yup. But sometimes people get excited about all the time saving convenience of 'eval()'.
by truffdog 5y ago
Yup. But sometimes people get excited about all the time saving convenience of 'eval()'.
- Sohcahtoa82 5y ago`eval()` is such a serious code smell. I will admit that I've used it, though. I have an IRC bot written in Python with a "!calc" command that calls eval(). But I use `ast` to build the syntax tree, then walk it and compare every AST object to a white list so you can only use numbers and math operators. Anything else, such as CALLs or strings will throw an error.