How is correct use of eval()

Robert Kern robert.kern at gmail.com
Mon Oct 11 21:07:53 CEST 2010


On 10/11/10 1:11 PM, Cata wrote:
> Hi .
> I read about eval().
> I also read about this "bug" :
> cod = raw_input ('Enter:")
> eval (cod)
> if i use  "rm -rf ~"  all files will be deleted .
>
> What is correct way to use this function?

There are cases when you are writing meta-programming tools for programmers. 
Otherwise, don't use it.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
  that is made terrible by our own mad attempt to interpret it as though it had
  an underlying truth."
   -- Umberto Eco




More information about the Python-list mailing list