There is no "read in a stream until it's a valid literal" function as far as I know, but ast.literal_eval will turn your string into an object.
On Mon, Apr 8, 2013 at 12:45 AM, <zeta.con...@gmail.com> wrote: > Suppose I want to read an object from some stream. How do I do it? > > For example, if the input stream contained the text: > [1, # python should ignore this comment > 2] > > and I do a "read" on it, I should obtain the result > [1, 2] > -- > http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list