- 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?
You must log in or register to comment.
What kind of psychopath would put the code in the if block.
Looks at all the Python scripts in my bin folder that I wrote.
Never heard of
def main(): pass if __name__ == '__main__': main()
?
I remember how weird this looked the first time I saw it and while I may now understand it, it still looks jank af
Now think about this, you have logic that doesn’t make sense when run directly, but you need it to be a library.
You have multiple name=main statements in some of your functions