Created
April 22, 2014 15:33
-
-
Save zeffii/11183806 to your computer and use it in GitHub Desktop.
coffeescript function calling from Python. dirty, but interesting.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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