[issue2610] string representation of range
report at bugs.python.org
Fri Apr 11 16:47:07 CEST 2008
Alexander Belopolsky <belopolsky at users.sourceforge.net> added the comment:
I did not realize that the proposed patch only affects str and not repr.
Some of may previous arguments against it do not hold in this case, but
I am still -1.
If you introduce range before list, it will be hard to explain why lists
are printed in valid python syntax while ranges are not.
What do you do with ranges in your first classes? Maybe you can
introduce it as a part of the looping construct and make students think
of for i in range(10) as an equivalent of C's for(i = 0; i < 10; i++)?
>>> [i for i in range(10)]
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
can be demonstrated early without explaining the mechanics of list
comprehensions. I would expect most students being able to guess what
for i in range(10): does and half of the students being able to guess
what [i for i in range(10)] means.
Tracker <report at bugs.python.org>
More information about the Python-bugs-list