[issue2610] string representation of range

Alexander Belopolsky report at bugs.python.org
Fri Apr 11 17:24:10 CEST 2008


Alexander Belopolsky <belopolsky at users.sourceforge.net> added the comment:

It looks like our messages have crossed in flight.

> this little patch allows them to print(range(100,0,-1))
> and get a much better intuition about what is happening.

This is a really bad example.  Why would you want to introduce the print 
function in the first class?  You can explain much of the language using 
python as an advanced calculator without introducing any IO.  
Furthermore, given that print changes from being a statement to being a 
function in 3.0, it will be a much less novice friendly construct for 
years to come.  Also range(100, 0, -1) is not the most shining example 
of python's clarity. :-)

I think the best idea for educators would be to limit introductory 
material to 2.x - 3.x portable constructs.  This means avoid using 
range(..) outside of looping constructs, don't use print before you have  
to (and then use a subset of 3.x syntax.)

BTW, you really only need to use print function when you start writing 
scripts and that is better avoided in the first class when you have 
interactive environment as you do with python.

As a side remark, you may find the following trick useful in the first 
class:

>>> range(10)
range(0, 10)
>>> list(_)
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue2610>
__________________________________


More information about the Python-bugs-list mailing list