Given these two snippets:
def sex (code):
return {'m': 'masculino', 'f': 'femenino', '': 'ignorado'} [code]
and
sex = lambda code: {'m': 'masculino', 'f': 'femenino', '': 'ignorado'} [code]
What is the actual difference? Do they have different behaviour?
And above all: Is one preferrable over the other?
I ask this, because one of my answers in this forum ( python3 - learning about searching, this very simple example does not work right ), which offered both possibilities, got truncated by another user ("revised"), deleting the lambda term. The reason for the revision was that the last option (the lambda expression) is worse than the function definition. This made me wonder:
Why are lambda expressions worse than function definitions? Especially simple ones like these.