Getting To Grips With Lambda Permalink

Today I had the chance to use Lambda for the first time. I was after a list of functions but also wanted properties and variables in the list.

funk = []

def bob():
    return "starwars"
def bib():
    return "stargate"

wibble = "Matrix"

funk.append(bob)
funk.append(bib)
funk.append(bob)
funk.append(bib)
funk.append(lambda : wibble)

for function in funk:
    print function()

Gives the output: starwars stargate starwars stargate Matrix

Posted by Davy Mitchell on 2007-06-09 13:57:25.
Categories: Python, IronPython Tags :
Like this post? Digg it or Del.icio.us it. |




Locations of visitors to this page