1. Cast down
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Rep Power

    Python 3000 -- removing lambda D:

    I use lambda a lot w/ wxPython events. What should I use instead? I don't think anything can be as short as using lambda there.
  2. #2
  3. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2005
    Rep Power
    Thanks for the link.

    Perhaps it's list comprehensions that you're looking for?

    Once I needed to use lambda with map() as seen here:
    ( http://forums.devshed.com/showthread.php?p=940894#post940894 ) just to get map() to work. The list comprehension seems more elegant, at least in this case.

    Maybe that's what to use with wxpython? Any examples?

    ouch. I did like map and filter... and \'s too... and what's up with input()/raw_input() now?


  4. #3
  5. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Hull, UK
    Rep Power
    This is indeed a strange turn, obviously I should pay more attention to the PEPs .

    Still, for the most part I agree with what's happening: reducing the number of built-in functions & keywords. This makes the language cleaner. Hopefully Python will be fully standardized with this release .

    Anyway, as described in the PEP you should stop using lambda, however since this version will be such a large change I doubt that most Python programs will work with it "print" is to be removed for instance.

    I agree with 2k, list comprehension/generator expressions can be used to accomplish anything you can do with map() and lambda expressions in a clearer way.

    Because lambda is just a quick way of creating a function it should be fairly easy to expand them to be local/nested functions. You can start to do this now if you like but Python 3 is still only a dream right now, so we'll have to see how it goes.

    I wouldn't worry about it too much for now,

    Take care,

    programming language development: www.netytan.com Hula

  6. #4
  7. Commie Mutant Traitor
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Jun 2004
    Alpharetta, GA
    Rep Power
    I'm not sure how I feel about this myself. I'm a Schemer as well as a Pythoner, and lambda is used extensively in Scheme even though nested functions are also available - but that's because Scheme is more or less built from lambdas. Also, in Scheme you can use lambda expressions to generate new functions at runtime, and functions returned by a lambda expression can be passed as functional arguments to other functions; since neither of these are possible with Python lambdas AFAIK, it means there is much less need for them.
    Rev First Speaker Schol-R-LEA;2 JAM LCF ELF KoR KCO BiWM TGIF
    #define KINSEY (rand() % 7) λ Scheme is the Red Pill
    Scheme in Short Understanding the C/C++ Preprocessor
    Taming Python A Highly Opinionated Review of Programming Languages for the Novice, v1.1

    FOR SALE: One ShapeSystem 2300 CMD, extensively modified for human use. Includes s/w for anthro, transgender, sex-appeal enhance, & Gillian Anderson and Jason D. Poit clone forms. Some wear. $4500 obo. tverres@et.ins.gov

IMN logo majestic logo threadwatch logo seochat tools logo