[Tutor] _next

Roel Schroeven rschroev_nospam_ml at fastmail.fm
Wed May 31 12:15:19 CEST 2006


Dave Kuhlman schreef:
> Roel Schroeven <rschroev_nospam_ml <at> fastmail.fm> writes:
> Kent Johnson alerted me to this discussion.
> 
> And, thanks, Roel, for the comments and improvements on my example.
> 
> I agree that my example class being discussed is confused.  I've reworked the 
> example, taking hints from this thread.  And, while I was there, I've re-written 
> the whole section on iterators.  Hopefully, I've made it less (rather than more) 
> confusing.  You can find the new version here:
> 
> http://www.rexx.com/~dkuhlman/python_101/python_101.html
> http://www.rexx.com/~dkuhlman/python_101/python_101.
> html#SECTION004460000000000000000

I think it is quite clear now; it certainly gives a nice overview of all 
the different ways of creating iterators. It might be a bit overwhelming 
for beginners though.

> You may be wondering why I would spend so much time on what seems to be a little 
> used and advanced technique.  After all, iterators cannot be too important, 
> since they did not even make it into Python until Python 2.2.  The answer I give 
> myself is that this Python feature is very powerful and very elegant.  It also 
> gives us the ability to write clearer and more maintainable code, for example, 
> separating the producer and consumer parts of our code.  But, it does so only if 
> we can work out a clear and unconfused way to explain and teach it.  Thanks for 
> motivating me to try to do that.

I agree that iterators are an important language feature, but as I said 
it might be a bit too much information to digest at once. I know I 
didn't learn the iterator protocol until after I gained some experience 
in Python. OTOH, that might just be because it wasn't mentioned in the 
tutorial I used (the official one), so maybe it's a good thing that it's 
clearly explained in your tutorial.

I think comments from people who use the tutorial to learn Python are 
more appropriate than mine in this regard.

-- 
If I have been able to see further, it was only because I stood
on the shoulders of giants.  -- Isaac Newton

Roel Schroeven



More information about the Tutor mailing list