PEP 276 Simple Iterator for ints (fwd)

Rainer Deyke root at rainerdeyke.com
Tue Nov 27 22:16:26 EST 2001


"David Eppstein" <eppstein at ics.uci.edu> wrote in message
news:eppstein-AEB95C.16365127112001 at news.service.uci.edu...
> In article <slrna0824s.1ra3.Gareth.McCaughan at g.local>,
>  Gareth.McCaughan at pobox.com (Gareth McCaughan) wrote:
>
> > Greg Ewing wrote:
> >
> > > While trying to think of a range syntax that looks
> > > unambiguously half-open without clashing with list
> > > or tuple constructors, the following blindingly
> > > obvious solution occurred to me:
> > >
> > >   for 0 <= i < 5:
> > >     ...
> >
> > +1 if it also groks "for 0 < i <= 5" and so on.
>
> Also +1 if it gives the reversed sequence for "for 5 > i >= 0".

+666 if it understands arbitrary expressions:

for 0 <= i < 5 and i % 0 == 0: # possible
  pass

for 0 < i + 2 <= 5: # unlikely
  pass

for i.__class__ == str: # impossible
  pass

for a * x ** 2 + b * x + c == 0: # what's this even supposed to do?
  pass


On second thought, let's not go there.  It's a silly place.


--
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