How to do a Lispy-esque read?

Benjamin Kaplan benjamin.kaplan at case.edu
Mon Apr 8 04:32:55 EDT 2013


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.convex at 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



More information about the Python-list mailing list