python - can lambda have more than one return -


i know lambda doesn't have return expression. normally

def one_return(a):     #logic here     c = + 1     return c 

can written:

lambda : + 1 

how write 1 in lambda function:

def two_returns(a, b):     # logic here     c = + 1     d = b * 1     return c, d 

yes, it's possible. because expression such @ end of function:

return a, b 

is equivalent this:

return (a, b) 

and there, you're returning single value: tuple happens have 2 elements. it's ok have lambda return tuple, because it's single value:

lambda a, b: (a, b) # here return implicit 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -