On Wed, Feb 10, 2010 at 6:26 AM, Owain Clarke <simb...@cooptel.net> wrote: > Please excuse the obviousness of my question (if it is), but I have searched > the documentation for how to generate a list e.g. [(1,2), (3,4)] from a > string "[(1,2), (3,4)]". I wonder if someone could point me in the right > direction.
Python 2.6 and later contain the function ast.literal_eval() which is the safe way to do this. http://docs.python.org/library/ast.html#ast.literal_eval In [15]: import ast In [16]: ast.literal_eval("[(1,2), (3,4)]") Out[16]: [(1, 2), (3, 4)] Kent _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor