[Tutor] Importing file data into Python arrays

alan.gauld@bt.com alan.gauld@bt.com
Tue, 28 May 2002 17:17:39 +0100


> So many of these anti-eval() arguments boil down to
> reasoning like:  one shouldn't be allowed to use knives,
> because one might cut one's own wrists (or throat)
> with them.

No, its more like you shouldn't keep guns lying around 
coz somebody else might get their hands on it and shoot 
you...

Consider the case where somebody presents a file 
containing something like "open('autoexec.bat','w')"

The eval() will duly evaluate that to a file object and in 
the process wipe autoexec.bat (or any other system file 
you care to name!).

> That argument only makes sense if you presume a
> self-destructive programmer (or a completely inept
> one), in which case there a many more direct ways
> to wreak havoc.

Its not usually the programmer we worry about but the end 
users of our programs.

Alan g