In Python, I can do:
list = ['a', 'b', 'c']
', '.join(list) # 'a, b, c'
However, if I have a list of objects and try to do the same thing:
class Obj:
def __str__(self):
return 'name'
list = [Obj(), Obj(), Obj()]
', '.join(list)
I get the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: sequence item 0: expected string, instance found
Is there any easy way? Or do I have to resort to a for-loop?