Inline returning of function objects

Discussion in 'Python' started by dataangel, Oct 7, 2004.

  1. dataangel

    dataangel Guest

    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.
     
    dataangel, Oct 7, 2004
    #1
    1. Advertising

  2. dataangel <> 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
     
    Thomas Heller, Oct 7, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Nish
    Replies:
    4
    Views:
    545
    Thomas Stegen
    Oct 8, 2004
  2. TGOS
    Replies:
    3
    Views:
    404
    Kevin Bracey
    Feb 28, 2005
  3. Ajay
    Replies:
    5
    Views:
    425
    Pete Becker
    Apr 1, 2006
  4. Replies:
    7
    Views:
    464
  5. 7stud
    Replies:
    11
    Views:
    755
    Dennis Lee Bieber
    Mar 20, 2007
Loading...

Share This Page