直接从Python中导入Lua模块
lua-imports的Python项目详细描述
卢阿丘进口
直接从Python中导入Lua模块。在
基本用途
一旦注册了lua_imports.lua_importer
,在Python代码中编写一个引用Lua模块的import
语句。在
示例
foo.lua
return{say_hello=function(person)print("Hello, "..person)end}
bar.py
登记
lua_importer
可以在Python代码中注册:
fromlua_importsimportlua_importerlua_importer.register()
(注意,这必须在任何Lua导入之前出现)
或者,要在环境范围内注册lua_importer
,请在环境的site-packages
文件夹中创建一个lua-imports.pth
文件,其中包含以下内容:
import lua_imports; lua_imports.lua_importer.register()
注意事项
这个模块包装了Lupa,因此对Lua和Python数据类型都有相同的警告。在
- 项目
标签: