PEP 284, Integer for-loops

Greg Ewing greg at cosc.canterbury.ac.nz
Thu Mar 7 20:32:06 EST 2002


Bjorn Pettersen wrote:
> 
> If it can only be used in one context in the
> language I'm left to wonder if it's not just extra "noise" for everyone
> to have to learn...

Just in case anyone's forgotten, it can also
be used in a list comprehension:

  r = [i for 0 <= i < 10]

If efficiency is a concern, the compiler could
recognise this as a special case and substitute an
appropriate range() call. (And too bad about the
difference wrt side effects on i -- I don't
care!)

-- 
Greg Ewing, Computer Science Dept, University of Canterbury,	  
Christchurch, New Zealand
To get my email address, please visit my web page:	  
http://www.cosc.canterbury.ac.nz/~greg



More information about the Python-list mailing list