Question regarding Higher-Order-Programming in Python
Mark Fink
mark at mark-fink.de
Wed Dec 22 09:35:26 EST 2010
> >>> list(chain.from_iterable(starmap(product, izip(izip(dims.iterkeys()),
>
> dims.itervalues()))))
> [('special', '+'), ('special', '-'), ('number', 1), ('number', 2),
> ('number', 3), ('letter', 'a'), ('letter', 'b')]
>
> Peter
so far I have never noticed chain.from_iterable, but many thanks to
you Peter, I have now a beautiful solution to this problem.
>>> from itertools import chain
>>> comb = it.combinations(dims, 2)
>>> l = chain.from_iterable(it.imap(get_products, comb))
>>> l.next()
[('special', '+'), ('number', 1)]
>>> l.next()
[('special', '+'), ('number', 2)]
More information about the Python-list
mailing list