what does 'for _ in range()' mean?
peter at engcorp.com
Thu Jul 29 21:37:25 CEST 2004
Christopher T King wrote:
> On Thu, 29 Jul 2004, Peter Hansen wrote:
>>In that case they would be related, but is this any more than
>>supposition on your part? Is the use of _ as a throw-away in
>>for loops, and perhaps even in the interpreter as "last result",
>>definitely descended from its wildcard usage in functional
>>languages (or, at least, Ocaml)?
> I'm pretty sure they're both descended from the use of _ as both a
> throw-away and a wildcard in Prolog, as another poster pointed out.
I'm just as unsure about any of that. It seems more likely to
me that a number of people have independently found _ to be a handy
"anonymous" variable in different situations, and that trying to find
links to analogous usage in other languages is largely speculative.
Of course, that said, we'll probably hear shortly from someone
channelling the person who added it to the interpreter as the
"last result" name, contra-dicting me. :-)
More information about the Python-list