In what scenario is the __name__ attribute of a module set to its own module name instead of "__main__"?

  • When the module is a built-in module
  • When the module is defined in Python 2.x
  • When the module is imported as a library
  • When the module is the main program
The __name__ attribute of a module is set to its own module name when it's imported as a library by another module. It's set to "__main__" when the module is the main program being executed.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *