what does 'for _ in range()' mean?

Peter Hansen peter at engcorp.com
Thu Jul 29 07:39:45 EDT 2004


Matteo Dell'Amico wrote:

> Peter Hansen wrote:
> 
>> Uh, okay... and does Ocaml allow duplicating argument
>> names in whatever it has that passes for a function
>> definition?  This is all a reach from the original
>> point of the thread, which was to use it as a throw-away
>> control variable in a for loop...
> 
> It allows pattern-matching. You can say, for instance, something as:
> 
> foo(a, a) = True
> foo(_, _) = False
> 
> This means that foo is true when its arguments are equal. Note, too, 
> that 'a' has a different value from '_'.

I have no idea what you are talking about; sorry.  The "code"
you show is not valid, and since you aren't talking about a
function *definition* (where duplicate names are disallowed)
but apparently about calling a function, I can't see that this
has the slightest thing to do with the topic at hand.

Therefore I'm sure I misunderstood what you meant... please
explain.

-Peter



More information about the Python-list mailing list