append
is a mutating (destructive) operation (it modifies the list in place instead of of returning a new list). The idiomatic way to do the non-destructive equivalent of append
would be
l = [1,2,3]
print l + [4] # [1,2,3,4]
print l # [1,2,3]
to answer your question, my guess is that if append
returned the newly modified list, users might think that it was non-destructive, ie they might write code like
m = l.append("a")
n = l.append("b")
and expect n
to be [1,2,3,"b"]
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…