Re: question about what lamda does

2006-07-21 Thread Bruno Desthuilliers
danielx wrote: > Bruno Desthuilliers wrote: > >>danielx wrote: >>(snip) >> >> >>>Python's lambda really can't be as powerful as Lisp's because Python >>>does not have expressions that do case analysis (this is not lambda's >>>fault, of course ;). The reason is that you really want to put each >>>c

Re: question about what lamda does

2006-07-20 Thread danielx
Bruno Desthuilliers wrote: > danielx wrote: > (snip) > > > Python's lambda really can't be as powerful as Lisp's because Python > > does not have expressions that do case analysis (this is not lambda's > > fault, of course ;). The reason is that you really want to put each > > case on its own set

Re: question about what lamda does

2006-07-20 Thread Bruno Desthuilliers
danielx wrote: (snip) > Python's lambda really can't be as powerful as Lisp's because Python > does not have expressions that do case analysis (this is not lambda's > fault, of course ;). The reason is that you really want to put each > case on its own set of lines. This enhances readability at th

Re: question about what lamda does

2006-07-20 Thread nephish
hey thanks for that last post, although some of it was a bit over my head. i think i am getting more of the differences here. thanks again, sk danielx wrote: > [EMAIL PROTECTED] wrote: > > Hey there, > > i have been learning python for the past few months, but i can seem to > > get what exactly a

Re: question about what lamda does

2006-07-19 Thread danielx
[EMAIL PROTECTED] wrote: > Hey there, > i have been learning python for the past few months, but i can seem to > get what exactly a lamda is for. What would i use a lamda for that i > could not or would not use a def for ? Is there a notable difference ? > I only ask because i see it in code sample

Re: question about what lamda does

2006-07-19 Thread Iain King
Steve Holden wrote: > tac-tics wrote: > > [EMAIL PROTECTED] wrote: > > > >>Hey there, > >>i have been learning python for the past few months, but i can seem to > >>get what exactly a lamda is for. What would i use a lamda for that i > >>could not or would not use a def for ? Is there a notable di

Re: question about what lamda does

2006-07-19 Thread Steve Holden
tac-tics wrote: > [EMAIL PROTECTED] wrote: > >>Hey there, >>i have been learning python for the past few months, but i can seem to >>get what exactly a lamda is for. What would i use a lamda for that i >>could not or would not use a def for ? Is there a notable difference ? >>I only ask because i

Re: question about what lamda does

2006-07-18 Thread [EMAIL PROTECTED]
I stand corrected. Not sure where I got that from, improper defragmentation due to sleep depravation perhaps... K.S.Sreeram wrote: > [EMAIL PROTECTED] wrote: > > The two primary differences between using def and using lambda is that > > lambda is limited to a single expression and def cannot be us

Re: question about what lamda does

2006-07-18 Thread tac-tics
[EMAIL PROTECTED] wrote: > Hey there, > i have been learning python for the past few months, but i can seem to > get what exactly a lamda is for. What would i use a lamda for that i > could not or would not use a def for ? Is there a notable difference ? > I only ask because i see it in code sample

Re: question about what lamda does

2006-07-18 Thread Steve Holden
[EMAIL PROTECTED] wrote: > The two primary differences between using def and using lambda is that > lambda is limited to a single expression and def cannot be used within > another function. > Where on earth did you get that from? I presume you mean "You can't use a def statement as an argument t

Re: question about what lamda does

2006-07-18 Thread K.S.Sreeram
[EMAIL PROTECTED] wrote: > The two primary differences between using def and using lambda is that > lambda is limited to a single expression and def cannot be used within > another function. 'def' can certainly be used within another function : def make_adder( delta ) : def adder( x ) :

Re: question about what lamda does

2006-07-18 Thread [EMAIL PROTECTED]
The two primary differences between using def and using lambda is that lambda is limited to a single expression and def cannot be used within another function. Basically, use lambda when you need to define a small function within another function. I've also used it to create 'shortcut' functions a

Re: question about what lamda does

2006-07-18 Thread nephish
so a lamda needs to stay at one expression, and use more than one lamda for more expressions ? i think i get it. sk Nick Vatamaniuc wrote: > Use it anywhere a quick definition of a function is needed that can be > written as an expression. For example when a callback function is > needed you cou

Re: question about what lamda does

2006-07-18 Thread Nick Vatamaniuc
Use it anywhere a quick definition of a function is needed that can be written as an expression. For example when a callback function is needed you could say: def callback(x,y): return x*y some_function(when_done_call_this=callback) But with lambda you could just write some_function(when_done_cal

Re: question about what lamda does

2006-07-18 Thread nephish
ok, i think i get it. pretty cool. thanks -sk Dan Bishop wrote: > [EMAIL PROTECTED] wrote: > > Hey there, > > i have been learning python for the past few months, but i can seem to > > get what exactly a lamda is for. > > It defines a function. > > f = lambda x, y: expression > > is equivalent to

Re: question about what lamda does

2006-07-17 Thread Dan Bishop
[EMAIL PROTECTED] wrote: > Hey there, > i have been learning python for the past few months, but i can seem to > get what exactly a lamda is for. It defines a function. f = lambda x, y: expression is equivalent to def f(x, y): return expression Note that lambda is an expression while def is

question about what lamda does

2006-07-17 Thread nephish
Hey there, i have been learning python for the past few months, but i can seem to get what exactly a lamda is for. What would i use a lamda for that i could not or would not use a def for ? Is there a notable difference ? I only ask because i see it in code samples on the internet and in books. th