[pydotorg-www] Can't edit - https://wiki.python.org/moin/RangeGenerator

Mark Muir markmuir87 at gmail.com
Sat Aug 27 08:34:01 EDT 2016


Hi,

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
integers.
        range(i, j) returns [i, i+1, i+2, ..., j-1]; start (!) defaults to
0.
        When step is given, it specifies the increment (or decrement).
        For example, range(4) returns [0, 1, 2, 3].  The end point is
omitted!
        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:
        yield start
        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 :)

Mark
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pydotorg-www/attachments/20160827/f4533b74/attachment.html>


More information about the pydotorg-www mailing list