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\".joi
For Python 2.*:
If you overload the function __str__() for your Person class, you can omit the part with map(str, ...). Another way for this is creating a function, just like you wrote:
def write_list(lst):
for item in lst:
print str(item)
...
write_list(MyList)
There is in Python 3.* the argument sep for the print() function. Take a look at documentation.