[Python-Dev] Single- vs. Multi-pass iterability

Greg Ewing greg@cosc.canterbury.ac.nz
Mon, 22 Jul 2002 11:35:38 +1200 (NZST)


Ka-Ping Yee <ping@zesty.ca>:

> I believe this is where the biggest debate lies: whether "for" should be
> non-destructive.

It's not the for-loop's fault if it's argument is of such a nature
that iterating over it destroys it.

Given suitable values for x and y, it's possible for evaluating "x+y"
to be a destructive operation.  Does that mean we should revise the
"+" protocol somehow to prevent this from happening? I don't think so.

This sort of thing is all-pervasive in Python due to its dynamic
nature. It's not something that can be easily "fixed", even if it were
desirable to do so.

Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury,	   | A citizen of NewZealandCorp, a	  |
Christchurch, New Zealand	   | wholly-owned subsidiary of USA Inc.  |
greg@cosc.canterbury.ac.nz	   +--------------------------------------+