I’m curious how I should be be implementing the repr method of an object that contains other objects that implement repr.
For example (pythonish):
class Book():
def__repr__
return 'author ... isbn'
class Library():
def __repr__:
me ='['
for b in books:
me = me + b.repr()
me = me + ']'
return me
Do I have to directly call that repr() method? i can’t seem to just concat it and have it implicitly convert it to a string.
Call the
repr()function on theBookinstance:object.__repr__(self)[docs]