[pydotorg-www] Can't edit - https://wiki.python.org/moin/RangeGenerator
markmuir87 at gmail.com
Sat Aug 27 08:34:01 EDT 2016
I can't even seem to sign up for an account (which, from what I've read
would still not be sufficient).
I was hoping to add a Python 3 compatible implementation of the proposed
'irange' function (https://wiki.python.org/moin/RangeGenerator):
def irange(start, stop=None, step=1):
""" Generator for a list containing an arithmetic progression of
range(i, j) returns [i, i+1, i+2, ..., j-1]; start (!) defaults to
When step is given, it specifies the increment (or decrement).
For example, range(4) returns [0, 1, 2, 3]. The end point is
These are exactly the valid indices for a list of 4 elements.
if step == 0:
raise ValueError("irange() step argument must not be zero")
if stop is None:
stop = start
start = 0
continue_cmp = (step < 0) * 2 - 1
while ((start > stop) - (start < stop)) == continue_cmp:
start += step
If someone would be willing to edit this page for me I'd be grateful.
Unless, of course, this has already been implemented in Python 3, thus
making my effort pointless :)
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the pydotorg-www