- 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?
This is exactly why the conditional is used. It allows the script to function both as a standalone application and a library.
ETA: Probably would make sense to just treat it as default behavior in the interpreter and only require the conditional to overwrite in cases where
main
is not the main function and/or pre-processing is needed.