list to tuple and vice versa
Chris Rebert
clp2 at rebertia.com
Sat Oct 17 23:32:55 EDT 2009
On Sat, Oct 17, 2009 at 8:24 PM, Jabba Laci <jabba.laci at gmail.com> wrote:
> Hi,
>
> I have some difficulties with list -> tuple conversion:
>
> t = ('a', 'b')
> li = list(t) # tuple -> list, works
> print li # ['a', 'b']
>
> tu = tuple(li) # list -> tuple, error
> print tu # what I'd expect: ('a', 'b')
>
> The error message is: "TypeError: 'tuple' object is not callable".
You created a variable named "tuple" somewhere, which is shadowing the
built-in type. Rename that variable to something else.
Cheers,
Chris
--
http://blog.rebertia.com
More information about the Python-list
mailing list