2

I am making a Github Pages site (static only, no server side code, JavaScript/JQuery is OK) on learning Python 3 code. I would like a way to:

  • Evaluate the Python 3 code the user gives in an <input> or something similar.
  • Print output, including error messages, to a <pre><code> or something similar.
  • Assign output, including error messages, to a JavaScript variable or something similar in order to use it in a validation function (written in JavaScript/jQuery).
  • Is portable enough to use on a Github Pages static web site.

Is there a library/software that can accomplish this?

1

Skulpt is a Python interpretor in JavaScript:

Skulpt is an entirely in-browser implementation of Python.
No preprocessing, plugins, or server-side support required [...].

It is for Python 2, but apparently it already mostly work with Python 3, if I understand correctly most Python 3 unit tests are passing. I have not tested though.

Demos are available on their website, it is rather impressive.

Skulpt seems to load faster than the similar project PyPy.js, and has more Github stars.

Apparently some online Python programming courses like Coursera use it, and so does Trinket.io:

enter image description here

  • I'll check it out when I get home today. Thank you so much! – OldBunny2800 Sep 1 '17 at 17:21
  • Does this work with Python 3? On Github, it says Python 2.x. – OldBunny2800 Sep 2 '17 at 15:39
  • @OldBunny2800: Added some info. – Nicolas Raoul Sep 3 '17 at 6:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.