Good code patterns in Python
jbar at lf1.cuni.cz
Tue Jul 1 18:38:22 CEST 2003
One, there has been a proposal for a ternary operator on python.org. You
know that kind of (cond) ? (eval1) : (eval2) stuff.
Two, no need to guard that code. Passing and assigning a paramater should
always make you THINK about what's happening.
Three, how about
a = 1
b = 0
if b == 0:
a = 0
a = a/b
? You cannot replace it with your pattern. Sure enough, there are far more
examples of this -- when you cannot evaluate the first expression.
More information about the Python-list