Skip to content

Instantly share code, notes, and snippets.

@cemerick
Created March 20, 2011 23:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cemerick/de3b8d0ecdccf6655a63 to your computer and use it in GitHub Desktop.
Save cemerick/de3b8d0ecdccf6655a63 to your computer and use it in GitHub Desktop.
# hello-world-level nREPL protocol interaction from python (https://github.com/clojure/tools.nrepl)
# very rusty python 2.6 here, BTW:
>>> c = socket.create_connection(("localhost", 49777));
>>> f = c.makefile('rw')
>>> f.writelines(["2\n", '"id"\n', '"foo"\n', '"code"\n', '"(println 5)"\n'])
>>> f.flush()
>>> for line in f:
... print line
...
3
"ns"
"user"
"out"
"5\n"
"id"
"foo"
3
"ns"
"user"
"id"
"foo"
"value"
"nil\n"
3
"status"
"done"
"ns"
"user"
"id"
"foo"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment