[Python-Dev] defaultdict and on_missing() (original) (raw)
Greg Ewing greg.ewing at canterbury.ac.nz
Wed Mar 1 05:42:30 CET 2006
- Previous message: [Python-Dev] defaultdict and on_missing()
- Next message: [Python-Dev] iterator API in Py3.0
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Previous message: [Python-Dev] defaultdict and on_missing()
- Next message: [Python-Dev] iterator API in Py3.0
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]