Do you mean this test?
if __name__ == "__main__":
# faz algo
What this test determines is whether the execution is happening in the main scope , that is, it is the script that was directly executed from the command line (or the graphical menu).
This test is useful when you want the script to be imported with a module (in which case the above test will return False) but can also be run directly. (Because a pure module only defines functions and classes, it normally does nothing even if it runs directly.)
So there is no "right" or "wrong", it may be an interesting practice to encapsulate the code this way so that a script is "modularized" easily, but a script that will always run directly in the foreseeable future does not need this .