HiddenLayer555@lemmy.ml to Programmer Humor@programming.devEnglish · 8 days agoPython needs an actual default functionlemmy.mlimagemessage-square160fedilinkarrow-up1749arrow-down129file-text
arrow-up1720arrow-down1imagePython needs an actual default functionlemmy.mlHiddenLayer555@lemmy.ml to Programmer Humor@programming.devEnglish · 8 days agomessage-square160fedilinkfile-text
Also, do y’all call main() in the if block or do you just put the code you want to run in the if block?
minus-squareDie Martin Die@sh.itjust.workslinkfedilinkarrow-up14·edit-28 days agoif debug.getinfo(1).what == "main" then -- ... end Not that you’ll ever use it. No, seriously. Edit: actually, they are not quite equivalent. This code just checks whether we are outside any function, not necessarily in the main file (i.e. not in a module). I don’t think there’s an equivalent to Python’s __name__ in stock Lua.
if debug.getinfo(1).what == "main" then -- ... end
Not that you’ll ever use it. No, seriously.
Edit: actually, they are not quite equivalent. This code just checks whether we are outside any function, not necessarily in the main file (i.e. not in a module). I don’t think there’s an equivalent to Python’s
__name__
in stock Lua.