PEP 276 Simple Iterator for ints (fwd)

Paul Jackson pj at sgi.com
Mon Dec 10 16:59:26 EST 2001


David Eppstein <eppstein at ics.uci.edu> wrote:
|>
|> In article <9up46o$e2ost$1 at fido.engr.sgi.com>, pj at sgi.com (Paul Jackson) 
|> wrote:
|> 
|> > Ok - so you choose to go down that fork in the decision tree:
|> > 
|> >     The problem I have with this then is that it results
|> >     in the comparison operators <, <=, ..., >, >= sometimes
|> >     requiring a list of assignable expressions on one or the
|> >     other side, as opposed to their current usage, which
|> >     requires comparable expressions on both sides.
|> > 
|> >     This sort of subtle, context sensitive syntax change
|> >     feels weird and unsettling to me.
|> 
|> And you're not equally unsettled by the identical behavior of "in"?

I take it you are comparing the use of 'in' in the two
contexts:
    if x in s:
and
    for x in s:

In the first case, x is compared with each element of s,
and in the second case x is assigned each element of s.

Ok - fair enough.

But I still don't like it.

Let me try this tack -- pray tell how does one verbalize
(read out loud or subverbally) the line:

    for 0 <= i < 10:

Imagine, say, you and a colleague were brainstorming over
something on the telephone, and you happened to want to say
something equivalent in meaning to this.  If it were me, I
would not say:

    "for zero less-than-or-equal i less-than ten"

Not in a million years.  I would say something like one of:

    say i ranges from zero to ten
    for each i between zero and ten
    let i take on a value between zero and ten
    take i in the range zero to ten
    take i between zero and ten
    given that i is between zero and ten
    (I might say 'nine', not 'ten', depending on the listener ...)

or one of sundry other variations, each one of which I'd wager
would _not_ have the name of the variable 'i' occurring after
the 'zero', but before the 'ten'.

In short, I claim that, even though the notation is visually
appealing, it is not verbally appealing.  It looks ok, but
sounds bogus.  You wouldn't read it out loud, to someone who
wasn't within view of it, as it is written, if you were more
focused on conveying meaning than being literal.

So ... how do you read this construct out loud?

-- 

                          I won't rest till it's the best ...
			  Manager, Linux Scalability
                          Paul Jackson <pj at sgi.com> 1.650.933.1373



More information about the Python-list mailing list