code: def _python_to_lua(pval):
          
          import lua
          if pval is None:
              # Python None --> Lua None
              return lua.eval("")
          if isinstance(pval, (list, tuple, set)):
              # Python list --> Lua table
              # e.g.: in lrange
              #     in Python returns: [v1, v2, v3]
              #     in Lua returns: {v1, v2, v3}
              lua_list = lua.eval("{}")
              lua_table = lua.eval("table")
              for item in pval:
                  lua_table.insert(lua_list, Script._python_to_lua(item))
              return lua_list
          elif isinstance(pval, dict):
              # Python dict --> Lua dict
              # e.g.: in hgetall
              #     in Python returns: {k1:v1, k2:v2, k3:v3}
              #     in Lua returns: {k1, v1, k2, v2, k3, v3}
              lua_dict = lua.eval("{}")
              lua_table = lua.eval("table")
              for k, v in pval.iteritems():
                  lua_table.insert(lua_dict, Script._python_to_lua(k))
                  lua_table.insert(lua_dict, Script._python_to_lua(v))
              return lua_dict
          elif isinstance(pval, str):
              # Python string --> Lua userdata
              return pval
          elif isinstance(pval, bool):
              # Python bool--> Lua boolean
              return lua.eval(str(pval).lower())
          elif isinstance(pval, (int, long, float)):
              # Python int --> Lua number
              lua_globals = lua.globals()
              return lua_globals.tonumber(str(pval))
  
          raise RuntimeError("Invalid Python type: " + str(type(pval)))
docs: Convert Python object(s) into Lua object(s), as at times Python object(s)
          are not compatible with Lua functions