I have a class, call it
Test, which has a variable
var. It uses this variable in its
__init__ mathod, and maybe look 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.
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().
Can someone shed some light?
Thanks in advance