interpreter

How to embed a Python interpreter on a website

别等时光非礼了梦想. 提交于 2019-11-30 10:52:05
问题 I am attempting to build an educational coding site, similar to Codecademy, but I am frankly at a loss as to what steps should be taken. Could I be pointed in the right direction in including even a simple python interpreter in a webapp? 回答1: One option might be to use PyPy to create a sandboxed python. It would limit the external operations someone could do. Once you have that set up, your website would take the code source, send it over ajax to your webserver, and the server would run the

Is there Dart VM available?

这一生的挚爱 提交于 2019-11-30 08:22:48
Just read news that Google had announced an early preview of the new web programming language Dart. The documentation on the dartlang.org states: You will be able to run Dart code in several ways: Translate Dart code to JavaScript that can run in any modern browser: Chrome, Safari 5+, and Firefox 4+ (more browser support coming shortly). Execute Dart code directly in a VM on the server side Use Dartboard to write, modify, and execute small Dart programs within any browser window And I'm curious is there already VM available to run Dart code? Can't find it anyway, maybe it is available through

How do I read the output of the IPython %prun (profiler) command?

旧巷老猫 提交于 2019-11-30 07:56:18
I run this: In [303]: %prun my_function() 384707 function calls (378009 primitive calls) in 83.116 CPU seconds Ordered by: internal time ncalls tottime percall cumtime percall filename:lineno(function) 37706 41.693 0.001 41.693 0.001 {max} 20039 36.000 0.002 36.000 0.002 {min} 18835 1.848 0.000 2.208 0.000 helper.py:119(fftfreq) --snip-- What do each of tottime, percall, cumtime? ncalls is fairly obviously (number of times the function is called). My guess is that tottime is the total time spent in the function excluding time spent within its own function calls; percall is ???; cumtime is

Does it make sense to use Hungarian notation prefixes in interpreted languages? [closed]

Deadly 提交于 2019-11-30 07:07:11
First of all, I have taken a look at the following posts to avoid duplicate question. https://stackoverflow.com/questions/1184717/hungarian-notation Why shouldn't I use "Hungarian Notation"? Are variable prefixes (“Hungarian notation”) really necessary anymore? Do people use the Hungarian Naming Conventions in the real world? Now, all of these posts are related to C#, C++, Java - strongly typed languages. I do understand that there is no need for the prefixes when the type is known before compilation. Nevertheless, my question is: Is it worthwhile to use the prefixes in interpreter based

In what Javascript engines does Function.prototype.toString not return the source code of that function?

混江龙づ霸主 提交于 2019-11-30 06:47:10
EDIT: To be explicit, I am not looking for advice or opinions on the qualitative merit of the various issues implied by the functionality in question — neither am I looking for a reliable solution to a practical problem; I am simply looking for technical, verifiable answers to the question in the title. I have appended the question with a list of non-conforming browsers. Using a function's .toString method will typically render the source code for that function . The problem is that this behaviour isn't specified — the spec refrains from making any commitment as to what the behaviour should be

Why is string comparison so fast in python?

家住魔仙堡 提交于 2019-11-30 06:06:14
I became curious to understand the internals of how string comparison works in python when I was solving the following example algorithm problem: Given two strings, return the length of the longest common prefix Solution 1: charByChar My intuition told me that the optimal solution would be to start with one cursor at the beginning of both words and iterate forward until the prefixes no longer match. Something like def charByChar(smaller, bigger): assert len(smaller) <= len(bigger) for p in range(len(smaller)): if smaller[p] != bigger[p]: return p return len(smaller) To simplify the code, the

OK Programming language from USB stick with no installation

守給你的承諾、 提交于 2019-11-30 05:14:28
I'm looking for a compiler or interpreter for a language with basic math support and File IO which can be executed directly from a memorystick in either Linux or Windows. Built in functionality for basic datastructures and sorting/searching would be a plus. (I've read about movable python, but it only supports windows) Thank you Not sure what are the issues there for the other languages, but I am pretty sure that Lua will work fine on such environment. It is perfect for your requirements: basic I/O, math functions, excellent data structures (all based on numeric and associative array, with any

Python local variable compile principle

烈酒焚心 提交于 2019-11-30 04:32:22
问题 def fun(): if False: x=3 print(locals()) print(x) fun() output and error message: {} --------------------------------------------------------------------------- UnboundLocalError Traceback (most recent call last) <ipython-input-57-d9deb3063ae1> in <module>() 4 print(locals()) 5 print(x) ----> 6 fun() <ipython-input-57-d9deb3063ae1> in fun() 3 x=3 4 print(locals()) ----> 5 print(x) 6 fun() UnboundLocalError: local variable 'x' referenced before assignment I am wondering how the python

web based interpreter for language R [closed]

独自空忆成欢 提交于 2019-11-30 04:02:17
I am looking for a web based interpreter for the language R. To be more precise , i am looking for a IDE like http://codepad.org/ where i can provide the code and the server should execute and provide me with the output. I went through applications like Rapache but then they don't fit my requirement as they are not made to accept code from client , execute it and provide the result. In short , i could find web application which takes input from the user , execute a specific R script and then place the output in a neatly formated way but not a web application which accepts R code ,execute it

“Strictly positive” in Agda

自作多情 提交于 2019-11-30 03:18:31
I'm trying to encode some denotational semantics into Agda based on a program I wrote in Haskell. data Value = FunVal (Value -> Value) | PriVal Int | ConVal Id [Value] | Error String In Agda, the direct translation would be; data Value : Set where FunVal : (Value -> Value) -> Value PriVal : ℕ -> Value ConVal : String -> List Value -> Value Error : String -> Value but I get an error relating to the FunVal because; Value is not strictly positive, because it occurs to the left of an arrow in the type of the constructor FunVal in the definition of Value. What does this mean? Can I encode this in