Replacement for lambda - 'def' as an expression?

Rocco Moretti roccomoretti at hotpop.com
Tue Sep 6 10:05:52 EDT 2005


en.karpachov at ospaz.ru wrote:
> On Tue, 06 Sep 2005 12:19:21 +0200
> Torsten Bronger wrote:
> 
> 
>>"talin at acm dot org" <viridia at gmail.com> writes:
>>
>>>Anyway, here's an example, then, of how 'def' could be used:
>>>
>>>add = def( a, b ):
>>>   return a + b
>>
>>I'm really not an expert in functional programming, so I wonder
>>what's the difference between "add = def" (assumed that it worked)
>>and "def add"?
> 
> 
> In the former case one could write
> 
>     self.add[0] = def(a, b)
>         # etc.

If that's the issue, it might make more sense to extend def to take any 
lvalue.

     def self.add[0](a, b):
         return a + b



More information about the Python-list mailing list