Lists
Steven D'Aprano
steve+comp.lang.python at pearwood.info
Mon Sep 15 03:09:21 EDT 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.
--
Steven
More information about the Python-list
mailing list