How do we share global variables across modules in Python?
Answers
Answered by
0
The way in which global variables can be shared across modules in Python is by creating a special configuration module which is often referred to as config or cfg.
- This can be done by just importing the configuration module in all modules of the application.
- This module will then be a global name.
- Also, there will be only one instance of each module and any changes made to this module object will be reflected everywhere.
Similar questions
English,
5 months ago
Math,
5 months ago
Computer Science,
11 months ago
Computer Science,
11 months ago
Science,
1 year ago