HiddenLayer555@lemmy.ml to Programmer Humor@programming.devEnglish · 10 days agoPython needs an actual default functionlemmy.mlimagemessage-square119fedilinkarrow-up1659arrow-down128file-text
arrow-up1631arrow-down1imagePython needs an actual default functionlemmy.mlHiddenLayer555@lemmy.ml to Programmer Humor@programming.devEnglish · 10 days agomessage-square119fedilinkfile-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-up12·edit-210 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.