>A Byte of Python

A module's __name__

Every module has a name and statements in a module can find out this name. This is especially handy in one particular situation. As mentioned previously, when a module is imported, the main block in that module is run. What if we want to run the block only if the program was used by itself and not when it was imported as a module? This can be achieved using the __name__ variable.