Search code examples
pythonclojurestringio

Python's StringIO for Clojure


Is there something equivalent to Python's StingIO for Clojure?

I'm trying to write a report generating/literate programming system similar to Sweave and Pweave for Clojure. I'm currently using a temp file, but I'd prefer using something similar to StringIO.


Solution

  • with-out-str is pretty handy.

    (let [foo (with-out-str (println "Hello world!"))] 
       foo)
    

    More documentation here