[racket] using Python from Racket

From: Niitsuma Hirotaka (hirotaka.niitsuma at gmail.com)
Date: Wed Aug 20 22:58:41 EDT 2014

I wrote interface for python

https://github.com/niitsuma/pyjsonrpcembd

example usage

https://github.com/niitsuma/pyjsonrpcembd/blob/master/example/example-racket.rkt
=========
(pyinit)

(pystr "str(3*4)")
(pystrexec "print(3*4)")
(pystrexec "import nltk")
(pystrexec "import numpy")
(pystrexec "print(numpy.array([3,4]))")

(pystr "3*4")

(string->jsexpr
(pyjson "{\"method\": \"min\", \"params\": [[9, 3 , 7]]}")) ;;=> 3
(string->jsexpr
(pyjson "{\"method\": \"range\", \"params\": [2,6]}")) ;; =>'(2 3 4 5)
(string->jsexpr
(pyjson
(jsexpr->string
(make-hash '
((method . "range") ( params . (2 6))))))) ;;=> '(2 3 4 5)
(pystr "_") ;"[2, 3, 4, 5]"

(pystrexec "x=[3,4]")
(string->jsexpr (pystr "x*2"))

Posted on the users mailing list.