Python - Why do extend() and append() return None (void)?

arrays, immutability, python

Solution

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

Problem

I think `list1.extend(list2)` and `list1.append(num)` should return the mutated list as well as mutating id, rather than returning `None`.

Original source

Related problems