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

Possible duplicate:
why is python list.append evaluating to false?

In my opinion, I think that list1.extend(list2) and list1.append(num) should return a mutated list, not None (void). As well as a side effect of destructive changes to the original list.

+6
source share
1 answer

I believe that the goal was to promote readable code and reduce errors. This decision was made a long time ago, but you can find more by looking at the python / python-dev mailing list archives.

Python3 would be an opportunity to change this behavior, but as you see it, this is not considered a design mistake by the development team.

+2
source

Source: https://habr.com/ru/post/916217/


All Articles