

Class variable reset to default values when I try to access them
I was making an application in Python 3.9 and I made a class Config
in that class I had some varibles like threads
, but, I did this in my __init__()
function in another class Main()
: Config.threads = 100
, but when I try to access it from another file like this:
import main
from main import *
import threading
from threading import Thread
threading.Thread(target=func).start()
def func():
print(Config.threads)
__init__()
is called at the end of my main.py
file to start the program. Like this:
Main()
It simply prints 0, which is the default value assigned to Config.threads
. What am I doing wrong here?
Python


Please paste all the code that you have written here, you will need to instantiate the other class so that it runs __init__ and re-assigns values
Login to add comment