5

Is it possible to embed Lua into Python 3.x? If so how could I run and execute Lua scripts within my Python program? How good would the interaction be between the Languages for instance would Lua have access to all of Python's variables and classes and would Python have access to all of Lua's information?

Andrew Stern
  • 688
  • 9
  • 18
  • 4
    Why would you embed Lua in Python, which is a perfectly good scripting language and, of course, fully integrated with itself? –  Dec 24 '10 at 16:44
  • I was looking for a way to embed Lua into python to make a sort of fantasy computer. There are lot's of uses for embedding an interpreter inside of the existing one(Python). – Coolq B Jul 10 '17 at 23:11

2 Answers2

7

Try Lunatic Python, a two-way bridge between Python and Lua.

lhf
  • 70,581
  • 9
  • 108
  • 149
5

In addition to Lunatic Python, there is Lupa, powered by LuaJIT:

http://pypi.python.org/pypi/lupa/0.9

See the link about advantages and reasons to use it.

Alexander Gladysh
  • 39,865
  • 32
  • 103
  • 160
  • 2
    As a side note: I do not agree with the "why use it" section there: it is not futile (or hard) to write large programs in Lua. I know, I have several hundred KLOC of Lua on my hands. The part about batteries is closer to truth though. – Alexander Gladysh Dec 24 '10 at 18:03
  • I both learned programming with Lua and have developed a disdain for it when trying to script a program that embeds it. Now I have to interpret *some* lua but will do my absolute best to touch it as little as possible. – Paul Dec 31 '22 at 13:48