一部の外部コードは、次のコードの機能を実行します。
def __init__(self,weights=None,threshold=None):
print "weights: ", weights
print "threshold: ", threshold
if weights:
print "weights assigned"
self.weights = weights
if threshold:
print "threshold assigned"
self.threshold = threshold
そして、このコードは以下を出力します:
weights: [1, 2]
threshold: 0
weights assigned
つまり、 print 演算子はthreshold
is zero のif
ように動作しますが、演算子は定義されていないかのように動作します。
正しい解釈は?何が起こっている?パラメータの状態threshold
とその認識方法を教えてください。