default value in __init__
Lawrence D'Oliveiro
ldo at geek-central.gen.new_zealand
Fri Oct 17 16:20:35 EDT 2008
In message <01087685$0$20638$c3e8da3 at news.astraweb.com>, Steven D'Aprano
wrote:
> On Fri, 17 Oct 2008 23:04:52 +1300, Lawrence D'Oliveiro wrote:
>
>> The right solution, of course, is
>>
>> fns = [(lambda x : lambda : x)(x) for x in range(10)]
>
> Only if by "right solution" you mean "excessively verbose, confusing, and
> the sort of thing that makes even supporters of lambda cringe".
>
> Yes yes, it's just a factory function written with lambdas. It's still
> ugly and exactly the sort of thing that gives ammunition to lambda-
> haters.
It's NOT ugly. It's EXACTLY the right sort of thing you do with
lambda-expressions, going right back to Church.
It's no more ugly than, say, parentheses in Lisp. :)
More information about the Python-list
mailing list