[racket] using Python to pipe data through Racket

From: Eli Barzilay (eli at barzilay.org)
Date: Wed Apr 10 07:35:13 EDT 2013

8 hours ago, Matthew Butterick wrote:
> New Racket user, first list question.
> I'm using scribble/text as a preprocessor language for a system
> mostly written in Python.
> What's the best way to process an arbitrary chunk of scribble/text
> data, using Racket, from within a Python script?
> Right now I'm making a temp file that begins "#lang scribble/text"
> and using os.popen to feed the temp file to racket. Works, but seems
> like the wrong idiom.

I'm not sure what exactly you're trying to do, but instead of using
the file in "text mode" which is what you get with "#lang
scribble/text", you can make it produce the text explicitly with
something like:

     #lang at-exp racket/base
     (require scribble/text)
     (output @list{
       ... same text as before ...

and now you can wrap this to grab the output in a string.  But if your
goal is to just have Racket do the preprocessing, then generating the
temporary code is as good as anything.

          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                    http://barzilay.org/                   Maze is Life!

Posted on the users mailing list.