Transforming a str to an operator

Anny Mous b1540457 at tyldd.com
Fri Aug 28 21:43:23 EDT 2009


r wrote:

> Abviously the OP is a python baby noob and casting your irrational
> fear (and many others irrational fears) of eval 

It isn't irrational to have a healthy caution towards eval.

Apart from the security issues, running code in eval takes a massive
performance hit. Its about ten times slower to run eval("x+1") than to run
x+1 directly.



> at him is akin to 
> tales of Chupacabras running a muck in the jungle sucking the blood
> from live goats in the twilight hours. I use eval all the time and
> quite love it.

LOL I'm not surprised.


> This is nothing more than a throw away academic exercise that will
> serve no useful purpose for him in the future, 

What makes you think that learning to program well in Python is a throw-away
exercise of no useful purpose? I'm sure the code itself will be thrown away
and forgotten, but it has a very important purpose: for the OP to learn
good programming skills. Looks like you want him to learn bad skills, then
spend the rest of his life trying to unlearn them.


> but serves the very 
> useful purpose now of establishing an IO between the student and
> Python interpretor. I'll bet most your example (albeit a good example)
> flew miles above his head into la-la land.

How insulting. Is there anything that gave you the impression the OP was
stupid?


> The OP has plenty of time to learn about malicious input and
> protecting against it, right now the fundamentals are well...
> fundamental :)

When would you recommend he learns? When his web app is hijacked by
gangsters in Russia and the personal details and financial records of fifty
thousand people stolen? Protecting against malicious input *IS*
fundamental.






More information about the Python-list mailing list