You are working on a Python project with several modules, and you need to make some global configurations accessible across all modules. How would you achieve this?
- a) Use global variables
- b) Use the configparser module
- c) Use function arguments
- d) Use environment variables
To make global configurations accessible across multiple modules, it's a good practice to use the configparser module. It allows you to store configuration settings in a separate configuration file and read them from different modules. This promotes modularity and maintainability.
Loading...
Related Quiz
- How can you parameterize a test function in pytest to run it multiple times with different arguments?
- The counterpart to the @property decorator for setting the value of an attribute is _______.
- You want to create a logging utility that can be used across various modules in your project without repeatedly initializing the logger. Which Python feature can help in achieving this?
- Imagine you are developing a game and you have a Player class. Every player has a unique ID and a score. Which method would be best suited to fetch the highest score across all players without needing an instance of the player class?
- Which statement is used to create an infinite loop in Python intentionally?