[Python-Dev] iterator API in Py3.0

Baptiste Carvello baptiste13 at altern.org
Sun Mar 5 19:43:47 CET 2006

Phillip J. Eby a écrit :

> I didn't misstate her argument or reduce it to the absurd.  I simply 
> applied that argument consistently to similar features of Python.  It's you 
> who is concluding that this results in absurdity; I made no such 
> conclusion.  I'm simply pointing out that in 3.0 we should be 
> consistent.  Either we should have ob.iter() and ob.len(), or else we 
> should have a builtin next().

There is a difference though: a next() builtin would change the state of its 
argument, what len() ant iter() don't do. I usually prefer methods to functions 
for operations that modify an object.
But then we have setattr and delattr :)

I'd say it makes sense to go for practicallity here. Let's keep the next() 
method as it is, and document this as an exception. The canonical place could be 
section 3.3 in the language reference, but for some reason, it does not list 
next() right now...


More information about the Python-Dev mailing list