Skip to content

Instantly share code, notes, and snippets.

@zeffii
Created April 22, 2014 15:33
Show Gist options
  • Save zeffii/11183806 to your computer and use it in GitHub Desktop.
Save zeffii/11183806 to your computer and use it in GitHub Desktop.
coffeescript function calling from Python. dirty, but interesting.
# coffeescript_from_python.py
import os, sys
import ast
# coffee <yourcoffeescriptfile>.coffee
file_location = "C:/Users/dealga/Desktop/code/conjurer.coffee"
a = " ".join(['coffee', file_location])
b = os.popen(a,'r',1)
def closure_eval(stream_in):
exec(stream_in.read())
g = vars()
del g['stream_in']
return g
f = closure_eval(b)
print(f)
k = [0..40]
g = [20..50]
out_object = {out1: k, out2: g}
for i of out_object
if out_object.hasOwnProperty(i)
console.log i + ' = [' + out_object[i] + ']'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment