- cross-posted to:
- programmer_humor@programming.dev
- programmerhumor@lemmy.ml
- cross-posted to:
- programmer_humor@programming.dev
- 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?
I usually put some print statements and stuff in the if block.
The syntax is kind of weird and I have to regularly look it up, but it’s nice in a way because it makes it more obvious that this code isn’t going to run if you are importing the file rather than running it directly. Which implies a nice way to write something like a util.py, where there is no main function and what’s in the if block is for testing everything, not actually running the application.