A Standard

Greg Ewing (using news.cis.dfn.de) g2h5dqi002 at sneakemail.com
Wed May 28 02:30:34 EDT 2003


Andrew Koenig wrote:
> Greg> And in Python, every sequence (i.e. something that
> Greg> implements __getitem__) can be iterated over
> 
> You mean it is impossible for a user-defined type to implement
> __getitem__ without also implementing __iter__?

No, but if the object doesn't implement __iter__,
the iter() function supplies a default iterator that
uses __getitem__ to access the object.

 > Python iterators are much closer to C++ input iterators
> than they are to forward iterators.

Consider my table updated appropriately, then (I'm not
very familiar with STL terminology).

-- 
Greg Ewing, Computer Science Dept,
University of Canterbury,	
Christchurch, New Zealand
http://www.cosc.canterbury.ac.nz/~greg





More information about the Python-list mailing list