Explain that "e if C" (without the "else" part) is a bad idea.

This commit is contained in:
Guido van Rossum 2003-02-07 22:29:39 +00:00
parent 63a04aad2b
commit 648a2a5acc
1 changed files with 12 additions and 0 deletions

View File

@ -110,6 +110,18 @@ Alternatives
is called. There's no way to short-circuit the expression is called. There's no way to short-circuit the expression
evaluation. evaluation.
Variations
It has been proposed to make the 'else' part optional. This would
be a really bad idea. I showed:
x = e if C
to several people and they all thought that if C was false, it
would leave x unchanged. So don't even think about this one!
Copyright Copyright
This document has been placed in the public domain. This document has been placed in the public domain.