I would like to know if there is a better way to print all objects in a Python list than this :
myList = [Person("Foo"), Person("Bar")] print("\n".join(map(str, myList))) Foo Bar
I read this way is not really good :
myList = [Person("Foo"), Person("Bar")] for p in myList: print(p)
Isn’t there something like :
print(p) for p in myList
If not, my question is… why ? If we can do this kind of stuff with comprehensive lists, why not as a simple statement outside a list ?