On Sat, Apr 4, 2015 at 6:55 PM, Alan Gauld <alan.ga...@btinternet.com> wrote: > On 04/04/15 22:57, boB Stepp wrote: >> >> On Sat, Apr 4, 2015 at 3:35 PM, Alan Gauld <alan.ga...@btinternet.com> >> wrote: >>> >>> He could have done it in various other ways too: >>> >>> eg. >>> lambda : all(print('Hello lambda world!'), sys.exit() ) >> >> >> Is this what you meant? Because print will always return False. Or did >> you actually mean: >> >> lambda: any(print('Hello lambda world!'), sys.exit()) > > > any() would be more obvious, but in my interpreter > both any() and all() evaluate both functions before > testing the results. At least they do once you > fix the TypeError : they should be in a list/tuple... > > 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? -- boB _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor