PEP 260: simplify xrange()

Dinu Gherman gherman at
Wed Jun 27 18:24:21 CEST 2001

Aahz Maruch wrote:
> >PS: BTW, why not *add* something useful and make float
> >    increments work "as expected" in range/xrange...?
> And how do you expect floating point increments to work?  (Have you paid
> any attention to the extensive threads on FP over the past few months?)

No, I haven't followed the discussion... but you asked 
about an implementation; I'm using the one below.


def frange(start, end=None, inc=None):
    "A range function, that does accept float increments..."

    if end == None:
        end = start + 0.0
        start = 0.0

    if inc == None:
        inc = 1.0

    L = [start]
    while L[-1] + inc < end:
        L.append(L[-1] + inc)

    return L

More information about the Python-list mailing list