Building a dict from a tuple of tuples

vsoler vicente.soler at gmail.com
Sat Feb 20 12:35:17 EST 2010


Hello everyone!

I have a tuple of tuples, coming from an Excel range, such as this:

((None, u'x', u'y'),
(u'a', 1.0, 7.0),
(u'b', None, 8.0))

I need to build a dictionary that has, as key, the row and column
header.

For example:
d={ (u'a',u'x'):1.0, (u'a',u'y'): 7.0, (u'b',u'y'):8.0 }

As you can see, if the value in the matrix is None, no key has to be
added to the dictionary.

Of course, my tuple of tuples is a lot bigger.

How can I possibly do this?

Thank you



More information about the Python-list mailing list