The Python __name__ Variable
The Python __name__ variable is a special built-in variable that holds the name of the current imported module. When accessed within a Python script file that's executed directly (i.e. not a module), its value is the string "__main__". __name__ is most often used to differentiate between Python code that is run in a standalone script or code that's imported as a module.