functional programming with map()

Raymond Hettinger python at rcn.com
Mon Mar 4 00:39:53 EST 2002


"Greg Ewing" <greg at cosc.canterbury.ac.nz> wrote in message
news:3C7AFA8B.47A23F10 at cosc.canterbury.ac.nz...
> David Eppstein wrote:
> >
> > No side effects?  Try this:
> >
> > L = [x for x in range(10)]
> > print x
>
> Well, that's more of an "accidental" side effect.
> Ideally, Guido would use his time machine to go back
> and make for-loop control variables local to the
> loop, so that the same could then be done for LCs.

Actually, Guido would not use the time machine.
He assures me that exposing the looping variable was
done on purpose and that the alternative was considered
and dismissed.  The rationale for exposing the loop
variable is to make the list comprehension perform
identically to its for-loop equivalent.


Raymond Hettinger  a.k.a. rumour control





More information about the Python-list mailing list