> > 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? >
It looks like, "if topics contains only a single topic", means: self.topics = MyTopic was done at some point. What you should do is make self.topics ALWAYS be a list: even if it's only a list of one item. So you do self.topics.append(MyTopic) when you add that one topic. That way self.topics is always a list. Sometimes empty, sometimes containing one element, sometimes containing many. --S
-- http://mail.python.org/mailman/listinfo/python-list