flatten sequences in a dictionary

ajcppmod at gmail.com ajcppmod at gmail.com
Wed Jan 9 08:16:58 EST 2008


Hi

I wondering if someone could give me a pointer. I have a dictionary
with the following structure:

testDict = dict(foo=((1,2,3),(1,4,3)), bar=((3,2,1),(9,8,7,)),
mumble=((1,2,3),))

I am trying to create a list of the the 3 element tuples using
itertools (just for a bit of fun). I'm trying this:

list(itertools.chain(testDict.itervalues())

but that's doesn't work. I think I need a way to convert the iterator
returned by itervalues() into a sequence of iterables. Any clues?

Thanks

Andy



More information about the Python-list mailing list