Problem with join in__str__() in class (newbie)

Fencer no.i.dont at
Sun Aug 9 19:42:23 CEST 2009

jon rascal wrote:
> You're turning your list into a string -- try this:
> ', '.join([str(x) for x in self.topics])

Thanks for your quick reply, unfortunately it didn't quite work for me.
Say topics contain two topics: polemics, and the parthenon I get this 
Known topics: t5:Polemics

only the first topic is printed. If topics only contain a single topic I 
get this error:
Traceback (most recent call last):
   File "C:\Users\fencer\workspace\Find Expert\src\", line 
57, in <module>
     print experts[1]
   File "C:\Users\fencer\workspace\Find Expert\src\", line 
21, in __str__
     output += '\nKnown topics: %s' % (', '.join([str(x) for x in 
TypeError: iteration over non-sequence

What did I do wrong?

- Fencer

More information about the Python-list mailing list