Oct-30-2019, 06:05 PM
(This post was last modified: Oct-30-2019, 06:05 PM by dataplumber.)
I am trying to call the method of the class having no arguments but it is failing.
class ab:
def a():
print("in a")
def b():
print("in b")
if __name__ == '__main__':
b()
ab.a()Error:in b
Traceback (most recent call last):
File "p.py", line 11, in <module>
ab.a()
TypeError: unbound method a() must be called with ab instance as first argument (got nothing instead)I have also tried to modify the code as below but not successfulclass ab:
def a():
print("in a")
def b():
print("in b")
if __name__ == '__main__':
b()
c=ab()
c.a()Error:in b
Traceback (most recent call last):
File "p.py", line 12, in <module>
c.a()
TypeError: a() takes no arguments (1 given)
