On 05/04/15 04:45, boB Stepp wrote:
He could have done it in various other ways too:eg. lambda : all(print('Hello lambda world!'), sys.exit() )
Well, now I am curious as to why the "all" form evaluates BOTH elements. Apparently it does not apply the short-circuit logic we have been discussing, or it would stop evaluating after the print statement return. Why is that?
Because I didn't really think the example through properly. I just grabbed the first thing I could think of that would evaluate both functions... As Cameron has shown, a much more elegant solution is just to use a tuple as the body of the lambda. That's effectively what's happening indside the all()/any() calls. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos _______________________________________________ Tutor maillist - [email protected] To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
