Problem with join in__str__() in class (newbie)
Fencer
no.i.dont at want.mail.from.spammers.com
Sun Aug 9 13:42:23 EDT 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
output:
e2:Carla
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\find_expert.py", line
57, in <module>
print experts[1]
File "C:\Users\fencer\workspace\Find Expert\src\find_expert.py", line
21, in __str__
output += '\nKnown topics: %s' % (', '.join([str(x) for x in
self.topics]))
TypeError: iteration over non-sequence
What did I do wrong?
- Fencer
More information about the Python-list
mailing list