join does not call __str__
Sasa Zivkov
sasha at spuni.is
Fri Jun 1 11:12:25 EDT 2001
>>> class A:
... def __str__(self):
... return "str-a"
...
>>> a = A()
>>> print a
str-a
>>> b = ['c', 'd', a]
>>> "".join(b)
Traceback (most recent call last):
File "<interactive input>", line 1, in ?
TypeError: sequence item 2: expected string, instance found
Somehow I expected that join method would use __str__ method to convert
instance to string...
Your opinion ?
-- Sasa
More information about the Python-list
mailing list