List -> Tuple

Joseph Wilhelm jwilhelm at outsourcefinancial.com
Wed Oct 31 11:47:46 EST 2001


>     Joseph> Is there a simple way to convert a list into a
> tuple, like a
>     Joseph> built-in function for that? Or is the easiest way to just
>     Joseph> iterate through the list and append to a tuple?
>
> Try the tuple builtin:
>
>     >>> l = [1,2,3]
>     >>> tuple(l)
>     (1, 2, 3)

Ah, thank you much, exactly what I was looking for! Wasn't quite sure if
that function really was sitting around.

--Joseph Wilhelm





More information about the Python-list mailing list