Here's what I made to test how python works....
test.py:
class ECollector:
#error msg collector
#this class should be used as 'global'
msgs = []
def addmsg(self,msg):
self.msgs.append(msg)
def clear(self):
self.msgs = []
class test(ECollector):
dcodes = []
ECollector
def new(self):
ECollector.addmsg("test!")
And I typed the following on the Python console
(I'm working on Python 3.12 with Pyscripter 2.3)
>>>a = test()
>>>a.new()
and the following is what I got:
Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
File "C:\...\test.py", line 14, in new
ECollector.addmsg("test!")
TypeError: addmsg() takes exactly 2 positional arguments (1 given)
What I don't get is this: why is Python requiring 2 arguments?
I thought this 'self' argument was 'automatically-filled' kind of argument...
(in other words, I thought it's unnecessary to fill the 'self' argument...)
Also, I tried to fill in the self argument like this:
class test(ECollector):
dcodes = []
ECollector
def new(self):
ECollector.addmsg(ECollector"test!")
This doesn't work either :(
I'm confused about this 'phenomenon' T.T
Anyway, please 'redeem' this bewildered newbie giving him some answers :)