Re: [Tutor] Converting string or list to sum

Terry Carroll carroll at tjc.com
Sat Jan 31 21:47:23 EST 2004


On Sat, 31 Jan 2004, Isr Gish wrote:

> When I try doing.
> map(str, a)
> I got a traceback 
> TypeError: 'str' object is not callable
> But when I do,
> map(__builtin__.str, a)
> It works fine.

did you rebind the variable name str elsewhere in your program, e.g.,

>>> a=['1','2','3']
>>> a
['1', '2', '3']
>>> d=''.join(map(str,a))
>>> d
'123'
>>> str="xyz"
>>> d=''.join(map(str,a))
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: 'str' object is not callable
>>>








More information about the Tutor mailing list