Steven D'Aprano steve+comp.lang.python at
Mon Sep 15 09:09:21 CEST 2014

Christian Gollwitzer wrote:

> range() does
> not return a list of numbers, but rather a generator

Technically, it's not a generator. It's a range object. Generators can
return anything, and you have to program them by using yield:

def gen():
    yield 1
    yield 2
    if today() is Tuesday:
        yield 99
    yield 3

whereas range() objects are much more specific in what they can do. But
otherwise, they behave in a similar fashion.


More information about the Python-list mailing list