On Sun, 18 Oct 2009 14:33:17 +1100, Ben Finney wrote: > Jabba Laci <jabba.l...@gmail.com> writes: > >> 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') > > Works fine for me: > > Python 2.5.4 (r254:67916, Sep 26 2009, 11:00:02) [GCC 4.3.4] on > linux2 > Type "help", "copyright", "credits" or "license" for more > information. > >>> t = ('a', 'b') > >>> li = list(t) > >>> print li > ['a', 'b'] > >>> > >>> tu = tuple(li) > >>> print tu > ('a', 'b') > >> The error message is: "TypeError: 'tuple' object is not callable". > > Nothing in your example code is calling a tuple object. This makes me > suspect that what you showed us is not what you actually tried. > > You might want to try the above session yourself and paste the resulting > session *literally* (rather than re-typing) as I did above, so we can > see what you're seeing.
Surely it's obvious what he did - something like tuple = tuple([1,2]) After all, "tuple" is a reasonable name... -- http://mail.python.org/mailman/listinfo/python-list