Print all local variables accessible to the current scope in Lua

Posted by Edu Felipe on Stack Overflow See other posts from Stack Overflow or by Edu Felipe
Published on 2010-05-14T13:46:37Z Indexed on 2010/05/14 14:04 UTC
Read the original article Hit count: 181

Filed under:
|

I know how to print "all" global variables using the following code

for k,v in pairs(_G) do
    print("Global key", k, "value", v)
end

So my question is how to do that for all variables that are accessible from the currently executing function, something that can do what locals() does for Python.

© Stack Overflow or respective owner

Related posts about lua

Related posts about introspection