lambda with floats

monkeys paw monkey at joemoney.net
Thu Apr 8 21:32:10 EDT 2010


On 4/8/2010 7:19 PM, Patrick Maupin wrote:
> On Apr 8, 6:06 pm, monkeys paw<mon... at joemoney.net>  wrote:
>> On 4/7/2010 1:08 PM, Peter Pearson wrote:
>>
>>
>>
>>> On Tue, 06 Apr 2010 23:16:18 -0400, monkeys paw<mon... at joemoney.net>    wrote:
>>>> I have the following acre meter which works for integers,
>>>> how do i convert this to float? I tried
>>
>>>> return float ((208.0 * 208.0) * n)
>>
>>>>>>> def s(n):
>>>> ...    return lambda x: (208 * 208) * n
>>>> ...
>>>>>>> f = s(1)
>>>>>>> f(1)
>>>> 43264
>>>>>>> 208 * 208
>>>> 43264
>>>>>>> f(.25)
>>>> 43264
>>
>>> The expression "lambda x: (208 * 208) * n" is independent of x.
>>> Is that what you intended?
>>
>> Seems i should have done this:
>> g = lambda x: 208.0 * 208.0 * x
>> g(1)
>> 43264.0
>
> Yes, but then what is the 'n' for.  When you do that, you are not
> using it, and it is still confusing.
>
> Regards,
> Pat

I was going from example and looking for something useful from
the lambda feature. I come from C -> Perl -> Python (recent). I
don't find lambda very useful yet.



More information about the Python-list mailing list