lua-users home
lua-l archive

Re: Is there a similar way to do if __name__ == '__main__' as in python ?

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


On Wed, Feb 07, 2007 at 08:35:43PM -0800, gary ng wrote:
> I want to write lua modules and put some self testing
> code at the end of the script which got executed only
> if it is run as its own and not through "require".
> 
> In python, this is usually done through 
> 
> if __name__ = "__main__":
> 
> How should I do it in lua ?
I'm not sure (Rici probably answered that), but for this particular
task, I'd probably do it a little differently:
lua -e 'RunTests = true;' YourScript.lua
and then check RunTests.
-- 
Glenn Maynard

AltStyle によって変換されたページ (->オリジナル) /