最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How does Udacity web Python interpreter work? - Stack Overflow

programmeradmin2浏览0评论

Udacity gives students a web editor to enter Python programs. The editor recognizes Python keywords and built-in functions and allows to run a program. Do you know how this technology works? Are programs submitted to a backend and executed by the standard Python interpreter or is it a JavaScript based Python interpreter? Does the editor simply hold a static list of Python keywords and built-in functions or does it interact with the standard or JavaScript based Python to obtain these?

Udacity gives students a web editor to enter Python programs. The editor recognizes Python keywords and built-in functions and allows to run a program. Do you know how this technology works? Are programs submitted to a backend and executed by the standard Python interpreter or is it a JavaScript based Python interpreter? Does the editor simply hold a static list of Python keywords and built-in functions or does it interact with the standard or JavaScript based Python to obtain these?

Share Improve this question asked Sep 14, 2012 at 15:16 Jan WrobelJan Wrobel 7,0993 gold badges42 silver badges57 bronze badges 1
  • That thing is the beezneez. – Evan Plaice Commented Feb 8, 2013 at 18:24
Add a comment  | 

3 Answers 3

Reset to default 13

While javascript python interpreters do exist: http://syntensity.com/static/python.html , they don't appear to be using one. It would be far too easy to cheat if they didn't at least run the programs once for verification on their own interpreter.

After looking at the network activity on Udacity I can see that they make an ajax call with a bunch of data and then get the results of the program run back in JSON.

At a guess they have the standard python interpreter running in a sandbox that will execute the assignments, then the results are packed into JSON, returned to the client and updated to the screen. At the same time the results of your submission will be recorded as part of your class results.

Very late to the party here, but I work as an engineer at Udacity, so I figured I'd give it a shot.

There are two fundamental things going on:

  1. The current syntax highlighting and editing is provided by a Codemirror implementation, although we have used several different editors in the past couple years.
  2. When you hit submit (or run), your code is packaged up and shipped off to a sandboxed cluster we run for execution. If you're hitting submit, this is where we run our own tests against your code and "grade" it to see if it passes. The output from that (in various forms) is piped back to the front end, and you get your feedback.

Not quite as fast as running it locally, but it sure beats supporting a few hundred thousand people trying to install Python for the first time ;)

I haven't tried Udacity, but for the syntax highlighting parts, it can be easily done with a simple backend code, which is updated using some Ajax. One of the easiest ways can be used as lexical analyzing as in compilers or interpreters ..

发布评论

评论列表(0)

  1. 暂无评论