Re: convert a string to tuple



querypk@xxxxxxxxx wrote:
b is a string b = '(1,2,3,4)' to b = (1,2,3,4)

py> tuple(int(s) for s in '(1,2,3,4)'[1:-1].split(',')) (1, 2, 3, 4)

Or if you're feeling daring:

py> eval('(1,2,3,4)', dict(__builtins__=None))
(1, 2, 3, 4)

Python makes no guarantees about the security of this second one though.

STeVe
.