Iterator addition

Alex Martelli aleax at
Thu Nov 10 05:42:06 CET 2005

Paul Rubin <> wrote:

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

No -- feel free to define __add__ accordingly in every one of your
iterator classes.

If you mean for *ALL* built-in types, such as generators, lists, files,
dicts, etc, etc -- I'm not so sure.  Right now, if I mistakenly try to
add a list to a dict, I get an exception which immediately alerts me to
my mistake.  I definitely wouldn't want to lose that...


More information about the Python-list mailing list