Inline returning of function objects

D

dataangel

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.
 
T

Thomas Heller

dataangel said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top