Inline returning of function objects

Thomas Heller theller at python.net
Thu Oct 7 21:34:28 CEST 2004


dataangel <k04jg02 at kzoo.edu> writes:

> 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 but
> not normal functions. I tried variations in the syntax like
> surrounding the function definition with parenthesis but none worked.

but you can write:

def foo(x):
    def bar(y):
        pass
    return bar

Thomas



More information about the Python-list mailing list