PEP 276 Simple Iterator for ints (fwd)

Rainer Deyke root at rainerdeyke.com
Wed Nov 28 09:37:59 EST 2001


"Peter Hansen" <peter at engcorp.com> wrote in message
news:3C04768A.CFDC1CE8 at engcorp.com...
> Rainer Deyke wrote:
> >
> > "Peter Hansen" <peter at engcorp.com> wrote:
> > > Greg Ewing wrote:
> > > >   for 0 <= i < 5:
> > > >     ...
> > >
> > > -1 for being ambiguous to newbies.
> >
> > The same could be said for 'for i in range(5)', since 'i in range(5)' is
an
> > expression that is roughly equivalent to '0 <= i < 5'.
>
> 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.

You are missing the point.  Typing 'i in range(5)' gives the same result at
the interactive prompt.  So does 'i in [0, 1, 2, 3, 4]'.


--
Rainer Deyke (root at rainerdeyke.com)
Shareware computer games           -           http://rainerdeyke.com
"In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor





More information about the Python-list mailing list