Table of Contents

if __name__ main

General Information

Many python source files will have an interesting if statement around main(). This is why it exists.

Checklist


The Code

if __name__ == '__main__':
  main()

Explanation

It may include other statements as well.

This special if statement is checked by the python interpreter itself when it reads the source file.

The entire reason behind this is: