convert a string to tuple

Steven Bethard steven.bethard at gmail.com
Tue May 31 16:51:24 EDT 2005


bcannon at gmail.com wrote:
> Pass it to eval:
> 
>>>>eval('(1, 2, 3, 4, 5)')
> (1, 2, 3, 4, 5)

Just be sure you know where your strings come from.  You wouldn't want 
someone to pass you
     """__import__('os').system('rm -rf /')"""
and then send that to eval. =)

STeVe



More information about the Python-list mailing list