Raymond Hettinger wrote: > -1 on the silly renaming to __next__ and adding __builtin__.next(). > We have len() because it applies to many different object types. > In contrast, next() would apply only to iterables.
And you don't think there are many different types of iterables? You might as well argue that we don't need len() because it "only applies to sequences". There's a practical reason for using the xxx(obj)/obj.__xxx__() pattern -- it provides a lot more flexibility when it comes to future extensions of the protocol. We've used this to good effect already with iter(), which uses __iter__ if it's available, else falls back on another technique. If we had used this pattern with next() from the beginning then, for example, there would have been no problem adding an argument to next(), since the next() function could just have been updated to look for __send__ or something like that, and existing iterators need not have been affected. So the reason I'd like to see this changed in 3.0 is not because of consistency for its own sake, but because it would provide a better basis for future development. -- Greg _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com