Class A
contains a list of type class B
, which contains a print function. I am trying to return a String of all of the printed elements in B
, separated by a new line. What is the Pythonic 'single-line' way for method GetList()
?
class A():
# .....
def GetList(self):
temp = ""
for item in self.ListOfTypeClassB:
temp += item.Print() + "\n"
return temp
I can add the newline to the print method if that makes it cleaner.