> And what about irange with an optional reverse= argument? I did have > (and write about on c.l.py) a case where I currently code: > > if godown: > iseq = xrange(len(sq)-1, start-1, -1) > else: > iseq = xrange(start, len(sq), 1) > for index in iseq: > ... > > and would be just delighted to be able to code, instead, > > for index in irange(start, len(sq), reverse=godown): > ... > > Even when the need to reverse can more easily be hardwired in > the source (a more common case), would > > for index in irange(start, stop, reverse=True): > > be really so much worse than > > for index in revrange(start, stop): > > ...? Darn. At your recommendation I tried reading my inbox in reverse today (how appropriate... :-) and I missed this use case when I said I'd rather have two functions. Oh well. I do think that the savings in typing from having a reverse= keyword for that one use case are easily outnumbered by the extra typing for the much more common use case that has reverse=True. But really, I could live with either one, so Raymond can decide based upon the evidence, and as I said, either way having this in itertools is an argument against making reversed() a builtin. --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