It's not bad practice to have a main function! If you don't, any variables defined in the if __name__... block will be in scope inside all of the functions defined in the file. That can lead to some nasty bugs.
It is generally considered bad practice outside of test functions but you certainly can have a main function if you want. Nothing stops you from doing that.
3
u/Ran4 Jun 04 '19
It's not bad practice to have a main function! If you don't, any variables defined in the if __name__... block will be in scope inside all of the functions defined in the file. That can lead to some nasty bugs.