On Tue, Dec 21, 2010 at 9:36 PM, pbreit <[email protected]> wrote:
> I see lambda used quite a bit and don't totally understand the concept. Is
> there a simple rule to follow to know when it is necessary to use?
You can get away with NEVER using lambda. But it's cool to know it.
Lambda is basically a function that acts as an object. So, for
example, you can say this:
def myfunction(a):
a('this')!
myfunction(lambda x: print 'Eat %s!' % x)
and that would print 'Eat this!'.
There's nothing to it, really. Just knowing this, you'll know when you
need to use it. It's one of 3 features I love about Python.
http://docs.python.org/reference/expressions.html#lambda
--
Branko Vukelic
[email protected]
http://www.brankovukelic.com/