Converting a string of tuples to a list of tuples in Python
Question: How can I convert `"[(5, 2), (1,3), (4,5)]"` into a list of tuples `[(5, 2),
(1,3), (4,5)]`

I am using `planetlab` shell that does not support `"import ast"`. So I am
unable to use it.


Answer: If
[`ast.literal_eval`](http://docs.python.org/library/ast.html#ast.literal_eval)
is unavailable, you can use the (unsafe!)
[`eval`](http://docs.python.org/library/functions.html#eval):

    
    
    >>> s = "[(5, 2), (1,3), (4,5)]"
    >>> eval(s)
    [(5, 2), (1, 3), (4, 5)]
    

However, you should really overthink your serialization format. If you're
transferring data between Python applications and need the distinction between
tuples and lists, use [pickle](http://docs.python.org/library/pickle.html).
Otherwise, use [**JSON**](http://docs.python.org/library/json.html).

