Reputation: 23
In Python:
list(itertools.chain.from_iterable(['aaa','bbb']))
gives:
['a','a','a','b','b','b']
as expected.
In Jython 2.7.0 the same code gives TypeError: 'str' object is not callable
.
Note that it seems to be the attempt to cast to a list that gives the error, as
for c in itertools.chain.from_iterable(['aaa','bbb']):
lst.append(c)
constructs the required list.
Upvotes: 0
Views: 367
Reputation: 155428
I suspect there is no problem with Jython, you just declared a variable named list
and assigned it a string value.
Run del list
to get rid of the name shadowing the built-in, then retry, and it should work on Jython too.
Upvotes: 2