range() function bug ?

Hi all,

In blender 2.6 the range() function gives me stranges results:

print(range(10))

gives me

“range(10”

But in blender 2.4 (or python in a term) gives me
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

i’m confused…

Blender 2.4 uses Python 2.x, Blender 2.5+ uses Python 3.x.
Look up the range() function in a Python reference.

http://docs.python.org/release/3.1.3/library/functions.html#range

Thanks a lot,
it’s better with the appropriate doc :wink:

to get the old result use e.g. this:
[el for el in range(10)]
Or more direct (better?) : list(range(10) as the link to pythons says, was not aware of it yet.

Same things happen to other constructs as. e.g. zip
Meaning you get back an object and not the result of it,
so you have to ask the object to do its work
(see example above!)