Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: On Fri, Apr 11, 2008 at 12:06 PM, Brad Miller <[EMAIL PROTECTED]> wrote:
> Our use of range in the first few classes is exactly for iteration > purposes, but I do not like students to have to have too many mysteries. > So I always have liked to show that range(10) simply produces a sequence .. but it does not in 3.x and your patch does not change that. Instead, range(10) produces range(0,10) and I don't see anything mysterious here. > of integers. In Python 3.0 range returns a mysterious iteration object. > No thanks. My proposal was to provide a more user friendly > implementation of the str method for this new range object that would > allow the user to see the sequence. I like Python because it is so easy > to start up a shell and poke around and see what things are. > Maybe you should try it with some of your students first. Note that you can customize the way results are printed on the console with sys.displayhook. I fail to see how <0, 1, ... 9> is less mysterious than range(0,10), particularly combined with the fact that print representation is different from console display. I think <0, 1, ... 9> will confuse more students than it will help. > I have no problem, introducing list(range(10)) in week 3 when I start > talking about lists, and I like list comprehensions of that purpose too. > Why would you want to talk about loops before talking about lists? Python is not C. In many cases for x in some_list or for i,x in enumerate(some_list) is a better construct than for i in range(..). > Again, what I do not like is that things that used to be very easy for > students to get a conceptual handle on are now more difficult in 3.0. With your proposed <..> display students will be getting a wrong concept, thinking that <1, 2, 3> is yet another container in addition to (1,2,3), [1,2,3] and {1,2,3}. > - range is one example the dict_keys and dict_values objects are another > example. dict_keys et. al. are much easier to deal with since I've > already covered lists and the list() function by the time I get there. > IMHO list function is simpler than the print function, particularly in cases when it does not print what you enter. > BTW, I think we must have very different teaching styles as I would > never introduce something as mysterious as list(_) on the first day of > class. I'd be happy to continue our discussion of teaching philosophy > but I doubt that this is the right forum. > Your students are probably older than mine. I don't teach, but I introduced my son to python when he was 10. He is 12 now and is quite comfortable using python as a calculator (computing 2**1000 in python what quite an experience!) Explaining that _ stands for the value that just printed was easier than introducing variables (as in x=range(10); list(x)). __________________________________ Tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue2610> __________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com