On 04/04/2015 05:57 PM, boB Stepp wrote:
On Sat, Apr 4, 2015 at 3:35 PM, Alan Gauld <[email protected]> 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())

But the OR style is established as a kind of idiom,
not just in Python but several other languages too.

So this is not unusual for Python. BTW, what are some of the other
languages where this type of expression might be commonly used?



I don't think I've ever seen it used in Python. But it's quite common in Perl scripts and bash scripts that I've seen. In the case of bash, one might do something like:

     prog1   &&   prog2

and prog2 gets executed only if prog1 had a successful completion

--
DaveA
_______________________________________________
Tutor maillist  -  [email protected]
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to