mwm at mired.org
Sat Dec 10 00:10:53 CET 2005
Trent Mick <trentm at ActiveState.com> writes:
> [skip at pobox.com wrote]
>> Trent> Nah, the Try Ruby thing is mostly faking it (I believe) rather
>> Trent> than running an actually Ruby interactive session ("bastion'ed"
>> Trent> or not).
>> I don't think so. I tried typing some stuff at the prompt that it wasn't
>> asking for, like "x = [1,2,3]" followed by "x * 5" when it was asking me to
>> type "2 + 6". It evaluated both properly as far as I could tell.
> Yah. My guess at what he is doing (and the way I'd probably do this for
> Python) is to compile each statement, only allow certain constructs
> (like assigning to a variable, defining literals, basic operator usage,
> maybe some control flow statements -- although I didn't get that far)
> and then execute those.
I'm working on puttingn this up for Python. I'm planning on using AJAX
to pass the input string to eval on the server. I.e. - you'll be
limited to expressions, which is what it seems like the Ruby thing is
On the other hand, with iterators, generators and list comprehensions,
you can do quite a lot with eval.
If anyone else is contemplating putting up something like this, let me
know so we can avoijd duplicating the effort.
Mike Meyer <mwm at mired.org> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
More information about the Python-list