How to do a Lispy-esque read?

Z

zeta.convex

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]
 
B

Benjamin Kaplan

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,069
Latest member
SimplyleanKetoReviews

Latest Threads

Top