Theoretical question about Lambda

Paul Foley see at below
Mon May 6 01:11:33 EDT 2002


On Sun, 05 May 2002 07:22:17 GMT, Alex Martelli wrote:

> Bengt Richter wrote:
>> On Thu, 02 May 2002 21:05:45 GMT, Alex Martelli <aleax at aleax.it> wrote:
>>> 
>>> I can't argue that lambda lets you do anything substantial that def
>>> doesn't -- there would be just no basis to substain such an argument.
>>> I'm curious to see what you think there might be.
>>> 
>> I'm working on it ;-) "Substantial" does present an added hurdle ;-)

> I originally thought this kind of situation might count as 'substantial':

> funs = [ (lambda : x) for x in seq ]

I'd expect that to return a list of as many functions as there are
items in seq, that all return the last value in seq.  I.e., if seq is
[1, 2, 3, 4, 5], you'd get 5 functions that all return 5, not
functions that return 1, 2, 3, 4, and 5 respectively, as I think
you're expecting (and the second version, with the "funize" function,
does work that way)

[The usual binding-vs-assignment misunderstanding that I keep trying
to explain to people who say Python's assignment is really "binding"]

-- 
Nonono, while we're making wild conjectures about the behavior of
completely irrelevant tasks, we must not also make serious mistakes,
or the data might suddenly become statistically valid.
                                                           -- Erik Naggum
(setq reply-to
  (concatenate 'string "Paul Foley " "<mycroft" '(#\@) "actrix.gen.nz>"))



More information about the Python-list mailing list