Inline returning of function objects

Terry Reedy tjreedy at
Fri Oct 8 19:27:00 CEST 2004

"dataangel" <k04jg02 at> wrote in message 
news:41659565.3080500 at
> I've been finding more and more crazy stuff that you can do in Python, 
> and I was curious if it could handle this (it couldn't):
> def foo(x):
>    return def bar(y):
>       pass
> I was wondering why there's support for this for lambda functions not 
> normal functions.

Lambda *expressions* evaluate to normal functions.

Last I checked, the only noticable different between

f = lambda : 99 # and
def f(): return 99

is in the name attribute.  The return statement requires an expression, if 
anything, after 'return'.

Terry J. Reedy

More information about the Python-list mailing list