Status of PEP's?

Bjorn Pettersen BPettersen at NAREX.com
Thu Feb 28 10:50:59 EST 2002


> From: Remco Gerlich [mailto:scarblac at pino.selwerd.nl] 
> 
> Fernando Pérez <fperez528 at yahoo.com> wrote in comp.lang.python:
> > Python is a general purpose language, not one to be used only by 
> > number
> > theorists. Putting at a level as basic as the integers a 
> convention which 
> > allows things like 'for i in 3' to be valid iteration code 
> really sounds 
> > bizarre and counter intuitive to me.
> > 
> > But maybe it's just me.
> 
> It's not just you.
> 
> I believe syntax like 'for i in 5:' is confusing (at first 
> sight I'd think that i would get one value, 5), and has no 
> merit except saving a few key strokes compared to 'for i in 
> range(5):', which is clearer as well.
> 
> Compare:
> 
> for i in 6: print i
> for i in 6,7: print i
> for i in 6,7,8: print i
> 
> You wouldn't think the first line does something different, would you?

Personally, I find the proposal quite easy to understand, and I have no
problem grokking that 

  for i in len(mylist):

Creates an iterator over the indices in mylist. After over four years
programming in Python, the above is still an error I make frequently. I
also see no conceptual problem in understanding what:

  if i in len(mylist):

does. In fact I think it is more intuitive than the current:

  if i in range(len(mylist)):

Finally, I would almost expect the proposal to work, when 

  for line in file:

works.

Oh, and as for the proposal to have range accept a sequence, I believe
that died by BDFL pronouncement (although my memory is a bit fuzzy here
;-)

-- bjorn




More information about the Python-list mailing list