lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On 4 May 2012 13:28, Daniel Silverstone <dsilvers@digital-scurf.org> wrote:
> On Fri, May 04, 2012 at 12:20:56PM +0100, Emeka wrote:
>> There is this popular language which allows one to easily  list out all the
>> functions in a library.
>> Say I have this:
>> import os
>> dir(os) Will list the functions and others.
>> How can I do the same with Lua?
>
> lua -e'table.foreach(require "os", print)'
>
> Not as pretty, but it'll work.

If you have Microlight [1], you can do this:

lua -e 'print(require"ml".tstring(require"os"))'

You can achieve similar results using methods listed in [2].

[1] https://github.com/stevedonovan/Microlight
[2] http://lua-users.org/wiki/TableSerialization