> Well, i guess that's part of the protocol philosophy. There exist > cursor-like objects that would be natural candidates for being used > like iterators (files are one example, database cursors are another). > Choosing __next__ makes it possible to add support to an existing > object when appropriate, instead of requiring an auxiliary object > regardless of whether it's appropriate or inappropriate. OK, that's clear. > To me, the former feels like the more typical Python thing to do, > because it's consistent with the way all the other protocols work. > So it's from this perspective that "next" without underscores > is a wart to me. Yes. > For example, when something is container-like you can implement > __getitem__ on the object itself, and then you can use [] with the > object. Some objects let you fetch containers and some objects > implement __getitem__ on their own. But we don't force everybody > to provide a convert-to-container operation in all cases before > allowing them to provide __getitem__. Correct. Now, weren't you a co-author of the Iterator PEP? I wish you'd brought this up then. Or maybe you did, and I overruled you. Sorry then. But I don't think we can withdraw this so easily. It's not the end of the world. --Guido van Rossum (home page: http://www.python.org/~guido/)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4