Jul-03-2019, 12:23 PM
Hello,
i have been playing around with the following piece of code that i found in an online course of Python.
The class has 2 methods, one method is calling the other.
I can make it work if i use the class name in the zoo().
Currently as it is, it can execute without any errors.
If i remove the comments is providing me the following errors,according to the line in use, can someone explain me why please?
i have been playing around with the following piece of code that i found in an online course of Python.
The class has 2 methods, one method is calling the other.
I can make it work if i use the class name in the zoo().
Currently as it is, it can execute without any errors.
If i remove the comments is providing me the following errors,according to the line in use, can someone explain me why please?
class TestClass: def foo(left,stop): pass def zoo(left): foo(left,True) foo(left,False) obj1=TestClass() obj1.foo('left') #obj1.zoo('left') #TypeError: zoo() takes 1 positional argument but 2 were given #obj1.zoo() #NameError: name 'foo' is not definedThank you