Created
February 15, 2015 16:23
-
-
Save ssh0/0a5fc8a7a0429c91c229 to your computer and use it in GitHub Desktop.
boolean and "A" or "B"みたいな書き方できたら賢そう【Python】【でも】 ref: http://qiita.com/ssh0/items/51aacabde077c50c0922
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 test(flag=True): | |
... print 'flag: %s' % (flag and 'on' or 'off') | |
... |
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
>>> test(True) | |
flag: on | |
>>> test(False) | |
flag: off |
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 test(flag=True): | |
... print 'flag: %s' % ('on' if flag else 'off') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment