Iterator addition

Paul Rubin http
Wed Nov 9 23:50:48 EST 2005


aleax at mail.comcast.net (Alex Martelli) writes:
> > Is there a good reason to not define iter1+iter2 to be the same as

> If you mean for *ALL* built-in types, such as generators, lists, files,
> dicts, etc, etc -- I'm not so sure.

Yes, that's what I mean.

> 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...

Hmm, there might also be __add__ operations on the objects, that would
have to take precedence over iterator addition.  Iterator addition
itself would have to be a special kludge like figuring out "<" from
__cmp__, etc.

Yeah, I guess the idea doesn't work out that well.  Oh well.



More information about the Python-list mailing list