As a part of my school CS class, I am reading Python Programming by John Zelle.  In the book, Zelle talks about surrounding the invocation of a main method with if <condition>:    main()where the condition is something like __name__ == '__main__'.  My computer science teacher said that the necessity of this loop depends on if the program is importable and run-directly.  I know that because there are 2 variables, there can only be four combinations of importable and    run-directly.I know from the book and my CS teacher that If a program is importable and is run directly, then main must be conditional.However, I do not know the cases, which is what I am trying to figure out:If not importable and not run-directlyIf importable and not run-directly If not importable and run-directlyI think, but am not sure, that these are the correct answers.If not importable and not run-directly, then it must be in a conditionalIf importable and not run-directly, then it doesn't have to be in a conditional.If not importable and run-directly, then it doesn't have to be in a conditional.Are the statements above correct? is what I am trying to figure out.I have tried finding this information in the book, but is unfortunately unavailable.
Enclosing main invocation of a function in an if
design patterns;python
You're very close, but are missing one aspect. If a program is importable and is run directly, then main must be conditional.If not importable and not run-directly, then main is irrelevant. Actually, the entire contents of the file are irrelevant. If importable and not run-directly, then main should not exist. If not importable and run-directly, then main does not have to be in a conditional. It's still a good idea, as it'll help avoid accidentally omitting it were needed, and it causes no harm. 