LunaticPython - Lua + Python!

Started by
2 comments, last by GameDev.net 19 years, 3 months ago
Why argue over which one to use, when you can use both? ;) http://moin.conectiva.com.br/LunaticPython
"2. Introduction Lunatic Python is a two-way bridge between Python and Lua, allowing these languages to intercommunicate. Being two-way means that it allows Lua inside Python, Python inside Lua, Lua inside Python inside Lua, Python inside Lua inside Python, and so on. 3. Why? Right now this is an experiment. Let me know if you find some real usage for it."
Example from that page:

>>> import lua
>>> lg = lua.globals()
>>> lg.string
<Lua table at 0x81c6a10>
>>> lg.string.lower
<Lua function at 0x81c6b30>
>>> lg.string.lower("Hello world!")
'hello world!'

>>> d = {}
>>> lg.d = d
>>> lua.execute("d['key'] = 'value'")
>>> d
{'key': 'value'}

>>> d2 = lua.eval("d")
>>> d is d2
True

>>> lua.eval("python")
<Lua table at 0x81c7540>

>>> class MyClass: pass
... 
>>> obj = MyClass()
>>> obj
<__main__.MyClass instance at 0x403ccb4c>
>>> lua.eval(r"python.eval('lua.eval(\"python.eval(\'obj\')\")')")
<__main__.MyClass instance at 0x403ccb4c>


I think that last line alone should be enough. ;)
Advertisement
Sweet.
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
Well, I always did want to see what a Lua style coroutine in Python would be like.
I may not have to hate Blender3D with a fiery passion from now on!

This topic is closed to new replies.

Advertisement