Specific iterator in one line

Paul Rubin http
Tue Jun 30 11:18:06 CEST 2009


Filip Gruszczyäski <gruszczy at gmail.com> writes:
> [1, 0, 0, 1] -> ['b', 'b', 'a', 'a', 'b', 'b']

Using itertools:

>>> list(chain(*imap([['a'],['b','b']].__getitem__, [1,0,0,1])))
['b', 'b', 'a', 'a', 'b', 'b']



More information about the Python-list mailing list