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

Matteo Dell'Amico della at toglimi.linux.it
Thu Jul 29 09:30:08 CEST 2004


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 '_'.

-- 
Ciao,
Matteo



More information about the Python-list mailing list