Status of PEP's?

Hernan M. Foffani hfoffani at yahoo.com
Sat Mar 2 15:54:36 EST 2002


Carel Fellinger wrote:
> Jeff Hinrichs :
> 
> > What you are asking everyone to agree with is:
> >         5 = [0,1,2,3,4]
> 
> No he isn't:)  He explicitly says he doesn't think of sequences at all.

Yes, but...
 
The 'for' sentence in Python differs substantially from other languages.
Besides the whitespace show it may be one of the first thing you learn in
Python. From the tutorial:
"Python's for statement iterates over the items of any sequence (a list or
a string), in the order that they appear in the sequence"

And, to be fair, in the Ref. we read:
"The for statement is used to iterate over the elements of a sequence (such
as a string, tuple or list) or other iterable object"

Newbies don't get that far reading docs, heh heh...

The occasional/newbie programmer should not get the idea that Python's for
loop behaves along the lines of Basic or Fortran. I would like that the
concept of the for construction as we know it is as clear as possible.

So, if the PEP progress it should go along with a BIG notice that in
Python positive integers are iterable objects (or, more precisely, that
they follow the iter protocol.)

Thinking in practical terms, I'm more in favour of an indici(seq_or_iter)
builtin function and/or an inditems(seq_or_iter) one as someone proposed.

	for n in indici(set):
	for n, datum in inditems(set):

Also, we should work implementing the iter interface in old code so we
can see more things like:
	
	for row in resultSet:
		print row.attribute

so there is no need of xrange(seq.getCount()) / seq.get(n) pairs.

indici(x) will replace the odd xrange(len(x)) idiom and address the problem
of open intervals where the length of the set is not known in advance.

But I fail to see how to apply this solution naturally on sets that have
several different main 'walking' directions like arrays or like the sample
in the PEP. If the 'table' object has symmetry between two (or more) axes,
then
	indici(table)
is ambiguous.


Regards,
-Hernan



More information about the Python-list mailing list