Naming conventions for iterator methods?

Jp Calderone exarkun at intarweb.us
Tue Dec 23 09:23:24 EST 2003


On Tue, Dec 23, 2003 at 01:14:19PM +0000, John J Lee wrote:
> [snip]
> 
> I just realised some of these methods of mine don't actually return
> iterators, but merely objects supporting the iterator protocol.  In other
> words, the returned objects have an .__iter__() method, but not a .next()
> method (usually because I've quickly implemented the method by returning a
> sequence, leaving the way open for a later reimplementation that, eg.,
> returns a lazy iterator).  Would that surprise people from a method named
> .iter_foo()?
> 

  Yes.  return "iter(something)" instead of just "something".

  Jp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 196 bytes
Desc: Digital signature
URL: <http://mail.python.org/pipermail/python-list/attachments/20031223/38d1ebaa/attachment.sig>


More information about the Python-list mailing list