On 2/8/06, "Martin v. Löwis" <[EMAIL PROTECTED]> wrote: > Jiwon Seo wrote: > > Then, is there any chance anonymous function - or closure - is > > supported in python 3.0 ? Or at least have a discussion about it? > > That discussion appears to be closed (or, not really: everybody > can discuss, but it likely won't change anything). > > > (IMHO, closure is very handy for function like map, sort etc. And > > having to write a function for multiple statement is kind of good in > > that function name explains what it does. However, I sometimes feel > > that having no name at all is clearer. Also, having to define a > > function when it'll be used only once seemed inappropriate sometimes.) > > Hmm. Can you give real-world examples (of existing code) where you > needed this?
Apparently, simplest example is, collection.visit(lambda x: print x) which currently is not possible. Another example is, map(lambda x: if odd(x): return 1 else: return 0, listOfNumbers) (however, with new if/else expression, that's not so much a problem any more.) Also, anything with exception handling code can't be without explicit function definition. collection.visit(lambda x: try: foo(x); except SomeError: error("error message")) Anyway, I was just curious that if anyone is interested in having more closure-like closure in python 3.0 - in any form, not necessary an extension on lambda. -Jiwon > > Regards, > Martin > _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com