问题
Possible Duplicate:
why does python's list.append evaluate to false?
In my opinion, I think list1.extend(list2)
and list1.append(num)
should return the mutated list rather than None
(void). As well as having the side effect of destructively mutating the original list.
回答1:
I believe the intent was to promote readable code and reduce bugs. This decision was made a very long time ago, but you can probably find more by looking at the archives of the python/python-dev mailing lists.
Python3 would have been the opportunity to change this behaviour, but as you see it remains, so is not considered a design mistake by the development team
来源:https://stackoverflow.com/questions/10678226/python-why-does-extend-and-append-return-none-void