Iterator addition

Paul Rubin http
Wed Nov 9 23:34:49 EST 2005


Is there a good reason to not define iter1+iter2 to be the same as
itertools.chain(iter1, iter2)?

Examples:

   # all lines in a collection of files, like perl <>
   all_lines = file1 + file2 + file3

   candidate_primes = (2,) + (1+2*i for i in itertools.count(1))
   # candidate_primes is 2,3,5,7,9,11,...
   primes = itertools.ifilter(is_prime, candidate_primes)



More information about the Python-list mailing list