如果我想输出实例的名字,应该怎么做,这里为什么会产生迭代错误
class Person(object):
def __init__(self, name, gender):
self.name = name
self.gender = gender
class Student(Person):
def __init__(self, name, gender, score):
super(Student, self).__init__(name, gender)
self.score = score
def __str__(self):
return '(%s:%s,%s,%s)'%(self,self.name,self.gender,self.score)
__repr__=__str__
s = Student('Bob', 'male', 88)
print s