PEP 284, Integer for-loops

Courageous jkraska at san.rr.com
Thu Mar 7 18:57:45 EST 2002


>This doesn't sound good.  Suppose you say
>
>      for i = a to b:
>
>where you don't know at compile time the values of a and b.
>Do you really want it to count backwards if b < a?

I truly don't know. It's a semantic I could live with.
Ordinarily I personally would expect to validate the
data elsewhere in any case, so for _ME_, the shortcut
is just a way of not specifying the negative stride.
Here's another option:

	for i = 1 to 10 += 1:
	for i = 10 to 1 -= 1:

I think in at least one case the stride ought to be
optional.

C//





More information about the Python-list mailing list