PEP 276 (was Re: Status of PEP's?)

Carel Fellinger cfelling at iae.nl
Fri Mar 1 16:25:19 EST 2002


James_Althoff at i2.com wrote:

...
> [Carel Fellinger]
>> you being such a heavy weight that I fear
...
> Well, thanks (I think <wink>), but I can assure you that I hold no special

You think right, which could have be infered from *me* calling you a
heavy weight, might you have known me:)

...
> [Carel Fellinger]
>> Not only newbie unfriedly, you need a firm grasp of modern set
>> based number theory to appreciate it, it seems.

> As fond as we all surely are of the neat mathematical underpinnings
> suggested here and before, I believe that most programmers -- regardless of
> skill level (and pedigree in the field of mathematics) -- would be able to
> understand -- and certainly easily remember the second time -- that
> iterating on n means taking each of 0,1,2, ..., n-1 in turn; this without
> having to think about -- much less have "a firm grasp of" -- number theory
> (modern, set-based, or otherwise <wink>).  At least if one has enough
> background to understand "iteration" to begin with.

I admit I will be able to remember this, know how and when to use it
and all that.  And certainly programmers in general will be able to
handle it, hey some of them even handle APL (or so they believe).  But
even after that nice math lesson I still don't *understand* it, you
iterate over a sequence and I have a hard time seeing an integer as a
sequence.  Same for a length. And I believe many would have the same
problem.  Besides, I don't see the huge advantage of this compared to
`range(integer)' or `indici(sequenceORmapping)'.

Unfortunately the whole subject has moved from a `preference' via
`lack of knowledge' to a matter of `believe', so not much of a chance
to resolve it:)

> Let's try that again.

> Q: What does it mean to iterate a number n?

A: I wouldn't know.  O wait you mean that awfull hack, yea I know,
   pretend an integer is a sequence...


> I certainly acknowledge the feelings of those who don't like the suggested
> idiom.  At the same time, claims of its alleged *great difficulty* seem
> overblown.

It's not difficult to use once it's been explained, it's difficult
to understand no matter how often it gets explained.

> [Carel Fellinger]
>> So please explain why you think it natural to loop over a number.

> The "rational" section of PEP 276 talks about iterating through the indices
> of an indexed collection.  These, as we know, are related to the length (an
> integer) of the indexed collection.

far fatched isn't it?
What about a function that accepts as argument such a collection and then
generates the indici?  Much easier to explain, to understand, to adopt.
But admitted, it takes a little extra typing.

Seriously I would like you to add something in your PEP that addresses
this simple alternative and explain why you favour yours.  True,
`i in range(len(sequence))' doesn't look very pleasing, but
`i in indici(sequence)' does. And as an added bonus it's
very similar to `(i, item) in indexed(sequence)'.


> [Carel Fellinger]
>> here in your PEP you make it look like some minority
>> of nitwits objected

> I don't remember writing anything about nitwits.  But that does remind me

I'm sorry. Those are my words, and my words only. I was a bit itchy that
day, would have formulated it differently now.  But I do think that
dismissing our point as a matter of preference misses our point.


> [Remco Gerlich]
>> 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?

> [Emile van Sebille]
>> Is that really any different from what we have now:
>>
>> for i in "Spam": print i
>> for i in "Spam","and": print i
>> for i in "Spam","and", "Eggs": print i

> [Andy Gimblett]
>> Yes, it really is.  "Spam" is a sequence, whereas 6 isn't.

> I agree with Emile on this one.

To me this means you actually see and int as a sequence then.  A
string is a sequence, a sequence of chars.  I still fail to understand
how the same applies to integers.

> Two different results.  One needs to understand how and why.  Sometimes one
> wants to treat a string as a unit, other times as a sequence.  It's useful
> and convenient to be able to do both.

I agree, but can't relate this to integers.

looking forward to your views on meta programming though
-- 
groetjes, carel



More information about the Python-list mailing list