Sample lambda and its equivalent function in Python