If you really want to use lambda, the syntax is:
lambda param, list: return_value
For example, this is lamdba, which adds:
lambda x, y: x + y
I'm not sure how this could make your function easier, as this is the most obvious way:
def myFunction(name): for i, x in enumerate(self.getList()): if x.name == name: return i
Your lamdba would be like this:
lamdba x: x.name == name
So, one terrible way to do this:
def myFunction(name): matches = [index for index, value in enumerate(self.getList()) if value.name == name] if matches: return matches[0]
source share