> I think the search for the __reversed__ method is the meat of the > proposal; I can define for myself a simple two-line generator that > iterates in reverse over sequences. What I need the language to > define for me is a protocol for iterating over objects in reverse > and for providing users of my own classes with the ability to > iterate over them in reverse in a standard way. > > If this proposal could be satisfied by the simple definition: > > def reversed(seq): > for i in xrange(len(seq)-1, -1, -1): > yield seq[i] > > I wouldn't be for it. The reason I'm +1 is because I want a > standard protocol for iterating in reverse over objects. I would be *against* such a protocol. It would end up complicating almost everything that defines __iter__, for a very questionable pay-off (reverse iteration isn't that common except for some special cases). The PEP got as far as it is by focusing on simplicity and sequences. It is rapidly losing its innocence. :-) --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