アカウント名:
パスワード:
if condition: x = true_valueelse: x = false_value
x = true_value if condition else false_value
In many cases where a conditional expression is used, one value seems to be the 'common case' and one value is an 'exceptional case', used only on rarer occasions when the condition isn't met. --PEP 308: Conditional Expressions [python.org]
より多くのコメントがこの議論にあるかもしれませんが、JavaScriptが有効ではない環境を使用している場合、クラシックなコメントシステム(D1)に設定を変更する必要があります。
※ただしPHPを除く -- あるAdmin
Conditional Expressions (スコア:2, すばらしい洞察)
英語圏の人からは読みやすく見えるのかなぁ……。
"Complex is better than complicated."なのがPythonのいいところだと思っていたので、ちょっと残念です。
Re:Conditional Expressions (スコア:1, 参考になる)
if condition:
x = true_value
else:
x = false_value
ではなく
x = true_value # デフォルト値
if condition:
x = false_value # 例外的な値
とすると納得いくのではないかな。
Re:Conditional Expressions (スコア:3, 参考になる)