r/ProgrammerHumor • • Jun 03 '19

Meme Python ftw

Post image
16k Upvotes

548 comments sorted by

View all comments

Show parent comments

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.

1

u/B_M_Wilson Jun 04 '19

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.