I have a function which returns an object of class Person, defined as:
class Person:
def __init__(self):
self.id=None
self.age=0
self.name=None
def setValues(self,id,age,name):
self.id=id_
self.age=age_
self.name=name_
And here is a function which returns such an object:
def getTeacher():
pr = Person()
pr.setValues(11,"John",30)
return pr
Now, I want to assign the object returned by this function to another object in main:
teacher=getTeacher()
But it turns out teacher is a null object. Please help
getTeacher()requires two parameters. You call it with no parameters. That must have caused a runtime error. If you did not have an error, then the code that you show is not the code that you executed. Please kindly update your question.