Snapshottable re-iterable iterators

Michael Chermside mcherm at mcherm.com
Tue Jun 17 11:54:43 EDT 2003


Beni Cherniavsky writes:
 [... should the "snapshot-this-iterator" function be named __iter__? ...]
> On one hand, it seems cute.  On the
> other, it makes it hard to avoid the forking when you don't want it.

I think you've summed it up nicely yourself in the above quote.

Argument 1: it makes it hard to avoid the forking when you don't want it.
  Therefore, you should avoid the name "__iter__".

Argument 2: It seems cute.
  Therefore, you should avoid the name "__iter__". "Cute" is a red flag
  here warning you that it's a dangerously misleading choice of name.

So call it "snapshot()", or "copy()", but not "__iter__()".

-- Michael Chermside






More information about the Python-list mailing list