On 2016-03-24 11:49, David Palao wrote: >> s = "(1, 2, 3, 4)" >> >> and I want to recover the tuple in a variable t >> >> t = (1, 2, 3, 4) >> >> how would you do ? > > Use "eval": > s = "(1, 2, 3, 4)" > t = eval(s)
Using eval() has security implications. Use ast.literal_eval for safety instead: import ast s = "(1, 2, 3, 4)" t = ast.literal_eval(s) -tkc -- https://mail.python.org/mailman/listinfo/python-list