PEP 276 Simple Iterator for ints (fwd)

Peter Hansen peter at engcorp.com
Wed Nov 28 08:05:48 CET 2001


David Eppstein wrote:
> 
>  Peter Hansen <peter at engcorp.com> wrote:
> 
> > But range() can be looked up.  You can type range(5) at the interactive
> > prompt (where a newbie would live) and see [0, 1, 2, 3, 4] and infer
> > immediately that you are stepping through the items one at a time.
> > Typing 0 <= i < 5 at the prompt gives you either 0 or 1, or NameError:
> > name 'i' is not defined. Not helpful for a newbie.
> 
> How would the newbie know to type "range(5)" instead of "i in range(5)"?

Try both.  One works... 

> > (Note: I'm not exactly interested in dumbing a language down to the
> > point where anyone can understand it without learning something from a
> > tutorial or the reference.
> 
> When you phrase it that way, I'm not either -- what does it mean to dumb
> down a language? 

I thought someone might object to my continued reference to newbies.
The "dumbing down" part comes from guessing that if there was an
objection to focusing on newbies when it comes to evaluating a 
suggested feature like this, the accusation would likely include 
those terms.  Didn't refer to anything specific in this case... either
yours or mine might be considered more "dumbed down" by this 
hypothetical objector. :)

> -- but I would be interested in changes that allow
> non-Python-literate programmers to understand my code without having to
> dig through a manual.

I agree that sounds like a worthy goal.  I disagree that your
suggestion is any more likely to be understood by anyone,
other than perhaps a mathematician.  As a very experienced
programmer, I found it quite obscure and am unsure I 
would have figured it out were it not for the context of
recent threads on the subject.

Maybe we should look back to BASIC (for i = 1 to 5: next) 
or one of the suggestions for something which looks more 
explicitly like a list of items (for i in [0..5]) or 
(for i in [0, 1, .. 5] ).  Especially this latter would
definitely be understandable to anyone, IMHO.

-- 
----------------------
Peter Hansen, P.Eng.
peter at engcorp.com



More information about the Python-list mailing list