> Here's another sweet and short PEP. What do folks think? Is > xrange()'s complexity really worth having? > > --Guido van Rossum (home page: http://www.python.org/~guido/) > > PEP: 260 > Title: Simplify xrange() > Version: $Revision: 1.1 $ > Author: guido@python.org (Guido van Rossum) > Status: Draft > Type: Standards Track > Python-Version: 2.2 > Created: 26-Jun-2001 > Post-History: 26-Jun-2001 > > Abstract > > This PEP proposes to strip the xrange() object from some rarely > used behavior like x[i:j] and x*n. > > > Problem > > The xrange() function has one idiomatic use: > > for i in xrange(...): ... If this is to be done, I would also propose that xrange() and range() be changed to allow passing in a straight-out sequence such as in the following code in order to get rid of the need for range(len(seq)): import __builtin__ def range (start, stop=None, step=1, range=range): """""" start2 = start stop2 = stop if stop is None: stop2 = start start2 = 0 try: return range(start2, stop2, step) except TypeError: assert stop is None return range(len(start)) def xrange (start, stop=None, step=1, xrange=xrange): """""" start2 = start stop2 = stop if stop is None: stop2 = start start2 = 0 try: return xrange(start2, stop2, step) except TypeError: assert stop is None return xrange(len(start)) a = [5, 'a', 'Hello, world!'] b = range(a) c = xrange(4, 6) d = xrange(b) e = range(c) print a print b print c print d print e print range(d, 2) Tim Delaney
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