tuples from lists

David Eppstein eppstein at ics.uci.edu
Sun Mar 9 15:41:46 EST 2003


In article <c4e6b17d.0303091212.4fee8ea9 at posting.google.com>,
 bobnotbob at byu.edu (Bob Roberts) wrote:

> I have a list of lists of lists.  How can I turn that into a tuple of
> tuples of tuples?

If LLL is a list of lists of lists, then:

def tuplize(LL):
    return map(tuple,LL)

TTT = tuple(tuplize(map(tuplize,LLL)))

-- 
David Eppstein                      http://www.ics.uci.edu/~eppstein/
Univ. of California, Irvine, School of Information & Computer Science




More information about the Python-list mailing list