Created
October 18, 2018 11:17
-
-
Save shaypal5/bc208d67df4615423c7f97dacd691ee1 to your computer and use it in GitHub Desktop.
Silence-able print one-liner for Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def foo(a, quiet=False): | |
_print = (lambda x: x) if quiet else print | |
b = a * 5 | |
_print("Warming up warp engines. This will not print if quiet is set to True.") | |
return b + 3.14 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment