C
Chris S.
Why do most, if not all, compound Python structures not convert their
elements to strings recursively?
.... def __init__(self, a):
.... self.a = a
.... def __str__(self):
.... return 'foo('+str(self.a)+')'
....
.... for n in self:
.... text.append(str(n))
.... return 'Set('+', '.join(text)+')'
....Set(foo(1))
elements to strings recursively?
.... def __init__(self, a):
.... self.a = a
.... def __str__(self):
.... return 'foo('+str(self.a)+')'
....
.... text = []>>> from sets import Set
>>> a=Set([foo(1)])
>>> print aSet([ said:>>> def SetStr(self):
.... for n in self:
.... text.append(str(n))
.... return 'Set('+', '.join(text)+')'
....Set(foo(1))