Js2Py icon indicating copy to clipboard operation
Js2Py copied to clipboard

Saving evaljs output to variable instead of printing it out

Open samul-1 opened this issue 5 years ago • 0 comments

Hello, I just found out about this library and I'm loving it.

I'm working on a didactic website which presents users with javascript problems, prompts for a solution (a user-written program), then runs the program against a number of inputs, and checks if the outputs match the expected ones.

I see that the eval_js function prints out the output from the program it is passed. What I'd like to do is save that output somewhere instead, so I can compare it with the expected one directly or run it through a function in case it's something more complex like an object. I can save the return value of eval_js to a variable, but I'm looking for a way to also save what's printed to stdout during execution of the script.

I realize there's a function to convert js scripts to python files, so I can see a workaround, but I'm pretty sure there's a simpler way to go about this, which I'm currently missing.

Any inputs are highly appreciated.

samul-1 avatar Dec 09 '20 09:12 samul-1