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.
Loading...
Related Quiz
- Which of the following concepts allows a single interface to represent different methods in derived classes?
- To define a generator, you use the ____ keyword in the function definition.
- In algorithm analysis, ____ denotes the upper bound of the running time of an algorithm.
- You are designing a RESTful API for an e-commerce platform. How would you structure the API endpoints to handle CRUD operations for products?
- You are tasked with the development of a library where the user’s classes need to be altered after their definition, for additional functionality. How can metaclasses be employed to modify or augment the user-defined classes?