I have a class, call it Test, which has a variable var. It uses this variable in its __init__ mathod, and maybe looks something like this:
class Test(object):
var = 0
def __init__(self):
print(self.var)
In order to change this variable before I initialise the class, this seemed logical
test = Test
test.var = 42
test.__init__(test)
...and behaves like I expected it to. (printing 42)
However, when the code looks like this:
class Test(Canvas):
var = 0
def __init__(self, parent):
Canvas.__init__(self, parent)
self.pack()
print(self.var)
test = Test
test.var = 42
test.__init__(test, frame) #tkinter frame I had made elsewhere
... it throws an error at the canvas.__init__ line, complaining that
TypeError: _options() missing 1 required positional argument: 'cnf'
I doubt this is a problem with the cnf parameters, as the class works fine when called 'normally', as in test = Test(). I have a feeling the parameters are being passed differently.
Can someone shed some light?
Thanks in advance
test = Testdoes? It's not clear what you are trying to accomplish. Why are you calling__int__? That is highly unusual.Test()ortest(). And when you create the instance,__init__()is called automatically, so you don't need that anyway.test = Test? Because nothing is printed there (else it would have printed0, not42), so I assumed__init__wasn't being called...