Andrew Koenig <ark@research.att.com>:
Is a file a container or not?
I would say no, a file object is not a container in Python terms. You can't index it with [] or use len() on it or any of the other things you expect to be able to do on containers. I think we just have to live with the idea that there are things other than containers that can supply iterators. Forcing everything that can supply an iterator to bend over backwards to try to be a random-access container as well would be too cumbersome. 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 +--------------------------------------+