Every module in Python has a special attribute called name. The value of name attribute is set to 'main' when the module is executed as the main program (e.g. running python foo.py
). Otherwise, the value of name is set to the name of the module that it was called from.