iterator wrapper
Paul Rubin
http
Fri Aug 11 20:53:25 EDT 2006
alf <ask at me> writes:
> > |>> I = ([n] for n in i)
>
> This is nice but I am iterating thru hude objects (like MBs) so you know ...
I don't understand the objection-- the above is entirely correct and
produces the same iterator you'd get from
def wrap(i):
for x in i:
yield [x]
I = wrap(i)
You could also use
import itertools
I = itertools.imap(lambda x: [x], i)
which again does the same thing.
More information about the Python-list
mailing list