List to Tuple and Tuple to List?
Boris Borcic
bborcic at gmail.com
Tue Nov 6 07:29:53 EST 2007
Davy wrote:
> Hi all,
>
> I am curious about whether there is function to fransform pure List to
> pure Tuple and pure Tuple to pure List?
>
> For example,
>
> I have list L = [[1,2,3],[4,5,6]]
> something list2tuple() will have T=list2tuple(L)=((1,2,3),(4,5,6))
>
> And the tuple2list()
>
> Any suggestions are welcome!
D = { list : tuple, tuple : list }
F = lambda x : D[type(x)](map(F,x)) if type(x) in D else x
list2tuple = tuple2list = F
More information about the Python-list
mailing list