0

I was looking for ways to make python read lua scripts and execute functions, like this:

function foo()
*call python "test" def*
end
function bar()
print('honk')
end

on python:

def test():
    print('tonk')
    *call lua function "bar"

is there a way to make this?

2 Answers 2

3

There is a package called lupa. It seems like it does exactly what you want (taken from their example):

>>> import lupa
>>> from lupa import LuaRuntime
>>> lua = LuaRuntime(unpack_returned_tuples=True)

>>> lua.eval('1+1')
2

>>> lua_func = lua.eval('function(f, n) return f(n) end')

>>> def py_add1(n): return n+1
>>> lua_func(py_add1, 2)
3

>>> lua.eval('python.eval(" 2 ** 2 ")') == 4
True
>>> lua.eval('python.builtins.str(4)') == '4'
True
Sign up to request clarification or add additional context in comments.

Comments

1

You can do it using lunatic library which can called from either side. https://labix.org/lunatic-python

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.