Reputation: 2594
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
Upvotes: 2
Views: 4384
Reputation: 11
@the_drow
From Lua's web site:
Lua is a fast language engine with small footprint that you can embed easily into your application. Lua has a simple and well documented API that allows strong integration with code written in other languages. It is easy to extend Lua with libraries written in other languages. It is also easy to extend programs written in other languages with Lua. Lua has been used to extend programs written not only in C and C++, but also in Java, C#, Smalltalk, Fortran, Ada, Erlang, and even in other scripting languages, such as Perl and Ruby.
@Joe Simpson
Check out Lunatic Python, it might have what you want. I know it's an old question, but other people might be looking for this answer, as well. It's a good question that deserves a good answer.
Upvotes: 1
Reputation: 20878
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.
Upvotes: 2
Reputation: 116157
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.
Upvotes: 0