- cross-posted to:
- programmerhumor@lemmy.ml
- cross-posted to:
- programmerhumor@lemmy.ml
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?
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?
I call main() in the if
I always use
if "__main__" == main: __main__()…and earlier in the code:
def __main__(): while True: pass main = "__main__"This helps to prevent people from arbitrarily running my code as a library or executable when I don’t went them to.