settings.py makes one object when it is loaded. The module helper.py changes that object. You run main.py.
settings.py:
class Settings:
def __init__(self):
self.theme = "light"
current = Settings()
helper.py:
import settings
def go_dark():
settings.current.theme = "dark"
main.py:
import settings
from settings import current
import helper
helper.go_dark()
settings.current = settings.Settings()
print(current.theme, settings.current.theme)
What does main.py print?Log in to join the discussion.
Loading…