PLEASE NOTE: this is NOT about using eval (), it's about the potential quality (or lack thereof) of the book in which it is used and what it was taught. SO already has countless threads about eval () in Python.
At the risk of inviting anger and downvotes SO, I nonetheless decided to ask this question, just in case. Please carry me. I tried Google and SO myself on this particular issue (as you will see) and received nothing. I could be blind.
This question is about using the notorious eval () function.
There is a relatively well-known (and well-revised, as you can see) John Celle book: http://www.amazon.com/Python-Programming- Introduction-Computer-Science / dp / 1590282418 / ref = pd_sim_b_3
Technically, this is a CS1 book that uses Python as a programming language. Fairly enough, it takes some responsibility on the shoulders of the author ("Hey, I'm trying to teach you something broad here, not all of these syntaxes and security details"), but when I started reading, I noticed, literally in the very first example use
x = eval(input("Enter your number: "))
where x must be int and therefore we need to convert user input to int.
I use Python 2.7.4 and the book is about Python 3, so from the very beginning I ran into pretty big problems with print () and input () and eval (), and I had to do some research to bring the examples to work. In the course of my research, I read countless opinions about eval () in Python (mainly here on SO), which boil down to the fact that this is almost always bad, security risk, unnecessary technical overhead, and so on. User questions were much more complicated (there was one about using eval () when running a wxPython project), so I cannot vouch for the general similarity between my case and their cases, but still ...
So, I admit that I'm not too far from the book, but I got to the point that after a while the author explained the use of eval () without reference to its controversial nature. He basically said what I just said: we need x, in the end, to be int, so here is a convenient way to do this. And he seems to use it ever.
My question is this: if, from the very beginning, the author makes such a mistake (or is it NOT a mistake? Maybe I missed something here), is it worth studying the book? I believe that Mr. Zell is a great CS teacher, and he shows whether he wants to or not, people will still learn Python from his book, in addition to algorithms and the art of programming. So is it worth learning Python from a book that was silent about such a seemingly universal problem in the Python community? I don’t want Mr. Zell to be a Python hacker and reveal all his secrets, but small details like these can make or break someone who is self-educated / self-taught. What will be your advice regarding this training material?
PS On the other hand, forcing me to do quite a bit of research and experimentation (involuntarily) from the very beginning, it's pretty cool :-)
Thanks!