lua-users home
lua-l archive

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



in lua module
if _NAME == nil then
    test()
end
equals
if __name__ == “__main__”: 

like this:

Lua 5.1.4  Copyright (C) 1994-2008 Lua.org, PUC-Rio
> require('md5')
> print(md5._NAME)
md5
>

At 2014-09-21 10:45:32, "Ashish Ranjan" <ashishwave@yahoo.com> wrote:
FEATURE REQUEST: In python , we have a construct 
        if __name__ == “__main__”:  
so that if a module .lua file is executed by itself then this code block executes, but if this module is imported(required() as in lua) by other script file, then this code blosk is not executed. 
Can we have this construct in lua. This will be an important step in life of a lua module.

Kindly see for better explanation http://stackoverflow.com/a/20158605


Ashish Ranjan
ashishwave@yahoo.com