how to iterate over sequence and non-sequence ?

Duncan Booth duncan.booth at invalid.invalid
Fri Oct 19 08:34:12 EDT 2007


Nils <nils.lastein at gmail.com> wrote:

> why not:
>>>> for i in eval('(1,2,3)'):
> ...     print i
> 1
> 2
> 3
> 

For the exact same reason Steven already gave you: one day someone will 
give you bad data.

For eval you need to use slightly more complicated expressions. e.g. 
"__import__('os').system('rm # -rf /')"
will be sufficient to mess you up.




More information about the Python-list mailing list