tags:

views:

287

answers:

3

Hi, I'm looking into using Lua in a web project. I can't seem to find any way of directly parsing in pure python and running Lua code in Python.

Does anyone know how to do this?

Joe

+2  A: 

See this question: What web server to use for Lua web development.
There's no need to parse Lua in Python.
If you want Python use Python. Same with Lua.
Why mix both languages?

the_drow
I'm looking for a method to parse Lua in Python code.
Joe Simpson
Because I am programming what I know to be safe code. Then I want a limited set of code for developers to be able to send and it will only be able to access certain resources.
Joe Simpson
+1  A: 

There's this project (pylux) which embeds Lua in Python. It seems rather inactive though, but it may be a good project to have a look at.

ChristopheD
I'm looking for a Pure Python implementation
Joe Simpson
Good luck on finding a pure Python Lua parser (never heard of one though).
ChristopheD
Hm... i've decided against using Lua. I'm just going to override the python builtins. This is a good answer though, so I'll mark it
Joe Simpson
@Joe, that doesn't sound like a good plan for making a good, working, maintainable program. Is your hope to sandbox Python? If so, that won't likely work well.
Mike Graham
+1  A: 

From your comments, it appears you a interested in a secure way of executing untrusted code.

Redifining python builtins, as you suggested in a comment, is a horrible way to secure code.

What you want is sandboxing, there are solutions for python, but I wouldn't recommend them. You would be much better of using Jython or IronPython, because the JVM and .NET clr, were designed with sandboxing in mind.

I personally believe that in most cases, if you need to execute untrusted code, then you are putting too much or not enough trust in your users.

mikerobi