It looks like you want this:
>>> sum([[1],[2]], [])
[1, 2]
You're right that it's trying to add 0 to [1] and getting an error. The solution is to give sum
an extra parameter giving the start value, which for you would be the empty list.
Edit: As gnibbler says, though, sum
is not a good way to concatenate things. And if you just want to aggregate a sequence of things, you should probably use reduce
rather than make your own __radd__
function just to use sum
. Here's an example (with the same poor behavior as sum
):
>>> reduce(lambda x, y: x+y, [[1],[2]])
[1, 2]
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…