def gatherAttrs(self): attrs = [] for key in sorted(self.__dict__): attrs.append('%s=%s)'%(key,getattr(self,key))) return ','.join(attrs)
почему в этом примере
def gatherAttrs(self): attrs = [] for key in sorted(self.__dict__): attrs.append('%s=%s)'%(key,getattr(self,key))) return ','.join(attrs)
>>> a='231231' >>> b=[123,'zxc',True] >>> b [123, 'zxc', True] >>> a.join(b) Traceback (most recent call last): File "<pyshell#19>", line 1, in <module> a.join(b) TypeError: sequence item 0: expected str instance, int found